[Chart] [GSoC 2013] Progress - Porting Charts to Diagrams

Jan Bracker jan.bracker at googlemail.com
Mon Jun 10 12:04:03 BST 2013


Hi everybody,

this is a general progress report of my work so far. Tim was so nice to
move some stuff around so all cairo specific code is in one module. You can
find this work in the branch "abstract-drawing":
https://github.com/timbod7/haskell-chart/tree/abstract-drawing

I pulled that work into my fork:
https://github.com/jbracker/haskell-chart/tree/abstract-drawing

... and from there I made the following changes:

- I renamed all types to remove the "Cairo" prefix.
- I added custom Chart types for all reused cairo types.
- I also created a Backend.Cairo module and moved the cairo specific stuff
there (while doing so I ran into some cyclic dependencies and recreated the
Types module).

Based on that I started to design a interface for backends. You can see my
try on this in the comments of this file:
https://github.com/jbracker/haskell-chart/blob/a02f054b1697f7f015f10b7c409bd9a0a2fb8cbe/chart/Graphics/Rendering/Chart/Types.hs

I think the backend API reflects all functions that are used by Charts. It
should also be easy to implement it with cairo as a backend:

data CairoBackend
  = CairoBackendPDF
  | CairoBackendPNG
  ...

instance ChartBackend CairoBackend where
  type ChartRenderM CairoBackend = Cairo.Render
  type ChartOutput CairoBackend = Renderable a -> Int -> Int -> OutputType
-> FilePath -> IO ()

For this to work the CRender monad has to be generalized so it can take an
inner backend-specific monad as first type parameter. While writing this I
looked at how Diagrams backend mechanism works. I would like to hear some
thoughts on what I did (and in general on my changes so far). I don't
really like that there are so many functions in the backend class, but I
can't see how to make it smaller without making radical changes to the way
that Charts works right now (which Tim and I decided against).

Jan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://projects.haskell.org/pipermail/chart/attachments/20130610/7e0ddb68/attachment.htm>


More information about the Chart mailing list