concept chart in category haskell

This is an excerpt from Manning's book Haskell in Depth.
Figure 3.2. Stock quotes charts for an imaginary company
![]()
Usage: stockquotes FILE [-n|--name ARG] [-c|--chart] [--html FILE] [-s|--silent] Stock quotes data processing Available options: FILE CSV file name -n,--name ARG company name -c,--chart generate chart --html FILE generate HTML report -s,--silent don't print statistics -h,--help Show this help text
Unfortunately, Haskell is not the best language for presenting data in visual form. Such languages as Python and R provide much better infrastructure and tooling. Nevertheless, we can still draw 2D charts and plots in Haskell. In this project, we use the
Chartpackage by Tim Docker for that. It’s a good example of a package built on top of other sophisticated Haskell packages, so it’s instructive to discuss its ideas and implementation.The
Chartpackage allows to describe a chart we want to plot. A chart in terms of this package is a deeply nested data structure. We construct elements we are interested in (such as layouts, axis, legends, data points) one by one leaving all others with their default values. This package supports line plots, bar plots, pie charts, and even candlestick plots out of box. One difficulty about this package is that it uses lenses to access elements of the chart structure. This approach is very powerful. In this chapter we’ll see how to use it without deep understanding what lenses are. For basic charts with default parameters, it’s possible to avoid using lenses alltogether as there are simple wrappers. Unfortunately, this is not our case.The
Chartpackage requires a backend for generating image files. We’ll useChart-diagramsto generate SVG files because it is the simplest one. It’s also possible to generate PNG or JPG images aw well as other graphical formats. Unfortunately, this would require a lot of system dependencies that may be hard to install correctly on Windows. There should be no problems with SVG in any operating system.The
Chartpackage has a wiki page on GitHub with several examples on how to use it to plot various kinds of graphs.