Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
Import this module to generate charts using the Google Chart API.
For more information about the Google Chart API, refer to
- Chart API Intro http://code.google.com/apis/chart/image_charts.html
- Getting Started http://code.google.com/apis/chart/docs/making_charts.html
For documentation full Haskell data model, refer to Graphics.GChart.Types.
Here is an example to use the functions in the module to generate a chart URL :
generatePieChart = getChartUrl $ do setChartSize 640 400 setChartType Pie setChartTitle "Test" addChartData ([1,2,3,4,5]::[Int]) addColor "FF0000" setLegend $ legend ["t1","t2", "t3","t4","t5"] setLabels $ ["Test 1", "Test 2", "Test 3", "Test 4", "Test 5"]
For examples, refer to Examples.hs
in the source tarball, or download it
directly from Github :
http://github.com/deepakjois/hs-gchart/blob/master/examples/Examples.hs.
The module constists of:
- Smart Constructors - to make it convenient to construct data types
- Functions to set chart data
- Functions to retrieve chart data in form of URL or Haskell data type
Synopsis
- module Graphics.GChart.Types
- solid :: Color -> FillType -> Fill
- legend :: [String] -> ChartLegend
- legendWithPosition :: [String] -> LegendPosition -> ChartLegend
- makeAxis :: Axis
- makeGrid :: ChartGrid
- simple :: ChartData
- text :: ChartData
- extended :: ChartData
- automatic :: BarChartWidthSpacing
- automaticWithSpacing :: Int -> Int -> BarChartWidthSpacing
- barwidth :: Int -> BarChartWidthSpacing
- barwidthspacing :: Int -> Int -> Int -> BarChartWidthSpacing
- relative :: Float -> Float -> BarChartWidthSpacing
- makeShapeMarker :: ShapeMarker
- makeRangeMarker :: RangeMarker
- makeFinancialMarker :: FinancialMarker
- makeLineMarker :: LineMarker
- makeLineStyle :: LineStyle
- setChartSize :: Int -> Int -> ChartM ()
- setChartHeight :: Int -> ChartM ()
- setChartType :: ChartType -> ChartM ()
- setChartTitle :: String -> ChartM ()
- setChartTitleWithColor :: String -> Color -> ChartM ()
- setChartTitleWithColorAndFontSize :: String -> Color -> FontSize -> ChartM ()
- setDataEncoding :: ChartData -> ChartM ()
- addChartData :: ChartDataEncodable a => [a] -> ChartM ()
- addDataScale :: DataScale -> ChartM ()
- addChartDataXY :: ChartDataEncodable a => [(a, a)] -> ChartM ()
- setColors :: [Color] -> ChartM ()
- addColor :: Color -> ChartM ()
- addFill :: Fill -> ChartM ()
- setLegend :: ChartLegend -> ChartM ()
- addAxis :: Axis -> ChartM ()
- setGrid :: ChartGrid -> ChartM ()
- addShapeMarker :: ShapeMarker -> ChartM ()
- addRangeMarker :: RangeMarker -> ChartM ()
- addFinancialMarker :: FinancialMarker -> ChartM ()
- addLineMarker :: LineMarker -> ChartM ()
- addLineFill :: LineFillType -> Color -> ChartM ()
- setLabels :: [String] -> ChartM ()
- setLabel :: String -> ChartM ()
- setBarWidthSpacing :: BarChartWidthSpacing -> ChartM ()
- setPieChartOrientation :: Float -> ChartM ()
- addLineStyle :: LineStyle -> ChartM ()
- setFormula :: String -> ChartM ()
- setQREncoding :: QREncoding -> ChartM ()
- setQRWidth :: Int -> ChartM ()
- setQRErrorCorrection :: ErrorCorrectionLevel -> ChartM ()
- getChartData :: ChartM () -> Chart
- getChartUrl :: ChartM () -> String
- convertToUrl :: Chart -> String
Documentation
module Graphics.GChart.Types
Smart Constructors
legend :: [String] -> ChartLegend Source #
generates a ChartLegend
from a list of labels
legendWithPosition :: [String] -> LegendPosition -> ChartLegend Source #
generats a ChartLegend
from a list of lables and a LegendPosition
returns a default axis. Use this to override the fields with your own values. For e.g :
makeAxis {axisType
=AxisTop
,axisLabels
= ["0","50","100"] }
Use this to specify the Simple
encoding for the setDataEncoding
function.
extended :: ChartData Source #
Use this to specify the Extended
encoding for the setDataEncoding
function.
automatic :: BarChartWidthSpacing Source #
Set automatic bar width for bar chart
automaticWithSpacing :: Int -> Int -> BarChartWidthSpacing Source #
Set automatic bar width for bar chart, with spacing values
barwidth :: Int -> BarChartWidthSpacing Source #
Set bar width for chart
barwidthspacing :: Int -> Int -> Int -> BarChartWidthSpacing Source #
Set bar width and spacing for chart
makeShapeMarker :: ShapeMarker Source #
Shape Marker
makeRangeMarker :: RangeMarker Source #
Range Marker
makeFinancialMarker :: FinancialMarker Source #
Financial Marker
makeLineMarker :: LineMarker Source #
Line Marker
makeLineStyle :: LineStyle Source #
Line Style
Setting Chart Parameters
setChartSize :: Int -> Int -> ChartM () Source #
Set the chart size by passing the width and the height in pixels
For e.g : setChartSize 320 200
setChartHeight :: Int -> ChartM () Source #
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
setChartTitle :: String -> ChartM () Source #
Set the chart title by passing a ChartTitle
setChartTitleWithColorAndFontSize :: String -> Color -> FontSize -> ChartM () Source #
Set the chart title with color and font size
setDataEncoding :: ChartData -> ChartM () Source #
addChartData :: ChartDataEncodable a => [a] -> ChartM () Source #
Add data to chart. Make sure you have set the data encoding using
setDataEncoding
before calling this function, otherwise it may generate
gibberish, or throw an error
addDataScale :: DataScale -> ChartM () Source #
Add a scale to chart.If more than one scale is added, it applies the scale in order to each data series
addChartDataXY :: ChartDataEncodable a => [(a, a)] -> ChartM () Source #
Works like addChartData
, but for XY datasets for line XY chart etc
setColors :: [Color] -> ChartM () Source #
Pass a list of colors corresponding to the datasets in the chart
addColor :: Color -> ChartM () Source #
Add a color to the chart. This color will be added to the list ChartColors
.
Make sure you do not include a call to setColors
at any time after a call to
addColor
, since this will lead to all previous values being erased.
setLegend :: ChartLegend -> ChartM () Source #
Set a Legend for the chart
addShapeMarker :: ShapeMarker -> ChartM () Source #
Adds a shape marker. Use makeShapeMarker
smart constructor when calling
this function If value of data set index is not specified when using
makeShapeMarker
, it automatically adds a data index to refer to the latest
data set
addRangeMarker :: RangeMarker -> ChartM () Source #
Adds a range marker. You can use makeRangeMarker
smart constructor when
calling this function
addFinancialMarker :: FinancialMarker -> ChartM () Source #
Adds a financial marker. Use 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
addLineMarker :: LineMarker -> ChartM () Source #
Adds a line marker. Use makeLineMarker
smart constructor when calling
this function. If value of data set index is not specified when using
makeLineMarker
, it automatically adds a data index to refer to the
latest data set
addLineFill :: LineFillType -> Color -> ChartM () Source #
Adds a line fill to the chart
setBarWidthSpacing :: BarChartWidthSpacing -> ChartM () Source #
Set bar and width spacing
setPieChartOrientation :: Float -> ChartM () Source #
Set pie chart orientation in radians
addLineStyle :: LineStyle -> ChartM () Source #
Add line style
setQREncoding :: QREncoding -> ChartM () Source #
Set QR code output encoding. Valid for QRCode
only
setQRWidth :: Int -> ChartM () Source #
Sets the width (in rows) of the white border around the data portion of the QRCode
setQRErrorCorrection :: ErrorCorrectionLevel -> ChartM () Source #
Sets the error correction level for QRCode
Retrieving Chart Data
getChartData :: ChartM () -> Chart Source #
Extracts the data out of the monad and returns a value of type Chart
getChartUrl :: ChartM () -> String Source #
Extracts the data out of the monad and returns a URL string for the chart