packages feed

hs-gchart 0.3 → 0.4

raw patch · 10 files changed

+202/−80 lines, 10 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

- Graphics.GChart.Types: shapeDataPoint :: ShapeMarker -> MarkerDataPoint
- Graphics.GChart.Types: shapePriority :: ShapeMarker -> Int
+ Graphics.GChart: setChartHeight :: Int -> ChartM ()
+ Graphics.GChart: setFormula :: String -> ChartM ()
+ Graphics.GChart: setLabel :: String -> ChartM ()
+ Graphics.GChart: setQREncoding :: QREncoding -> ChartM ()
+ Graphics.GChart: setQRErrorCorrection :: ErrorCorrectionLevel -> ChartM ()
+ Graphics.GChart: setQRWidth :: Int -> ChartM ()
+ Graphics.GChart.Types: Formula :: ChartType
+ Graphics.GChart.Types: H' :: ErrorCorrectionLevel
+ Graphics.GChart.Types: HorizontalLineFull :: ShapeType
+ Graphics.GChart.Types: ISO8859_1 :: QREncoding
+ Graphics.GChart.Types: L' :: ErrorCorrectionLevel
+ Graphics.GChart.Types: M' :: ErrorCorrectionLevel
+ Graphics.GChart.Types: Q' :: ErrorCorrectionLevel
+ Graphics.GChart.Types: QRCode :: ChartType
+ Graphics.GChart.Types: QRLabelData :: ErrorCorrectionLevel -> Int -> ChartLabelData
+ Graphics.GChart.Types: RadarCurvedLines :: ChartType
+ Graphics.GChart.Types: ShapeErrorBarMarker :: ShapeType
+ Graphics.GChart.Types: ShapeRectangle :: ShapeType
+ Graphics.GChart.Types: Shift_JIS :: QREncoding
+ Graphics.GChart.Types: UTF8 :: QREncoding
+ Graphics.GChart.Types: chartLabelData :: Chart -> Maybe ChartLabelData
+ Graphics.GChart.Types: data ChartLabelData
+ Graphics.GChart.Types: data ErrorCorrectionLevel
+ Graphics.GChart.Types: data QREncoding
+ Graphics.GChart.Types: defaultQREncodingLabelData :: ChartLabelData
+ Graphics.GChart.Types: instance Show ChartLabelData
+ Graphics.GChart.Types: instance Show ErrorCorrectionLevel
+ Graphics.GChart.Types: instance Show QREncoding
+ Graphics.GChart.Types: qrEncoding :: Chart -> Maybe QREncoding
+ Graphics.GChart.Types: shapeDataPoints :: ShapeMarker -> MarkerDataPoint
+ Graphics.GChart.Types: shapeWidth :: ShapeMarker -> Maybe Int
+ Graphics.GChart.Types: shapeZorder :: ShapeMarker -> Float
- Graphics.GChart: addChartData :: (ChartDataEncodable a) => [a] -> ChartM ()
+ Graphics.GChart: addChartData :: ChartDataEncodable a => [a] -> ChartM ()
- Graphics.GChart: addChartDataXY :: (ChartDataEncodable a) => [(a, a)] -> ChartM ()
+ Graphics.GChart: addChartDataXY :: ChartDataEncodable a => [(a, a)] -> ChartM ()
- Graphics.GChart.Types: Chart :: ChartSize -> ChartType -> ChartData -> Maybe ChartTitle -> Maybe ChartColors -> Maybe ChartFills -> Maybe ChartLegend -> Maybe ChartAxes -> Maybe ChartMarkers -> Maybe ChartGrid -> Maybe ChartLabels -> Maybe ChartMargins -> Maybe BarChartWidthSpacing -> Maybe PieChartOrientation -> Maybe ChartLineStyles -> Chart
+ Graphics.GChart.Types: Chart :: Maybe ChartSize -> ChartType -> Maybe ChartData -> Maybe ChartTitle -> Maybe ChartColors -> Maybe ChartFills -> Maybe ChartLegend -> Maybe ChartAxes -> Maybe ChartMarkers -> Maybe ChartGrid -> Maybe ChartLabels -> Maybe ChartMargins -> Maybe BarChartWidthSpacing -> Maybe PieChartOrientation -> Maybe ChartLineStyles -> Maybe QREncoding -> Maybe ChartLabelData -> Chart
- Graphics.GChart.Types: SM :: ShapeType -> Color -> Int -> MarkerDataPoint -> Int -> Int -> ShapeMarker
+ Graphics.GChart.Types: SM :: ShapeType -> Color -> Int -> MarkerDataPoint -> Int -> Maybe Int -> Float -> ShapeMarker
- Graphics.GChart.Types: addEncodedChartData :: (ChartDataEncodable a) => [a] -> ChartData -> ChartData
+ Graphics.GChart.Types: addEncodedChartData :: ChartDataEncodable a => [a] -> ChartData -> ChartData
- Graphics.GChart.Types: chartData :: Chart -> ChartData
+ Graphics.GChart.Types: chartData :: Chart -> Maybe ChartData
- Graphics.GChart.Types: chartSize :: Chart -> ChartSize
+ Graphics.GChart.Types: chartSize :: Chart -> Maybe ChartSize
- Graphics.GChart.Types: class (Num a) => ChartDataEncodable a
+ Graphics.GChart.Types: class Num a => ChartDataEncodable a
- Graphics.GChart.Types: class (Show a) => ChartMarker a
+ Graphics.GChart.Types: class Show a => ChartMarker a
- Graphics.GChart.Types: encode :: (ChartItem c) => c -> [(String, String)]
+ Graphics.GChart.Types: encode :: ChartItem c => c -> [(String, String)]
- Graphics.GChart.Types: encodeChartMarker :: (ChartMarker a) => a -> String
+ Graphics.GChart.Types: encodeChartMarker :: ChartMarker a => a -> String
- Graphics.GChart.Types: set :: (ChartItem c) => c -> ChartM ()
+ Graphics.GChart.Types: set :: ChartItem c => c -> ChartM ()

Files

Graphics/GChart.hs view
@@ -62,6 +62,7 @@   -- * Setting Chart Parameters     setChartSize                     ,+   setChartHeight                   ,    setChartType                     ,    setChartTitle                    ,    setChartTitleWithColor           ,@@ -79,10 +80,14 @@    addRangeMarker                   ,    addFinancialMarker               ,    setLabels                        ,+   setLabel                         ,    setBarWidthSpacing               ,    setPieChartOrientation           ,    addLineStyle                     ,-+   setFormula                       ,+   setQREncoding                    ,+   setQRWidth                       ,+   setQRErrorCorrection             ,   -- * Retrieving Chart Data    getChartData,@@ -192,6 +197,12 @@ setChartSize :: Int -> Int -> ChartM () setChartSize w h = set (Size w h) +-- | Set chart height only. Applicable to 'Formula' charts+-- This will set the width to 0 which will automatically+-- be excluded when the data is being encoded+setChartHeight :: Int -> ChartM ()+setChartHeight h = set (Size 0 h)+ -- | Set the chart type by passing a 'ChartType' setChartType :: ChartType -> ChartM () setChartType = set@@ -269,7 +280,7 @@ -- 'makeShapeMarker', it automatically adds a data index to refer to the latest -- data set addShapeMarker :: ShapeMarker -> ChartM ()-addShapeMarker marker | (shapeDataSetIdx marker) > -1 = addMarker marker+addShapeMarker marker | shapeDataSetIdx marker > (- 1) = addMarker marker                       | otherwise = do idx <- getDataSetIdx                                        let newmarker = marker { shapeDataSetIdx = idx }                                        addMarker marker@@ -277,14 +288,14 @@ -- | Adds a range marker. You can use 'makeRangeMarker' smart constructor when -- calling this function addRangeMarker :: RangeMarker -> ChartM ()-addRangeMarker marker = addMarker marker+addRangeMarker = addMarker  -- | Adds a financial marker. User `makeFinancialMarker` smart constructor when -- calling this function. If value of data set index is not specified when using -- 'makeFinancialMarker', it automatically adds a data index to refer to the latest -- data set addFinancialMarker :: FinancialMarker -> ChartM ()-addFinancialMarker marker | (financeDataSetIdx marker) > -1 = addMarker marker+addFinancialMarker marker | financeDataSetIdx marker > (- 1) = addMarker marker                           | otherwise = do idx <- getDataSetIdx                                            let newmarker = marker { financeDataSetIdx = idx }                                            addMarker marker@@ -294,6 +305,9 @@ setLabels :: [String] -> ChartM () setLabels = set . ChartLabels +-- | Set label for a chart+setLabel :: String -> ChartM ()+setLabel label = set $ ChartLabels [label]  -- | Set bar and width spacing setBarWidthSpacing :: BarChartWidthSpacing -> ChartM ()@@ -306,6 +320,26 @@ -- | Add line style addLineStyle :: LineStyle -> ChartM() addLineStyle = addLineStyleToChart++-- | Set formula. Applies only to 'Formula' charts+setFormula :: String -> ChartM ()+setFormula formula = setLabels [formula]++-- | Set QR code output encoding. Valid for 'QRCode' only+setQREncoding :: QREncoding -> ChartM ()+setQREncoding = set++-- | Sets the error correction level for 'QRCode'+setQRErrorCorrection :: ErrorCorrectionLevel -> ChartM ()+setQRErrorCorrection ec = set qrLabelData where+                           qrLabelData = QRLabelData ec defMargin+                           QRLabelData _ defMargin = defaultQREncodingLabelData++-- | Sets the width (in rows) of the white border around the data portion of the 'QRCode'+setQRWidth :: Int -> ChartM ()+setQRWidth m = set qrLabelData where+                qrLabelData = QRLabelData defEC m+                QRLabelData defEC _ = defaultQREncodingLabelData  -- | Extracts the data out of the monad and returns a value of type 'Chart' getChartData :: ChartM () -> Chart
Graphics/GChart/ChartItems.hs view
@@ -29,7 +29,9 @@  addDataToChart d = do c <- get                       let old = chartData c-                      set $ addEncodedChartData d old+                      case old of+                        Just cd -> set $ addEncodedChartData d cd+                        _       -> error "Please set data encoding before adding data"  addColorToChart color = do chart <- get                            let (ChartColors old) = fromMaybe (ChartColors []) $ chartColors chart@@ -52,10 +54,11 @@ getDataSetIdx = do chart <- get                    return $ dataSetLength chart -dataSetLength chart = case chartData chart of-                        Simple   d -> length d - 1-                        Text     d -> length d - 1-                        Extended d -> length d - 1+dataSetLength chart | isNothing $ chartData chart = -1 -- it should never get here..+                    | otherwise = case fromJust $ chartData chart of+                                    Simple   d -> length d - 1+                                    Text     d -> length d - 1+                                    Extended d -> length d - 1  addMarker :: ChartMarker m => m -> ChartM () addMarker marker = do chart <- get@@ -75,8 +78,8 @@  -- FIXME : too much boilerplate. Can it be reduced? getParams chart =  filter (/= ("","")) $ concat [encode $ chartType chart,-                                                 encode $ chartSize chart,-                                                 encode $ chartData chart,+                                                 encodeMaybe $ chartSize chart,+                                                 encodeMaybe $ chartData chart,                                                  encodeMaybe $ chartTitle   chart,                                                  encodeMaybe $ chartColors  chart,                                                  encodeMaybe $ chartFills   chart,@@ -88,5 +91,7 @@                                                  encodeMaybe $ chartMargins chart,                                                  encodeMaybe $ barChartWidthSpacing chart,                                                  encodeMaybe $ pieChartOrientation chart,-                                                 encodeMaybe $ chartLineStyles chart]+                                                 encodeMaybe $ chartLineStyles chart,+                                                 encodeMaybe $ qrEncoding chart,+                                                 encodeMaybe $ chartLabelData chart] 
Graphics/GChart/ChartItems/Basics.hs view
@@ -6,11 +6,11 @@  -- Chart Size instance ChartItem ChartSize where-    set size = updateChart $ \chart -> chart { chartSize = size }--    encode size =  asList ("chs", show width ++ "x" ++ show height) where-                   Size width height = size+    set size = updateChart $ \chart -> chart { chartSize = Just size } +    encode (Size width height) =  asList ("chs", widthStr ++ show height) where+                                  widthStr | width == 0 = ""+                                           | otherwise =  show width ++ "x"  -- Chart Type instance ChartItem ChartType where@@ -31,4 +31,7 @@                                     Venn                 -> "v"                                     ScatterPlot          -> "s"                                     Radar                -> "r"+                                    RadarCurvedLines     -> "rs"                                     GoogleOMeter         -> "gom"+                                    Formula              -> "tx"+                                    QRCode               -> "qr"
Graphics/GChart/ChartItems/Data.hs view
@@ -7,7 +7,7 @@  -- Chart Data instance ChartItem ChartData where-    set cData = updateChart $ \chart -> chart { chartData = cData }+    set cData = updateChart $ \chart -> chart { chartData = Just cData }      encode datas = asList ("chd", encodeData datas)                         where encodeData (Simple d)   = encodeSimple d@@ -22,3 +22,18 @@ instance ChartDataEncodable Float where     addEncodedChartData d cd@(Text old) = Text $ old ++ [d]     addEncodedChartData d _             = error "Invalid type for specified encoding. Use int data"+++instance ChartItem QREncoding where+    set qrEnc = updateChart $ \chart -> chart { qrEncoding = Just qrEnc }++    encode qrEnc = asList ("choe", encStr)+                   where encStr = case qrEnc of+                                    UTF8     -> "UTF-8"+                                    Shift_JIS -> "Shift_JIS"+                                    ISO8859_1  -> "ISO-8859-1"++instance ChartItem ChartLabelData where+    set chld = updateChart $ \chart -> chart { chartLabelData = Just chld }++    encode (QRLabelData ec m) = asList ("chld", concat [show ec, "|", show m])
Graphics/GChart/ChartItems/Styles.hs view
@@ -59,32 +59,38 @@  -- Shape Markers instance ChartMarker ShapeMarker where-    encodeChartMarker marker = optionalat ++  (intercalate "," $  [marker_type, color, idx, datapoint, size] ++ [show priority | priority /= 0]) where+    encodeChartMarker marker = optionalat ++  (intercalate "," $ [marker_type, color, idx, datapoint, size ++ width] ++ [show zorder | zorder /= 0]) where                                  marker_type = case shapeType marker of-                                                 ShapeArrow       -> "a"-                                                 ShapeCross       -> "c"-                                                 ShapeDiamond     -> "d"-                                                 ShapeCircle      -> "o"-                                                 ShapeSquare      -> "s"-                                                 VerticalLine     -> "v"-                                                 VerticalLineFull -> "V"-                                                 HorizontalLine   -> "h"-                                                 ShapeX           -> "x"+                                                 ShapeArrow          -> "a"+                                                 ShapeCross          -> "c"+                                                 ShapeRectangle      -> "C"+                                                 ShapeDiamond        -> "d"+                                                 ShapeErrorBarMarker -> "E"+                                                 HorizontalLine      -> "h"+                                                 HorizontalLineFull  -> "H"+                                                 ShapeCircle         -> "o"+                                                 ShapeSquare         -> "s"+                                                 VerticalLine        -> "v"+                                                 VerticalLineFull    -> "V"+                                                 ShapeX              -> "x"                                   color = shapeColor marker -                                 datapoint = case shapeDataPoint marker of+                                 datapoint = case shapeDataPoints marker of                                                DataPoint x                  ->  show x                                                DataPointEvery               ->  "-1"-                                               DataPointEveryN x            ->  "-" ++ show x+                                               DataPointEveryN x            ->  '-' : show x                                                DataPointEveryNRange (x,y) n ->  intercalate ":"$  map show [x,y,n]                                                DataPointXY (x,y)            ->  show x ++ ":" ++ show y                                   idx  = show $ shapeDataSetIdx marker                                  size = show $ shapeSize marker-                                 priority = shapePriority marker+                                 width = case shapeWidth marker of+                                           Nothing -> ""+                                           Just x  -> ":" ++ show x+                                 zorder = shapeZorder marker -                                 optionalat = [ '@' | isDataPointXY $ shapeDataPoint marker ]+                                 optionalat = [ '@' | isDataPointXY $ shapeDataPoints marker ]                                  isDataPointXY (DataPointXY _) = True                                  isDataPointXY _               = False -- Range Markers@@ -100,13 +106,13 @@  -- Financial Markers instance ChartMarker FinancialMarker where-    encodeChartMarker marker = (intercalate "," $  ["F", color, idx, datapoint, size] ++ [show priority | priority /= 0]) where+    encodeChartMarker marker = intercalate "," $  ["F", color, idx, datapoint, size] ++ [show priority | priority /= 0] where                                  color = financeColor marker                                   datapoint = case financeDataPoint marker of                                                DataPoint x                  ->  show x                                                DataPointEvery               ->  "-1"-                                               DataPointEveryN x            ->  "-" ++ show x+                                               DataPointEveryN x            ->  '-' : show x                                                DataPointEveryNRange (x,y) n ->  error "Invalid value for finanical marker"                                                DataPointXY (x,y)            ->   show x ++ ":" ++ show y 
Graphics/GChart/DataEncoding.hs view
@@ -18,7 +18,7 @@           | otherwise          = '_'  encSimpleReverse :: Char -> Int-encSimpleReverse c | ord c >= ord 'A' && ord c <= ord 'Z' = (ord c - ord 'A')+encSimpleReverse c | ord c >= ord 'A' && ord c <= ord 'Z' = ord c - ord 'A'                    | ord c >= ord 'a' && ord c <= ord 'z' = 26 + (ord c - ord 'a')                    | ord c >= ord '0' && ord c <= ord '9' = 52 + (ord c - ord '0')                    | otherwise = -1
Graphics/GChart/Types.hs view
@@ -14,26 +14,22 @@  - Dynamic Icons <http://code.google.com/apis/chart/docs/gallery/dynamic_icons.html> -- Formula Chart <http://code.google.com/apis/chart/docs/gallery/formulas.html>- - Map Charts <http://code.google.com/apis/chart/docs/gallery/map_charts.html> -- QR Codes <http://code.google.com/apis/chart/docs/gallery/qr_codes.html>- Some parameters are not supported yet:  - Chart Data Scaling <http://code.google.com/apis/chart/docs/data_formats.html#data_scaling>  - Text and Data Value Markers <http://code.google.com/apis/chart/docs/chart_params.html#gcharts_data_point_labels> -- QR code output encoding <http://code.google.com/apis/chart/docs/gallery/qr_codes.html>- - Bar chart zero line <http://code.google.com/apis/chart/docs/gallery/bar_charts.html#chp>  - Dynamic icon type <http://code.google.com/apis/chart/docs/gallery/dynamic_icons.html>  - Geographic area <http://code.google.com/apis/chart/docs/gallery/map_charts.html> +- Shape offset feature for shape markers  <http://code.google.com/apis/chart/docs/chart_params.html#gcharts_shape_markers>+ -}  module Graphics.GChart.Types (@@ -42,8 +38,8 @@   -- | Typeclasses for abstraction   ChartM, ChartItem(set,encode), ChartDataEncodable(addEncodedChartData), -  -- * Chart data-  -- | This type represents the Chart+  -- * Chart+  -- | Data type to represent the chart   Chart(..),    -- * Chart Parameters@@ -52,7 +48,6 @@       More details : <http://code.google.com/apis/chart/docs/chart_params.html>   -} -   -- ** Bar Width and Spacing   BarChartWidthSpacing(..), BarWidth(..), BarGroupSpacing(..), @@ -75,18 +70,24 @@   -- ** Pie chart labels, Google-o-meter label (TODO: QR code data, Formula TeX data)   ChartLabels(..), -  -- *** Line Styles+  -- ** Chart Label Data+  ChartLabelData(..), ErrorCorrectionLevel(..),++  -- ** Line Styles   ChartLineStyles(..), LineStyle(..), -  -- *** Shape, Range and Financial Markers+  -- ** Shape, Range and Financial Markers   AnyChartMarker(..), ChartMarker(..), ChartMarkers,   ShapeType(..), MarkerDataPoint(..), ShapeMarker(..),   RangeMarkerType(..), RangeMarker(..), FinancialMarker(..), -  -- *** Chart Margins+  -- ** Chart Margins   ChartMargins(..), -  -- *** Pie Chart Orientation+  -- ** QR code output encoding+  QREncoding(..),++  -- ** Pie Chart Orientation   PieChartOrientation(..),    -- ** Chart Size@@ -95,10 +96,10 @@   -- ** Chart Type   ChartType(..), -  -- *** Chart Title and Style+  -- ** Chart Title and Style   ChartTitle(..), -  -- *** Visible Axis Axis styles and labels+  -- ** Visible Axis Axis styles and labels   ChartAxes, Axis(..), AxisType(..), AxisLabel, AxisPosition, FontSize,   AxisRange(..), AxisStyle(..), DrawingControl(..), AxisStyleAlignment(..), @@ -107,7 +108,7 @@        used as starting points to construct parameters when creating charts. -}    defaultChart, defaultAxis, defaultGrid, defaultSpacing, defaultShapeMarker,-  defaultRangeMarker, defaultFinancialMarker, defaultLineStyle+  defaultRangeMarker, defaultFinancialMarker, defaultLineStyle, defaultQREncodingLabelData ) where  import Control.Monad.State@@ -131,7 +132,10 @@   | Venn                  -- ^ Venn Diagram   | ScatterPlot           -- ^ Scatter Plot   | Radar                 -- ^ Radar Chart+  | RadarCurvedLines      -- ^ Radar Chart, connects points with curved lines   | GoogleOMeter          -- ^ Google-o-meter+  | Formula               -- ^ Formula Chart+  | QRCode                -- ^ QR Codes     deriving Show  -- | Title of the chart@@ -279,15 +283,18 @@     } deriving Show  -- | Shape type of 'ShapeMarker'-data ShapeType = ShapeArrow       -- ^ Arrow-               | ShapeCross       -- ^ Cross-               | ShapeDiamond     -- ^ Diamond-               | ShapeCircle      -- ^ Circle-               | ShapeSquare      -- ^ Square-               | VerticalLine     -- ^ Vertical line from x-axis to data point-               | VerticalLineFull -- ^ Vertical line across the chart-               | HorizontalLine   -- ^ Horizontal line across the chart-               | ShapeX           -- ^ X shape+data ShapeType = ShapeArrow            -- ^ Arrow+               | ShapeCross            -- ^ Cross+               | ShapeRectangle        -- ^ Rectangle+               | ShapeDiamond          -- ^ Diamond+               | ShapeErrorBarMarker   -- ^ Error Bar Marker+               | HorizontalLine        -- ^ Horizontal line across the chart at specified height+               | HorizontalLineFull    -- ^ Horizontal line through the specified data marker+               | ShapeCircle           -- ^ Circle+               | ShapeSquare           -- ^ Square+               | VerticalLine          -- ^ Vertical line from x-axis to data point+               | VerticalLineFull      -- ^ Vertical line across the chart+               | ShapeX                -- ^ X shape                  deriving Show  @@ -315,12 +322,19 @@  -- | Shape Marker data ShapeMarker =-    SM { shapeType  :: ShapeType           -- ^ Shape type-       , shapeColor :: Color               -- ^ Shape Marker color-       , shapeDataSetIdx :: Int            -- ^ Data Set Index-       , shapeDataPoint  :: MarkerDataPoint -- ^ Data point value-       , shapeSize :: Int                  -- ^ Size in pixels-       , shapePriority :: Int              -- ^ Priority of drawing. Can be one of -1,0,1+    SM { shapeType  :: ShapeType             -- ^ Shape type+       , shapeColor :: Color                 -- ^ Shape Marker color+       , shapeDataSetIdx :: Int              -- ^ Data Set Index+       , shapeDataPoints  :: MarkerDataPoint -- ^ Data point value+       , shapeSize :: Int                    -- ^ Size in pixels+       , shapeWidth :: Maybe Int             -- ^ Optional width used for certain shapes+       , shapeZorder :: Float                -- ^ The layer on which to draw the+                                             -- marker. This is a floating point+                                             -- number from -1.0 to 1.0,+                                             -- inclusive, where -1.0 is the+                                             -- bottom and 1.0 is the top++       -- TODO Add shape offset feature        } deriving Show  -- | 'RangeMarker' type@@ -412,12 +426,31 @@  type ChartLineStyles = [LineStyle] +-- | QR Code Output Encoding+data QREncoding = UTF8 | Shift_JIS | ISO8859_1 deriving Show++-- | Error Correction Level for QR Code+data ErrorCorrectionLevel = L' -- ^ recovery of up to 7% data loss+                          | M' -- ^ recovery of up to 15% data loss+                          | Q' -- ^ recovery of up to 25% data loss+                          | H' -- ^ recovery of up to 30% data loss++instance Show ErrorCorrectionLevel where+    show L' = "L"+    show M' = "M"+    show Q' = "Q"+    show H' = "H"++-- | Chart Label Data. Applies to 'QRCode'+data ChartLabelData = QRLabelData ErrorCorrectionLevel Int -- ^ Error Correction Level and Margin (as no. of rows)+                      deriving Show+ -- | Data type for the chart data Chart =     Chart {-      chartSize    :: ChartSize+      chartSize    :: Maybe ChartSize     , chartType    :: ChartType-    , chartData    :: ChartData+    , chartData    :: Maybe ChartData     , chartTitle   :: Maybe ChartTitle     , chartColors  :: Maybe ChartColors     , chartFills   :: Maybe ChartFills@@ -430,6 +463,8 @@     , barChartWidthSpacing :: Maybe BarChartWidthSpacing     , pieChartOrientation  :: Maybe PieChartOrientation     , chartLineStyles      :: Maybe ChartLineStyles+    , qrEncoding           :: Maybe QREncoding+    , chartLabelData       :: Maybe ChartLabelData     } deriving Show  @@ -460,9 +495,9 @@  -- | Default value for a chart defaultChart =-    Chart { chartSize  = Size 320 200,+    Chart { chartSize  = Nothing,             chartType  = Line,-            chartData  = Simple [],+            chartData  = Nothing,             chartTitle = Nothing,             chartColors = Nothing,             chartFills = Nothing,@@ -474,7 +509,9 @@             chartMarkers = Nothing,             barChartWidthSpacing = Nothing,             pieChartOrientation = Nothing,-            chartLineStyles = Nothing+            chartLineStyles = Nothing,+            qrEncoding = Nothing,+            chartLabelData = Nothing           }  -- | Default value for an axis@@ -506,9 +543,10 @@ defaultShapeMarker =  SM { shapeType = ShapeCircle,                            shapeColor = "0000DD",                            shapeDataSetIdx = -1,-                           shapeDataPoint = DataPointEvery,+                           shapeDataPoints = DataPointEvery,                            shapeSize = 5,-                           shapePriority = 0 }+                           shapeWidth = Nothing,+                           shapeZorder = 0 }  -- | Default value of range marker defaultRangeMarker = RM { rangeMarkerType  = RangeMarkerHorizontal,@@ -526,4 +564,7 @@ defaultLineStyle = LS { lineStyleThickness = 1,                         lineStyleLineSegment = 1,                         lineStyleBlankSegment = 0 }++-- | Default chart label data for QR Encoding+defaultQREncodingLabelData = QRLabelData L' 4 
README.md view
@@ -9,7 +9,7 @@ that effort by trying to design a more elegant API, and supporting more chart types and features. -[GoogleChart]: http://hackage.haskell.org/packages/archive/GoogleChart/0.3/doc/html/Graphics-Google-Chart.html+[GoogleChart]: http://hackage.haskell.org/packages/archive/GoogleChart/0.2/doc/html/Graphics-Google-Chart.html  ## Installation @@ -19,7 +19,7 @@  * [API functions reference](http://hackage.haskell.org/package/hs-gchart) -* [Haskell data types reference](http://hackage.haskell.org/packages/archive/hs-gchart/0.2/doc/html/Graphics-GChart-Types.html)+* [Haskell data types reference](http://hackage.haskell.org/packages/archive/hs-gchart/0.4/doc/html/Graphics-GChart-Types.html)  * [Google Chart API] @@ -73,6 +73,7 @@ The code below      barGraph = getChartUrl $ do setChartSize 600 300+                                setDataEncoding simple                                 setChartType BarHorizontalGrouped                                 addChartData dataSeries1                                 setChartTitle "Food and Drink Consumed Christmas 2007"
examples/Examples.hs view
@@ -2,9 +2,9 @@ import Data.Char(ord) {- -Some examples to demonstrate usage of GChart.+Examples to demonstrate usage of GChart. -All examples are taken from this article : http://24ways.org/2007/tracking-christmas-cheer-with-google-charts+Some examples are taken from this article : http://24ways.org/2007/tracking-christmas-cheer-with-google-charts  -} @@ -26,6 +26,7 @@   barGraph = getChartUrl $ do setChartSize 600 300+                            setDataEncoding simple                             setChartType BarHorizontalGrouped                             addChartData dataSeries1                             setChartTitle "Food and Drink Consumed Christmas 2007"@@ -90,7 +91,7 @@                                        addChartData ([10,15,20,25,30]::[Int])                                        addChartData ([13,5,6,34,12]::[Int])                                        setColors ["4d89f9","000000"]-                                       setBarWidthSpacing $ automatic+                                       setBarWidthSpacing automatic   bargraphRelativeSpacing = getChartUrl $ do setChartSize 190 125@@ -125,8 +126,21 @@                                             addChartData $ map encSimpleReverse "IJKNUWUWYdnswz047977315533zy1246872tnkgcaZQONHCECAAAAEII"                                            addLineStyle $ makeLineStyle { lineStyleThickness = 1, lineStyleLineSegment = 1, lineStyleBlankSegment = 0 }-blanks x = take x $ repeat "" +formulaChart = getChartUrl $ do setChartType Formula+                                setChartHeight 200+                                setFormula "\\Large\\mathbb{Q}+\\lim_{x\\to3}\\frac{1}{x}"+                                addColor "FF0000"+                                addFill $ Fill (LinearGradient 20 [("76A4FB",1),("FFFFFF",0)]) Background++qrCodeChart = getChartUrl $ do setChartType QRCode+                               setChartSize 150 150+                               setLabel "Hello World"+                               setQREncoding UTF8+                               setQRErrorCorrection L'++blanks x = replicate x ""+ dataSeries1 :: [Int] dataSeries1 = [10,20,8,25,5,3,15,9,5] @@ -155,7 +169,7 @@                 "Snacks"]  encSimpleReverse :: Char -> Int-encSimpleReverse c | ord c >= ord 'A' && ord c <= ord 'Z' = (ord c - ord 'A')+encSimpleReverse c | ord c >= ord 'A' && ord c <= ord 'Z' = ord c - ord 'A'                    | ord c >= ord 'a' && ord c <= ord 'z' = 26 + (ord c - ord 'a')                    | ord c >= ord '0' && ord c <= ord '9' = 52 + (ord c - ord '0')                    | otherwise = -1@@ -169,3 +183,6 @@           putStrLn bargraphRelativeSpacing           putStrLn scatterPlotWithMarkers           putStrLn lineChartWithLineStyles+          putStrLn formulaChart+          putStrLn qrCodeChart+
hs-gchart.cabal view
@@ -1,5 +1,5 @@ name: hs-gchart-version: 0.3+version: 0.4 synopsis: Haskell wrapper for the Google Chart API description:     This module is a wrapper around the Google Chart API. It exposes a rich