Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
- 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
Synopsis
- 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
- type ChartFills = [Fill]
- data Fill = Fill FillKind FillType
- data FillKind
- = Solid Color
- | LinearGradient Angle [(Color, Offset)]
- | LinearStripes Angle [(Color, Width)]
- data FillType
- 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 = 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
- 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
- data ChartTitle = ChartTitle {}
- type ChartAxes = [Axis]
- data Axis = Axis {}
- data AxisType
- type AxisLabel = String
- type AxisPosition = Float
- type FontSize = Int
- data AxisRange = Range (Float, Float) (Maybe Float)
- data AxisStyle = Style {}
- data DrawingControl
- 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 a Source #
Chart monad which wraps a State
monad in turn
to keep track of the chart state and make it convenient
to update it
class ChartItem c where Source #
Typeclass abstracting all the fields in a chart
set :: c -> ChartM () Source #
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
Instances
class Num a => ChartDataEncodable a where Source #
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 -> ChartData Source #
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.
Instances
ChartDataEncodable Float Source # | |
Defined in Graphics.GChart.ChartItems.Data | |
ChartDataEncodable Int Source # | |
Defined in Graphics.GChart.ChartItems.Data |
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
Instances
Show BarWidth Source # | |
ChartItem BarChartWidthSpacing Source # | |
Defined in Graphics.GChart.ChartItems.Styles |
data BarGroupSpacing Source #
Bar and Group Spacing
Instances
Show BarGroupSpacing Source # | |
Defined in Graphics.GChart.Types showsPrec :: Int -> BarGroupSpacing -> ShowS # show :: BarGroupSpacing -> String # showList :: [BarGroupSpacing] -> ShowS # | |
ChartItem BarChartWidthSpacing Source # | |
Defined in Graphics.GChart.ChartItems.Styles |
Series Colors
data ChartColors Source #
Chart colors specified as a list of Color
values for each data point.
Instances
Show ChartColors Source # | |
Defined in Graphics.GChart.Types showsPrec :: Int -> ChartColors -> ShowS # show :: ChartColors -> String # showList :: [ChartColors] -> ShowS # | |
ChartItem ChartColors Source # | |
Defined in Graphics.GChart.ChartItems.Colors |
Chart Data
Chart data along with encoding. XY data for is encoded a pair of consecutive data sets
Simple [[Int]] | lets you specify integer values from 0-61, inclusive |
Text [[Float]] | supports floating point numbers from 0-100, inclusive |
Extended [[Int]] | lets you specify integer values from 0-4095, inclusive |
data ChartDataScales Source #
List of Data scaling values
Instances
Show ChartDataScales Source # | |
Defined in Graphics.GChart.Types showsPrec :: Int -> ChartDataScales -> ShowS # show :: ChartDataScales -> String # showList :: [ChartDataScales] -> ShowS # | |
ChartItem ChartDataScales Source # | |
Defined in Graphics.GChart.ChartItems.Data |
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
Instances
Show ChartLegend Source # | |
Defined in Graphics.GChart.Types showsPrec :: Int -> ChartLegend -> ShowS # show :: ChartLegend -> String # showList :: [ChartLegend] -> ShowS # | |
ChartItem ChartLegend Source # | |
Defined in Graphics.GChart.ChartItems.Labels |
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 |
Instances
Show LegendPosition Source # | |
Defined in Graphics.GChart.Types showsPrec :: Int -> LegendPosition -> ShowS # show :: LegendPosition -> String # showList :: [LegendPosition] -> ShowS # |
Solid, Gradient and Striped Fills
type ChartFills = [Fill] Source #
Chart fills, as a list of Fill
s
Constructor for a chart fill
Instances
Show Fill Source # | |
ChartItem ChartFills Source # | |
Defined in Graphics.GChart.ChartItems.Colors |
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
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
Instances
Show ChartLabels Source # | |
Defined in Graphics.GChart.Types showsPrec :: Int -> ChartLabels -> ShowS # show :: ChartLabels -> String # showList :: [ChartLabels] -> ShowS # | |
ChartItem ChartLabels Source # | |
Defined in Graphics.GChart.ChartItems.Labels |
Chart Label Data
data ChartLabelData Source #
Chart Label Data. Applies to QRCode
QRLabelData ErrorCorrectionLevel Int | Error Correction Level and Margin (as no. of rows) |
Instances
Show ChartLabelData Source # | |
Defined in Graphics.GChart.Types showsPrec :: Int -> ChartLabelData -> ShowS # show :: ChartLabelData -> String # showList :: [ChartLabelData] -> ShowS # | |
ChartItem ChartLabelData Source # | |
Defined in Graphics.GChart.ChartItems.Data |
data ErrorCorrectionLevel Source #
Error Correction Level for QR Code
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 |
Instances
Show ErrorCorrectionLevel Source # | |
Defined in Graphics.GChart.Types showsPrec :: Int -> ErrorCorrectionLevel -> ShowS # show :: ErrorCorrectionLevel -> String # showList :: [ErrorCorrectionLevel] -> ShowS # |
Line Styles
type ChartLineStyles = [LineStyle] Source #
Line Style. Applicable for line charts
LS | |
|
Instances
Show LineStyle Source # | |
ChartItem ChartLineStyles Source # | |
Defined in Graphics.GChart.ChartItems.Styles |
Line, Shape, Range and Financial Markers
data AnyChartMarker Source #
Data type to abstract over all kinds of ChartMarker
ChartMarker w => AnyChartMarker w |
Instances
Show AnyChartMarker Source # | |
Defined in Graphics.GChart.Types showsPrec :: Int -> AnyChartMarker -> ShowS # show :: AnyChartMarker -> String # showList :: [AnyChartMarker] -> ShowS # | |
ChartItem ChartMarkers Source # | |
Defined in Graphics.GChart.ChartItems.Styles | |
ChartMarker AnyChartMarker Source # | |
Defined in Graphics.GChart.Types |
class Show a => ChartMarker a where Source #
Typeclass to abstract over different chart markers
Nothing
encodeChartMarker :: a -> String Source #
Instances
ChartMarker AnyChartMarker Source # | |
Defined in Graphics.GChart.Types | |
ChartMarker LineFillMarker Source # | |
Defined in Graphics.GChart.ChartItems.Styles | |
ChartMarker LineMarker Source # | |
Defined in Graphics.GChart.ChartItems.Styles encodeChartMarker :: LineMarker -> String Source # | |
ChartMarker FinancialMarker Source # | |
Defined in Graphics.GChart.ChartItems.Styles | |
ChartMarker RangeMarker Source # | |
Defined in Graphics.GChart.ChartItems.Styles | |
ChartMarker ShapeMarker Source # | |
Defined in Graphics.GChart.ChartItems.Styles |
type ChartMarkers = [AnyChartMarker] Source #
data LineWhichPoints Source #
Which points in a series to use to draw the line.
PointsAll | Use all the points in the series. |
Points (Maybe Float, Maybe Float) | (start,end) indicating a specific range of points |
Instances
Show LineWhichPoints Source # | |
Defined in Graphics.GChart.Types showsPrec :: Int -> LineWhichPoints -> ShowS # show :: LineWhichPoints -> String # showList :: [LineWhichPoints] -> ShowS # |
data LineMarker Source #
Line Marker
LM | |
|
Instances
Show LineMarker Source # | |
Defined in Graphics.GChart.Types showsPrec :: Int -> LineMarker -> ShowS # show :: LineMarker -> String # showList :: [LineMarker] -> ShowS # | |
ChartMarker LineMarker Source # | |
Defined in Graphics.GChart.ChartItems.Styles encodeChartMarker :: LineMarker -> String Source # |
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 |
Instances
Show MarkerDataPoint Source # | |
Defined in Graphics.GChart.Types showsPrec :: Int -> MarkerDataPoint -> ShowS # show :: MarkerDataPoint -> String # showList :: [MarkerDataPoint] -> ShowS # |
data ShapeMarker Source #
Shape Marker
SM | |
|
Instances
Show ShapeMarker Source # | |
Defined in Graphics.GChart.Types showsPrec :: Int -> ShapeMarker -> ShowS # show :: ShapeMarker -> String # showList :: [ShapeMarker] -> ShowS # | |
ChartMarker ShapeMarker Source # | |
Defined in Graphics.GChart.ChartItems.Styles |
data RangeMarkerType Source #
RangeMarker
type
RangeMarkerHorizontal | horizontal range |
RangeMarkerVertical | vertical range |
Instances
Show RangeMarkerType Source # | |
Defined in Graphics.GChart.Types showsPrec :: Int -> RangeMarkerType -> ShowS # show :: RangeMarkerType -> String # showList :: [RangeMarkerType] -> ShowS # |
data RangeMarker Source #
Range Marker
RM | |
|
Instances
Show RangeMarker Source # | |
Defined in Graphics.GChart.Types showsPrec :: Int -> RangeMarker -> ShowS # show :: RangeMarker -> String # showList :: [RangeMarker] -> ShowS # | |
ChartMarker RangeMarker Source # | |
Defined in Graphics.GChart.ChartItems.Styles |
data FinancialMarker Source #
Financial Marker, for line charts and vertical bar charts
FM | |
|
Instances
Show FinancialMarker Source # | |
Defined in Graphics.GChart.Types showsPrec :: Int -> FinancialMarker -> ShowS # show :: FinancialMarker -> String # showList :: [FinancialMarker] -> ShowS # | |
ChartMarker FinancialMarker Source # | |
Defined in Graphics.GChart.ChartItems.Styles |
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 |
Instances
Show LineFillType Source # | |
Defined in Graphics.GChart.Types showsPrec :: Int -> LineFillType -> ShowS # show :: LineFillType -> String # showList :: [LineFillType] -> ShowS # |
data LineFillMarker Source #
Line Fill Marker
Instances
Show LineFillMarker Source # | |
Defined in Graphics.GChart.Types showsPrec :: Int -> LineFillMarker -> ShowS # show :: LineFillMarker -> String # showList :: [LineFillMarker] -> ShowS # | |
ChartMarker LineFillMarker Source # | |
Defined in Graphics.GChart.ChartItems.Styles |
Chart Margins
data ChartMargins Source #
Chart Margins. All margin values specified are the minimum margins around the plot area, in pixels.
ChartMargins | |
|
Instances
Show ChartMargins Source # | |
Defined in Graphics.GChart.Types showsPrec :: Int -> ChartMargins -> ShowS # show :: ChartMargins -> String # showList :: [ChartMargins] -> ShowS # | |
ChartItem ChartMargins Source # | |
Defined in Graphics.GChart.ChartItems.Styles |
QR code output encoding
data QREncoding Source #
QR Code Output Encoding
Instances
Show QREncoding Source # | |
Defined in Graphics.GChart.Types showsPrec :: Int -> QREncoding -> ShowS # show :: QREncoding -> String # showList :: [QREncoding] -> ShowS # | |
ChartItem QREncoding Source # | |
Defined in Graphics.GChart.ChartItems.Data |
Pie Chart Orientation
data PieChartOrientation Source #
Pie Chart Orientation. Applicable only to Pie Charts,
Instances
Show PieChartOrientation Source # | |
Defined in Graphics.GChart.Types showsPrec :: Int -> PieChartOrientation -> ShowS # show :: PieChartOrientation -> String # showList :: [PieChartOrientation] -> ShowS # | |
ChartItem PieChartOrientation Source # | |
Defined in Graphics.GChart.ChartItems.Styles |
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 | |
|
Instances
Show ChartTitle Source # | |
Defined in Graphics.GChart.Types showsPrec :: Int -> ChartTitle -> ShowS # show :: ChartTitle -> String # showList :: [ChartTitle] -> ShowS # | |
ChartItem ChartTitle Source # | |
Defined in Graphics.GChart.ChartItems.Labels |
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 = Float Source #
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.
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 |
Instances
Eq DrawingControl Source # | |
Defined in Graphics.GChart.Types (==) :: DrawingControl -> DrawingControl -> Bool # (/=) :: DrawingControl -> DrawingControl -> Bool # | |
Show DrawingControl Source # | |
Defined in Graphics.GChart.Types showsPrec :: Int -> DrawingControl -> ShowS # show :: DrawingControl -> String # showList :: [DrawingControl] -> ShowS # |
data AxisStyleAlignment Source #
AxisStyleLeft | Left aligned labels |
AxisStyleCenter | Centered labels |
AxisStyleRight | Right aligned labels |
Instances
Eq AxisStyleAlignment Source # | |
Defined in Graphics.GChart.Types (==) :: AxisStyleAlignment -> AxisStyleAlignment -> Bool # (/=) :: AxisStyleAlignment -> AxisStyleAlignment -> Bool # | |
Show AxisStyleAlignment Source # | |
Defined in Graphics.GChart.Types showsPrec :: Int -> AxisStyleAlignment -> ShowS # show :: AxisStyleAlignment -> String # showList :: [AxisStyleAlignment] -> ShowS # |
Default Values
These functions return default values for complex parameters, which can be used as starting points to construct parameters when creating charts.
defaultChart :: Chart Source #
Default value for a chart
defaultAxis :: Axis Source #
Default value for an axis
defaultGrid :: ChartGrid Source #
Default value for a chart grid
defaultSpacing :: BarGroupSpacing Source #
Default value for bar and group spacing in bar chart
defaultShapeMarker :: ShapeMarker Source #
Default value of a shape marker. Make sure you change the value of shapeDataSetIdx
defaultRangeMarker :: RangeMarker Source #
Default value of range marker
defaultFinancialMarker :: FinancialMarker Source #
Default value of a financial marker. Make sure you change the value of financeDataSetIdx
defaultLineStyle :: LineStyle Source #
Default value of a line style
defaultLineMarker :: LineMarker Source #
Default value of a line marker. Make sure you change the value of lineDataSetIdx
defaultQREncodingLabelData :: ChartLabelData Source #
Default chart label data for QR Encoding