[Chart] Should we fix the layout API?

Tim Docker tim at dockerz.net
Tue Oct 1 14:57:18 BST 2013


Hi,

The most recent release (1.0) changed the API of the library quite 
substantially: mostly due to the use of lens, but also due to some of 
Jan's changes.

Before we close the door on API breaking changes, I'd like to consider 
one more. The Layout1 type in the library combines a plot area with 
axes, a title, and a legend [1]. It is parameterized by the types of the 
x and y axes. Whilst there is only a single y type, there are actually 
two potentially independent y axes, one on the left and one on the right 
hand side. You choose which axis you are plotting against by wrapping 
the plots in either Left or Right. There's some additional ugliness 
(_layout1_axes_control), to tie the two axes together if you are only 
plotting a single y range but want axes drawn on both sides of the chart.

I had intended to clean this up for some time, but hadn't found time to 
do so. Jan kindly had a go in the last week or so of GSOC. The results 
can be seen here [2]. In essence, the Layout1 type has been split into a 
simpler Layout type for where you only have a single y axis [3], and a 
more flexible LayoutLR type with independent types for the left and 
right axes [4].

I think this is a worthwhile change, but it does affect the API in minor 
ways for most charts. I'd really appreciate some feedback on this - 
Please respond with +1/0/-1 if it affects you.

Thanks,

Tim


[1] 
https://github.com/timbod7/haskell-chart/blob/master/chart/Graphics/Rendering/Chart/Layout.hs#L120
[2] https://github.com/timbod7/haskell-chart/pull/10
[3] 
https://github.com/jbracker/haskell-chart/blob/ed8b43075a0ac3a3e8c026140881b62142d63a3f/chart/Graphics/Rendering/Chart/Layout.hs#L148
[4] 
https://github.com/jbracker/haskell-chart/blob/ed8b43075a0ac3a3e8c026140881b62142d63a3f/chart/Graphics/Rendering/Chart/Layout.hs#L205



More information about the Chart mailing list