Safe Haskell | None |
---|---|
Language | Haskell2010 |
Examples of chart construction.
Synopsis
- unitExample :: ChartSvg
- svgOptionsExample :: ChartSvg
- hudOptionsExample :: ChartSvg
- rectExample :: ChartSvg
- textExample :: ChartSvg
- glyphsExample :: ChartSvg
- lineExample :: ChartSvg
- barExample :: ChartSvg
- waveExample :: ChartSvg
- lglyphExample :: ChartSvg
- glinesExample :: ChartSvg
- compoundExample :: ChartSvg
- textLocalExample :: ChartSvg
- labelExample :: ChartSvg
- legendExample :: ChartSvg
- surfaceExample :: ChartSvg
- rosenbrock :: Double -> Double -> Point Double -> (Double, Point Double)
- arcExample :: ChartSvg
- arcFlagsExample :: ChartSvg
- ellipseExample :: ChartSvg
- quadExample :: ChartSvg
- cubicExample :: ChartSvg
- pathExample :: ChartSvg
- vennExample :: ChartSvg
- arrowExample :: ChartSvg
- writeAllExamples :: IO ()
Documentation
unitExample :: ChartSvg Source #
unit example
svgOptionsExample :: ChartSvg Source #
SvgOptions
example.
hudOptionsExample :: ChartSvg Source #
HudOptions
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.
legendExample :: ChartSvg Source #
legend test
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
arcFlagsExample :: ChartSvg Source #
Reproduction of the flag explanation chart in https://developer.mozilla.org/en-US/docs/Web/SVG/Tutorial/Paths
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.