Graphics.GChart
Description
Import this module to generate charts using the Google Chart API.
For more examples, refer to Examples.hs in the source tarball, or download it
directly from Github : http://github.com/hs-gchart/.
For documentation regarding the full data model, refer to Graphics.GChart.Types.
For more information about the Google Chart API, refer to http://code.google.com/apis/chart/
- module Graphics.GChart.Types
- setChartSize :: Int -> Int -> ChartM ()
- setChartType :: ChartType -> ChartM ()
- setDataEncoding :: ChartData -> ChartM ()
- setChartTitle :: String -> ChartM ()
- addChartData :: ChartDataEncodable a => [a] -> 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 ()
- setLabels :: [String] -> ChartM ()
- getChartData :: ChartM () -> Chart
- getChartUrl :: ChartM () -> String
- convertToUrl :: Chart -> String
- solid :: Color -> FillType -> Fill
- legend :: [String] -> ChartLegend
- legendWithPosition :: [String] -> LegendPosition -> ChartLegend
- makeAxis :: Axis
- makeGrid :: ChartGrid
- simple :: ChartData
- text :: ChartData
- extended :: ChartData
Documentation
module Graphics.GChart.Types
Setting Chart Parameters
Use these functions to set the parameters of the chart.
These functions must be called inside a do block, which can then be passed
onto getChartUrl or getChartData. For e.g, here is a simple pie chart function
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"]
setChartSize :: Int -> Int -> ChartM ()Source
Set the chart size by passing the width and the height in pixels
For e.g : setChartSize 320 200
setChartType :: ChartType -> ChartM ()Source
Set the chart type by passing a ChartType
setDataEncoding :: ChartData -> ChartM ()Source
setChartTitle :: String -> ChartM ()Source
Set the chart title by passing a ChartTitle
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
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
Retrieving Chart data
getChartData :: ChartM () -> ChartSource
Extracts the data out of the monad and returns a value of type Chart
getChartUrl :: ChartM () -> StringSource
Extracts the data out of the monad and returns a URL string for the chart
convertToUrl :: Chart -> StringSource
Converts a value of type Chart to a URL
Smart Constructors
These functions can be used to construct chart parameters more conveniently
legend :: [String] -> ChartLegendSource
generates a Solid fill from a hex color value
generates a ChartLegend from a list of labels
legendWithPosition :: [String] -> LegendPosition -> ChartLegendSource
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.
Use this to specify the Text encoding for the setDataEncoding
function.
Use this to specify the Extended encoding for the setDataEncoding
function.