Safe Haskell | Safe-Inferred |
---|
- Typeclasses
- Chart
- Chart Parameters
- Bar Width and Spacing
- Series Colors
- Chart Data
- Chart Legend Text and Style
- Solid, Gradient and Striped Fills
- Grid Lines
- Pie chart labels, Google-o-meter label (TODO: QR code data, Formula TeX data)
- Chart Label Data
- Line Styles
- Line, Shape, Range and Financial Markers
- Line Fills
- Chart Margins
- QR code output encoding
- Pie Chart Orientation
- Chart Size
- Chart Type
- Chart Title and Style
- Visible Axis Axis styles and labels
- Default Values
This module contains the Haskell data model for the Google Chart API.
More details about the API and parameters can be found at : http://code.google.com/apis/chart/image_charts.html
Some chart types are not supported yet:
- Box Charts http://code.google.com/apis/chart/docs/gallery/compound_charts.html#box_charts
- Candlestick Charts http://code.google.com/apis/chart/docs/gallery/compound_charts.html#candlestick_charts
- Compound Charts http://code.google.com/apis/chart/docs/gallery/compound_charts.html
- Dynamic Icons http://code.google.com/apis/chart/docs/gallery/dynamic_icons.html
- Map Charts http://code.google.com/apis/chart/docs/gallery/map_charts.html
Some parameters are not supported yet:
- Text and Data Value Markers http://code.google.com/apis/chart/docs/chart_params.html#gcharts_data_point_labels
- Shape offset feature for shape markers http://code.google.com/apis/chart/docs/chart_params.html#gcharts_shape_markers
- Bug in
BarChartWidthSpacing
. Not fully accurate - Modfy FillType to conform to new API http://code.google.com/apis/chart/docs/chart_params.html#gcharts_gradient_fills
- 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
- Vertical slice filling http://code.google.com/apis/chart/docs/chart_params.html#gcharts_line_fills
- Bar chart zero line http://code.google.com/apis/chart/docs/gallery/bar_charts.html#chp
- type ChartM a = State Chart a
- class ChartItem c where
- class Num a => ChartDataEncodable a where
- addEncodedChartData :: [a] -> ChartData -> ChartData
- data Chart = Chart {
- chartSize :: Maybe ChartSize
- chartType :: ChartType
- chartData :: Maybe ChartData
- chartDataScales :: Maybe ChartDataScales
- 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
- pieChartOrientation :: Maybe PieChartOrientation
- chartLineStyles :: Maybe ChartLineStyles
- qrEncoding :: Maybe QREncoding
- chartLabelData :: Maybe ChartLabelData
- type BarChartWidthSpacing = (Maybe BarWidth, Maybe BarGroupSpacing)
- data BarWidth
- data BarGroupSpacing
- data ChartColors = ChartColors [Color]
- type Color = String
- data ChartData
- data ChartDataScales = CDS [DataScale]
- type DataScale = (Float, Float)
- data ChartLegend = Legend [String] (Maybe LegendPosition)
- data LegendPosition
- = LegendBottom
- | LegendTop
- | LegendVBottom
- | LegendVTop
- | LegendRight
- | LegendLeft
- 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 ChartGrid = ChartGrid {}
- data ChartLabels = ChartLabels [String]
- data ChartLabelData = QRLabelData ErrorCorrectionLevel Int
- data ErrorCorrectionLevel
- type ChartLineStyles = [LineStyle]
- data LineStyle = LS {}
- data AnyChartMarker = forall w . ChartMarker w => AnyChartMarker w
- class Show a => ChartMarker a where
- encodeChartMarker :: a -> String
- type ChartMarkers = [AnyChartMarker]
- data LineWhichPoints
- data LineMarker = LM {}
- data ShapeType
- 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 {}
- data LineFillType
- data LineFillMarker = LineFillMarker LineFillType Color
- data ChartMargins = ChartMargins {
- leftMargin :: Int
- rightMargin :: Int
- topMargin :: Int
- bottomMargin :: Int
- legendMargins :: Maybe (Int, Int)
- data QREncoding
- data PieChartOrientation = PCO Float
- data ChartSize = Size Int Int
- data ChartType
- = Line
- | Sparklines
- | LineXY
- | BarHorizontalStacked
- | BarVerticalStacked
- | BarHorizontalGrouped
- | BarVerticalGrouped
- | Pie
- | Pie3D
- | PieConcentric
- | Venn
- | ScatterPlot
- | Radar
- | RadarCurvedLines
- | GoogleOMeter
- | Formula
- | QRCode
- data ChartTitle = ChartTitle {}
- 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
- defaultChart :: Chart
- defaultAxis :: Axis
- defaultGrid :: ChartGrid
- defaultSpacing :: BarGroupSpacing
- defaultShapeMarker :: ShapeMarker
- defaultRangeMarker :: RangeMarker
- defaultFinancialMarker :: FinancialMarker
- defaultLineStyle :: LineStyle
- defaultLineMarker :: LineMarker
- defaultQREncodingLabelData :: ChartLabelData
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
sets the item in a chart
encode :: c -> [(String, String)]Source
encode the field into a list string params that can then be converted into a query string URL
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 type to represent the chart
Data type for the chart
Chart Parameters
Some of these parameters behave differently depending on the chart type;
More details : http://code.google.com/apis/chart/docs/chart_params.html
Bar Width and Spacing
type BarChartWidthSpacing = (Maybe BarWidth, Maybe BarGroupSpacing)Source
Bar Width and Spacing.
Bar Width
data BarGroupSpacing Source
Bar and Group Spacing
Series Colors
data ChartColors Source
Chart colors specified as a list of Color
values for each data point.
Chart Data
Chart data along with encoding. XY data for is encoded a pair of consecutive data sets
data ChartDataScales Source
List of Data scaling values
type DataScale = (Float, Float)Source
Data scaling expressed as (series_min
,series_max
). Applies to text encoding only
Chart Legend Text and Style
data ChartLegend Source
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 |
Solid, Gradient and Striped Fills
type ChartFills = [Fill]Source
Chart fills, as a list of Fill
s
Specifies the kind of fill
Solid Color | Solid Fill |
LinearGradient Angle [(Color, Offset)] | Linear Gradient |
LinearStripes Angle [(Color, Width)] | Linear Stripes |
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
Angle of the gradient between 0 (horizontal) and 90
(vertical). Applicable to LinearGradient
and LinearStripes
Grid Lines
Grid Lines for Chart
Pie chart labels, Google-o-meter label (TODO: QR code data, Formula TeX data)
data ChartLabels Source
Labels for Pie Chart and Google-o-meter. Specify a list with a single label for Google-o-meter
Chart Label Data
data ChartLabelData Source
Chart Label Data. Applies to QRCode
QRLabelData ErrorCorrectionLevel Int | Error Correction Level and Margin (as no. of rows) |
data ErrorCorrectionLevel Source
Error Correction Level for QR Code
Line Styles
type ChartLineStyles = [LineStyle]Source
Line Style. Applicable for line charts
LS | |
|
Line, 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
data LineWhichPoints Source
Which points in a series to use to draw the line.
data LineMarker Source
Line Marker
LM | |
|
Shape type of ShapeMarker
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 |
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 | |
|
Line Fills
data LineFillType Source
Line fill type for LineFill
LineFillFrom Int | Line fill starting from a start index |
LineFillBetween Int Int | Line fill between a start index and end index |
data LineFillMarker Source
Line Fill Marker
Chart Margins
data ChartMargins Source
Chart Margins. All margin values specified are the minimum margins around the plot area, in pixels.
ChartMargins | |
|
QR code output encoding
data QREncoding Source
QR Code Output Encoding
Pie Chart Orientation
data PieChartOrientation Source
Pie Chart Orientation. Applicable only to Pie Charts,
Chart Size
Size of the chart. width and height specified in pixels
Chart Type
Chart type
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 |
RadarCurvedLines | Radar Chart, connects points with curved lines |
GoogleOMeter | Google-o-meter |
Formula | Formula Chart |
QRCode | QR Codes |
Chart Title and Style
data ChartTitle Source
Title of the chart
ChartTitle | |
|
Visible Axis Axis styles and labels
Visible axis
Axis | |
|
Type of Axis
AxisBottom | Bottom x-axis |
AxisTop | Top x-axis |
AxisLeft | Left y-axis |
AxisRight | Right y-axis |
type AxisPosition = FloatSource
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
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 |
Default Values
These functions return default values for complex parameters, which can be used as starting points to construct parameters when creating charts.
Default value for a chart
Default value for an axis
defaultGrid :: ChartGridSource
Default value for a chart grid
defaultSpacing :: BarGroupSpacingSource
Default value for bar and group spacing in bar chart
defaultShapeMarker :: ShapeMarkerSource
Default value of a shape marker. Make sure you change the value of shapeDataSetIdx
defaultRangeMarker :: RangeMarkerSource
Default value of range marker
defaultFinancialMarker :: FinancialMarkerSource
Default value of a financial marker. Make sure you change the value of financeDataSetIdx
defaultLineStyle :: LineStyleSource
Default value of a line style
defaultLineMarker :: LineMarkerSource
Default value of a line marker. Make sure you change the value of lineDataSetIdx
defaultQREncodingLabelData :: ChartLabelDataSource
Default chart label data for QR Encoding