module Graphics.GChart (
module Graphics.GChart.Types,
solid ,
legend ,
legendWithPosition ,
makeAxis ,
makeGrid ,
simple ,
text ,
extended ,
automatic ,
automaticWithSpacing ,
barwidth ,
barwidthspacing ,
relative ,
makeShapeMarker ,
makeRangeMarker ,
makeFinancialMarker ,
makeLineStyle ,
setChartSize ,
setChartType ,
setChartTitle ,
setChartTitleWithColor ,
setChartTitleWithColorAndFontSize,
setDataEncoding ,
addChartData ,
addChartDataXY ,
setColors ,
addColor ,
addFill ,
setLegend ,
addAxis ,
setGrid ,
addShapeMarker ,
addRangeMarker ,
addFinancialMarker ,
setLabels ,
setBarWidthSpacing ,
setPieChartOrientation ,
addLineStyle ,
getChartData,
getChartUrl,
convertToUrl
) where
import Graphics.GChart.Types
import Graphics.GChart.ChartItems
import Graphics.GChart.DataEncoding
import Data.List
solid :: Color -> FillType -> Fill
solid color filltype = Fill (Solid color) filltype
legend :: [String] -> ChartLegend
legend labels = Legend labels Nothing
legendWithPosition :: [String] -> LegendPosition -> ChartLegend
legendWithPosition labels position = Legend labels (Just position)
makeAxis :: Axis
makeAxis = defaultAxis
makeGrid :: ChartGrid
makeGrid = defaultGrid
simple :: ChartData
simple = Simple []
text :: ChartData
text = Text []
extended :: ChartData
extended = Extended []
automatic :: BarChartWidthSpacing
automatic = (Just Automatic,Nothing)
automaticWithSpacing :: Int -> Int -> BarChartWidthSpacing
automaticWithSpacing b g= (Just Automatic, Just (Fixed (b,g)))
barwidth :: Int -> BarChartWidthSpacing
barwidth n = (Just (BarWidth n), Nothing)
barwidthspacing :: Int -> Int -> Int -> BarChartWidthSpacing
barwidthspacing bw b g = (Just (BarWidth bw), Just (Fixed (b,g)))
relative :: Float -> Float -> BarChartWidthSpacing
relative b g = (Nothing, Just (Relative (b,g)))
makeShapeMarker :: ShapeMarker
makeShapeMarker = defaultShapeMarker
makeRangeMarker :: RangeMarker
makeRangeMarker = defaultRangeMarker
makeFinancialMarker :: FinancialMarker
makeFinancialMarker = defaultFinancialMarker
makeLineStyle :: LineStyle
makeLineStyle = defaultLineStyle
setChartSize :: Int -> Int -> ChartM ()
setChartSize w h = set (Size w h)
setChartType :: ChartType -> ChartM ()
setChartType = set
setChartTitle :: String -> ChartM ()
setChartTitle title = set $ ChartTitle title Nothing Nothing
setChartTitleWithColor :: String -> Color -> ChartM()
setChartTitleWithColor title color = set $ ChartTitle title (Just color) Nothing
setChartTitleWithColorAndFontSize :: String -> Color -> FontSize -> ChartM ()
setChartTitleWithColorAndFontSize title color fontsize =
set $ ChartTitle title (Just color) (Just fontsize)
setDataEncoding :: ChartData -> ChartM ()
setDataEncoding = set
addChartData :: ChartDataEncodable a => [a] -> ChartM ()
addChartData = addDataToChart
addChartDataXY :: ChartDataEncodable a => [(a,a)] -> ChartM ()
addChartDataXY series = do addDataToChart xseries
addDataToChart yseries
where xseries = map fst series
yseries = map snd series
setColors :: [Color] -> ChartM ()
setColors = set . ChartColors
addColor :: Color -> ChartM()
addColor = addColorToChart
addFill :: Fill -> ChartM ()
addFill = addFillToChart
setLegend :: ChartLegend -> ChartM ()
setLegend = set
addAxis :: Axis -> ChartM ()
addAxis = addAxisToChart
setGrid :: ChartGrid -> ChartM ()
setGrid = set
addShapeMarker :: ShapeMarker -> ChartM ()
addShapeMarker marker | (shapeDataSetIdx marker) > 1 = addMarker marker
| otherwise = do idx <- getDataSetIdx
let newmarker = marker { shapeDataSetIdx = idx }
addMarker marker
addRangeMarker :: RangeMarker -> ChartM ()
addRangeMarker marker = addMarker marker
addFinancialMarker :: FinancialMarker -> ChartM ()
addFinancialMarker marker | (financeDataSetIdx marker) > 1 = addMarker marker
| otherwise = do idx <- getDataSetIdx
let newmarker = marker { financeDataSetIdx = idx }
addMarker marker
setLabels :: [String] -> ChartM ()
setLabels = set . ChartLabels
setBarWidthSpacing :: BarChartWidthSpacing -> ChartM ()
setBarWidthSpacing = set
setPieChartOrientation :: Float -> ChartM ()
setPieChartOrientation = set . PCO
addLineStyle :: LineStyle -> ChartM()
addLineStyle = addLineStyleToChart
getChartData :: ChartM () -> Chart
getChartData = getChartDataFromChartM
getChartUrl :: ChartM () -> String
getChartUrl = convertToUrl . getChartData
convertToUrl :: Chart -> String
convertToUrl chart = baseURL ++ intercalate "&" urlparams where
baseURL = "http://chart.apis.google.com/chart?"
urlparams = [urlEnc a ++ "=" ++ urlEnc b | (a,b) <- getParams chart]