This module contains the Haskell data model for the Google Chart API.
Details about the parameters can be found on the Google Chart API website : http://code.google.com/apis/chart/
Some chart types are not supported yet :
- Maps http://code.google.com/apis/chart/types.html#maps
- QRCodes http://code.google.com/apis/chart/types.html#qrcodes
Some parameters are not supported yet :
- Data Scaling http://code.google.com/apis/chart/formats.html#data_scaling
- Bar chart zero line http://code.google.com/apis/chart/styles.html#zero_line
- Data point labels http://code.google.com/apis/chart/labels.html#data_point_labels
- Fill area http://code.google.com/apis/chart/colors.html#fill_area_marker
- Line Styles http://code.google.com/apis/chart/styles.html#line_styles
- Pie chart orientation http://code.google.com/apis/chart/types.html#pie_charts
- type ChartM a = State Chart a
- class ChartItem c where
- class Num a => ChartDataEncodable a where
- addEncodedChartData :: [a] -> ChartData -> ChartData
- data Chart = Chart {
- chartSize :: ChartSize
- chartType :: ChartType
- chartData :: ChartData
- chartTitle :: Maybe ChartTitle
- chartColors :: Maybe ChartColors
- chartFills :: Maybe ChartFills
- chartLegend :: Maybe ChartLegend
- chartAxes :: Maybe ChartAxes
- chartMarkers :: Maybe ChartMarkers
- chartGrid :: Maybe ChartGrid
- chartLabels :: Maybe ChartLabels
- chartMargins :: Maybe ChartMargins
- barChartWidthSpacing :: Maybe BarChartWidthSpacing
- data ChartSize = Size Int Int
- data ChartData
- data ChartType
- = Line
- | Sparklines
- | LineXY
- | BarHorizontalStacked
- | BarVerticalStacked
- | BarHorizontalGrouped
- | BarVerticalGrouped
- | Pie
- | Pie3D
- | PieConcentric
- | Venn
- | ScatterPlot
- | Radar
- | GoogleOMeter
- data ChartColors = ChartColors [Color]
- type Color = String
- type ChartFills = [Fill]
- data Fill = Fill FillKind FillType
- data FillKind
- = Solid Color
- | LinearGradient Angle [(Color, Offset)]
- | LinearStripes Angle [(Color, Width)]
- data FillType
- = Background
- | Area
- | Transparent
- type Offset = Float
- type Width = Float
- type Angle = Float
- data ChartTitle = ChartTitle {}
- data ChartLegend = Legend [String] (Maybe LegendPosition)
- data LegendPosition
- = LegendBottom
- | LegendTop
- | LegendVBottom
- | LegendVTop
- | LegendRight
- | LegendLeft
- data ChartLabels = ChartLabels [String]
- type ChartAxes = [Axis]
- data Axis = Axis {}
- data AxisType
- = AxisBottom
- | AxisTop
- | AxisLeft
- | AxisRight
- type AxisLabel = String
- type AxisPosition = Float
- type FontSize = Int
- data AxisRange = Range (Float, Float) (Maybe Float)
- data AxisStyle = Style {}
- data DrawingControl
- = DrawLines
- | DrawTicks
- | DrawLinesTicks
- data AxisStyleAlignment
- type BarChartWidthSpacing = (Maybe BarWidth, Maybe BarGroupSpacing)
- data BarWidth
- data BarGroupSpacing
- data ChartMargins = ChartMargins {
- leftMargin :: Int
- rightMargin :: Int
- topMargin :: Int
- bottomMargin :: Int
- legendMargins :: Maybe (Int, Int)
- data ChartGrid = ChartGrid {}
- data AnyChartMarker = forall w . ChartMarker w => AnyChartMarker w
- class Show a => ChartMarker a where
- encodeChartMarker :: a -> String
- type ChartMarkers = [AnyChartMarker]
- data ShapeType
- = ShapeArrow
- | ShapeCross
- | ShapeDiamond
- | ShapeCircle
- | ShapeSquare
- | VerticalLine
- | VerticalLineFull
- | HorizontalLine
- | ShapeX
- data MarkerDataPoint
- = DataPoint Float
- | DataPointEvery
- | DataPointEveryN Int
- | DataPointEveryNRange (Int, Int) Int
- | DataPointXY (Float, Float)
- data ShapeMarker = SM {}
- data RangeMarkerType
- data RangeMarker = RM {}
- data FinancialMarker = FM {}
- defaultChart :: Chart
- defaultAxis :: Axis
- defaultGrid :: ChartGrid
- defaultSpacing :: BarGroupSpacing
- defaultShapeMarker :: ShapeMarker
- defaultRangeMarker :: RangeMarker
- defaultFinancialMarker :: FinancialMarker
Typeclasses
Typeclasses for abstraction
type ChartM a = State Chart aSource
Chart monad which wraps a State
monad in turn
to keep track of the chart state and make it convenient
to update it
Typeclass abstracting all the fields in a chart
class Num a => ChartDataEncodable a whereSource
Typeclass abstracting the numeric data that can be encoded. This helps in passing Int and Float values as chart data, which are then encoded correctly
addEncodedChartData :: [a] -> ChartData -> ChartDataSource
Adds the array of numeric data to the existing chart data. Throws a error if the data passed in doesnt match with the current data encoding format.
Chart data
This type represents the Chart
Data type for the chart
Required Parameters
These parameters are required for all charts
Chart Size
Size of the chart. width and height specified in pixels
Chart Data
Chart data along with encoding. XY data for is encoded a pair of | consecutive data sets | http://code.google.com/apis/chart/formats.html
Chart Type
Chart type http://code.google.com/apis/chart/types.html
Line | Line Chart |
Sparklines | Sparklines |
LineXY | Line Chart w/ XY co-ordinates |
BarHorizontalStacked | Horizontal bar chart w/ stacked bars |
BarVerticalStacked | Vertical bar chart w/ stacked bars |
BarHorizontalGrouped | Horizontal bar chart w/ grouped bars |
BarVerticalGrouped | Vertical bar chart w/ grouped bars |
Pie | Two dimensional pie chart |
Pie3D | Three dimensional pie chart |
PieConcentric | Concentric pie chart |
Venn | Venn Diagram |
ScatterPlot | Scatter Plot |
Radar | Radar Chart |
GoogleOMeter | Google-o-meter |
Optional Parameters
All other parameters are optional
Colors
Chart Colors
data ChartColors Source
Chart colors specified as a list of Color
values for each data point.
http://code.google.com/apis/chart/colors.html#chart_colors
Chart Fills : Solid Fill, Linear Gradient, Linear Stripes
type ChartFills = [Fill]Source
Chart fills, as a list of Fill
s
Specifies the kind of fill
Specifies the type of fill
Background | Background fill |
Area | Chart area fill |
Transparent | Apply transparency to whole chart (applicable to |
Specifies at what point the color is pure. In this parameter, 0 specifies
the right-most chart position and 1 specifies the left-most chart
position. Applicable to LinearGradient
Width of the stripe. must be between 0 and 1, where 1 is the full width of the chart
Specifies the angle of the gradient between 0 (horizontal) and 90
(vertical). Applicable to LinearGradient
and LinearStripes
Labels
Chart Title
data ChartTitle Source
Title of the chart | http://code.google.com/apis/chart/labels.html#chart_title
ChartTitle | |
|
Chart Legend
data ChartLegend Source
Specifies a chart legend http://code.google.com/apis/chart/labels.html#chart_legend
data LegendPosition Source
Position of legend on chart. Applies to ChartLegend
LegendBottom | Bottom of chart, horizontally |
LegendTop | Top of chart, horizontally |
LegendVBottom | Bottom of chart, vertically |
LegendVTop | Bottom of chart, vertically |
LegendRight | Left of chart |
LegendLeft | Right of chart |
Pie chart and Google-o-meter labels
data ChartLabels Source
Labels for Pie Chart and Google-o-meter. Specify a list with a single label for Google-o-meter
Axis styles and labels
Specify an axis for chart. http://code.google.com/apis/chart/labels.html#axis_styles
Axis | |
|
AxisBottom | Bottom x-axis |
AxisTop | Top x-axis |
AxisLeft | Left y-axis |
AxisRight | Right y-axis |
type AxisPosition = FloatSource
Axis
Label Positions. http://code.google.com/apis/chart/labels.html#axis_label_positions
Labels with a specified position of 0 are placed at the bottom of the y- or r-axis, or at the left of the x- or t-axis.
Labels with a specified position of 100 are placed at the top of the y- or r-axis, or at the right of the x- or t-axis.
Font size in pixels. Applicable to AxisStyle
and ChartTitle
Axis
Range http://code.google.com/apis/chart/labels.html#axis_range
The range is specifies with a tuple containing the start and end values. An optional interval value can be specified.
data DrawingControl Source
DrawLines | Draw axis lines only |
DrawTicks | Draw tick marks only |
DrawLinesTicks | Draw axis lines and tick marks |
data AxisStyleAlignment Source
AxisStyleLeft | Left aligned labels |
AxisStyleCenter | Centered labels |
AxisStyleRight | Right aligned labels |
Styles
Bar width and spacing
type BarChartWidthSpacing = (Maybe BarWidth, Maybe BarGroupSpacing)Source
Bar Width and Spacing.
Bar Width
data BarGroupSpacing Source
Bar and Group Spacing
Chart Margins
data ChartMargins Source
Chart Margins. All margin values specified are the minimum margins around the plot area, in pixels. http://code.google.com/apis/chart/styles.html#chart_margins
ChartMargins | |
|
Grid Lines
Grid Lines for Chart http://code.google.com/apis/chart/styles.html#grid
Shape, Range and Financial Markers
data AnyChartMarker Source
Data type to abstract over all kinds of ChartMarker
forall w . ChartMarker w => AnyChartMarker w |
class Show a => ChartMarker a whereSource
Typeclass to abstract over different chart markers
encodeChartMarker :: a -> StringSource
type ChartMarkers = [AnyChartMarker]Source
Shape type of ShapeMarker
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 MarkerDataPoint Source
Data point value of ShapeMarker
DataPoint Float | A specific data point in the dataset. Use a decimal value to interpolate between two points |
DataPointEvery | Draw a marker on each data point |
DataPointEveryN Int | Draw a marker on every n-th data point |
DataPointEveryNRange (Int, Int) Int |
|
DataPointXY (Float, Float) | draw a marker at a specific point (x,y). Specify the coordinates as floating point values, where 0:0 is the bottom left corner of the chart, 0.5:0.5 is the center of the chart, and 1:1 is the top right corner of the chart |
data ShapeMarker Source
Shape Marker
SM | |
|
data RangeMarkerType Source
RangeMarker
type
RangeMarkerHorizontal | horizontal range |
RangeMarkerVertical | vertical range |
data RangeMarker Source
Range Marker
RM | |
|
data FinancialMarker Source
Financial Marker, for line charts and vertical bar charts
FM | |
|
Default Values
These functions return default values for complex parameters, which can be used as starting points to construct parameters when creating charts.