chart-svg-0.2.2: Charting library targetting SVGs.
Safe HaskellNone
LanguageHaskell2010

Chart.Examples

Description

Examples of chart construction.

Synopsis

Documentation

unitExample :: ChartSvg Source #

unit example

rectExample :: ChartSvg Source #

rect example

textExample :: ChartSvg Source #

text example

glyphsExample :: ChartSvg Source #

glyphs example

lineExample :: ChartSvg Source #

line example

Example in cabal file

This lineExample provides a bit more detail for testing huds.

Simplified example:

>>> :set -XOverloadedLabels
>>> import Chart
>>> let xs = fmap (fmap (uncurry Point)) [[(0.0, 1.0), (1.0, 1.0), (2.0, 5.0)], [(0.0, 0.0), (3.2, 3.0)], [(0.5, 4.0), (0.5, 0)]] :: [[Point Double]]
>>> xs
[[Point 0.0 1.0,Point 1.0 1.0,Point 2.0 5.0],[Point 0.0 0.0,Point 3.2 3.0],[Point 0.5 4.0,Point 0.5 0.0]]
>>> let anns = zipWith (\w c -> LineA (defaultLineStyle & #width .~ w & #color .~ c)) [0.015, 0.03, 0.01] palette1_
>>> anns
[LineA (LineStyle {width = 1.5e-2, color = Colour 0.69 0.35 0.16 1.00, linecap = Nothing, linejoin = Nothing, dasharray = Nothing, dashoffset = Nothing}),LineA (LineStyle {width = 3.0e-2, color = Colour 0.65 0.81 0.89 1.00, linecap = Nothing, linejoin = Nothing, dasharray = Nothing, dashoffset = Nothing}),LineA (LineStyle {width = 1.0e-2, color = Colour 0.12 0.47 0.71 1.00, linecap = Nothing, linejoin = Nothing, dasharray = Nothing, dashoffset = Nothing})]
>>> let lineExample = mempty & (#chartList .~ zipWith Chart anns (fmap (fmap PointXY) xs)) & #hudOptions .~ defaultHudOptions & #svgOptions .~ defaultSvgOptions :: ChartSvg
>>> :t lineExample
lineExample :: ChartSvg
writeChartSvg "other/line.svg" lineExample

barExample :: ChartSvg Source #

Bar chart example.

waveExample :: ChartSvg Source #

wave example

lglyphExample :: ChartSvg Source #

Labelled Glyphs

glinesExample :: ChartSvg Source #

Glyph + Lines

compoundExample :: ChartSvg Source #

mappend of lglyph and glines examples

textLocalExample :: ChartSvg Source #

A reminder that Text scale is at representation level, and so doesn't scale compared with other chart elements, such as a rectangle.

labelExample :: ChartSvg Source #

label example.

surfaceExample :: ChartSvg Source #

The common way to create a surface chart is usually a grid over a function.

rosenbrock :: Double -> Double -> Point Double -> (Double, Point Double) Source #

function for testing

f(x,y) = (a-x)^2 + b * (y - x^2)^2
       = a^2 - 2ax + x^2 + b * y^2 - b * 2 * y * x^2 + b * x ^ 4
f'x = -2a + 2 * x - b * 4 * y * x + 4 * b * x ^ 3
f'y = 2 * b * y - 2 * b * x^2
f a b (Point x y) = (a^2 - 2ax + x^2 + b * y^2 - b * 2 * y * x^2 + b * x^4, Point (-2a + 2 * x - b * 4 * y * x + 4 * b * x ^ 3), 2 * b * y - 2 * b * x^2)

arcExample :: ChartSvg Source #

arc example

ellipseExample :: ChartSvg Source #

ellipse example

(ArcPosition (Point 1 0) (Point 0 1) (ArcInfo (Point 1.5 1) 0 True True))

quadExample :: ChartSvg Source #

quad example

cubicExample :: ChartSvg Source #

cubic example

pathExample :: ChartSvg Source #

Compound path example.

vennExample :: ChartSvg Source #

venn diagram

arrowExample :: ChartSvg Source #

arrow example

Which happens to be the gradient of the surface example.

writeAllExamples :: IO () Source #

Run this to refresh haddock example SVGs.