[GSoC 2013] Porting Charts to Diagrams - Final Report

330 views
Skip to first unread message

Jan Bracker

unread,
Sep 26, 2013, 6:08:27 AM9/26/13
to Diagrams Disscussion List, Charts Mailing List, haskel...@googlegroups.com
Hello everybody,

the Google Summer of Code 2013 is over! My project to port the charts [0] library to use diagrams [1] as an alternative to cairo [2] was a full success.

The project goal [3,4] was to remove cairo as a dependency and replace it with a open backend API so different technologies can be used to render charts. This was mainly necessary, because cairo is hard to install on platforms like windows or mac. Aside of that it also makes charts more flexible and opens the doors for renderings charts in different contexts.

We were successful. The cairo rendering code was completely removed from the chart library and replaced by a drawing API [5] that is backend independent. The cairo rendering backend, of course, is still there and now provided as the separate package Chart-cairo [6]. In addition we implemented a second backend based on the diagrams library. It is provided in Chart-diagrams [7].

To give some more detail on the development: The backend API is now based on a deep embedding of all drawing commands in the ChartBackend monad. The sequence of drawings commands resulting from this is then interpreted by a implementing backend. We use the operational package [9] to implement the deep embedding. Implementing the cairo backend was straightforward, because the backend API was developed with the cairo API in mind. Implementing the diagrams backend was some more work. Drawing on its own is not a problem but calculating text metrics is, because it requires to access the systems font rendering capabilities most of the time. Diagrams does not offer this access for several reasons (missing backend support, unclear how API would look, etc.). You can look at the diagrams-discuss mailing list for further information on this topic. We used the SVGFonts [10] library to render fonts, because of these issues. It is independent of the used backend and uses the SVGFonts format to render fonts and calculate their metrics. Like this fonts can be preloaded and metrics can be calculated on the fly. The only downside of this approach is that its performance is not to good, because we render each glyph as a path and because the math done in diagrams is not to fast either. At least when rendering to SVG files we could improve the performance by embedding fonts into the produced SVG and by that saving to insert each glyph as a path. The API to access this is not yet on hackage but the new version will be released soon. You can look at the GitHub repository [11] if you want to access it. Along with this development I also had the change to tackle some bugs and improve the diagrams-svg [12] and SVGFonts [10] code.

Everybody who is interested in the details of the development process and see every bit of what was done can check the chart or diagrams mailing list. Both contain the progress reports of the project [8].

So have a look at charts [0] and see what it can do. We also have a nice little tutorial on how to use the new backends [13].

Greets
Jan

Daniel Santa Cruz

unread,
Sep 26, 2013, 10:22:24 AM9/26/13
to haskel...@googlegroups.com, jan.b...@googlemail.com
Awesome work, Jan. I'm looking forward to playing around with the new libs!

As a side note, what did you use to generate your email? Did you manage all the footnotes by hand?

Daniel

Jan Bracker

unread,
Sep 26, 2013, 12:47:21 PM9/26/13
to haskel...@haskell.org
Hello everybody,

I am sorry to send this a second time. Someone hinted out that I would not reach everybody on the mailing list through the Google Groups address. I should have looked a bit more thoroughly.

The Google Summer of Code 2013 is over! My project to port the charts [0] library to use diagrams [1] as an alternative to cairo [2] was a full success.

Heinrich Apfelmus

unread,
Sep 28, 2013, 3:07:04 PM9/28/13
to haskel...@haskell.org
Jan Bracker wrote:
> Hello everybody,
>
> I am sorry to send this a second time. Someone hinted out that I would not
> reach everybody on the mailing list through the Google Groups address. I
> should have looked a bit more thoroughly.
>
> The Google Summer of Code 2013 is over! My project to port the charts [0]
> library to use diagrams [1] as an alternative to cairo [2] was a full
> success.
>
> [..]
Congratulations! I think the library looks great and I will consider
using it for my next plot.

Is it possible to change fonts? I have found that fonts (and shadows)
have a huge impact on the "wow"-factor of a plot. In fact, I could not
help but ask a speaker during a talk what font he used for a particular
plot... it just looked great!


Best regards,
Heinrich Apfelmus

--
http://apfelmus.nfshost.com

_______________________________________________
Haskell-Cafe mailing list
Haskel...@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Jan Bracker

unread,
Sep 28, 2013, 4:38:10 PM9/28/13
to Heinrich Apfelmus, haskel...@haskell.org
Is it possible to change fonts? I have found that fonts (and shadows) have a huge impact on the "wow"-factor of a plot. In fact, I could not help but ask a speaker during a talk what font he used for a particular plot... it just looked great!

I think all charts support setting a custom font style [0]. But: It depends on the backend which fonts you can actually use. Some defaults are always supported [1]. I suppose the cairo backend will load all fonts installed in the system if required, but the diagrams backend only delivers the defaults. For other or custom fonts in diagrams you need a SVG font version of the font and pass it into the backend [2]. Shadows are not supported.

Best regards,
Jan

Reply all
Reply to author
Forward
0 new messages