haskell-chart icon indicating copy to clipboard operation
haskell-chart copied to clipboard

Export more from Graphics.Rendering.Chart.Axis.LocalTime

Open paul-r-ml opened this issue 10 years ago • 5 comments

Hi Tim,

I am trying to customize the granularity of the time axis data for some charts. To do so, I am basically making a custom copy of Graphics.Rendering.Chart.Axis.LocalTime.autoTimeAxis. Is that the right way to go ? In this case, it would help to export everything that this function uses, in particular millisXXX, seconds, minuteSeq and hours.

Thank you very much, I'm still enjoying Chart a lot !

paul-r-ml avatar Feb 12 '15 14:02 paul-r-ml

Also, I wonder how Chart decides how often labels are actually displayed below the axis. It does not seem to be something the AxisFn function decides, but rather something decided downstream. Sometime it will print every labels, sometime 1/2, sometime 1/5. Most of the time, things are just fine (congrats for this magic !). But sometime, it can be annoying, for exemple when it displays hours 1/5 (00:00 05:00 10:00 ... 20:00 01:00 06:00 ...) . Choosing a more conventional set like 1/3 or 1/6 or 1/12 (they all divide 24) would be more practical.

paul-r-ml avatar Feb 12 '15 16:02 paul-r-ml

Also, the *Seq variants for TimeSeq generators are very handy. Please consider including (and exporting) them for minutes, hours, and days.

I realize that I am asking a lot ! I can probably make these changes myself and come back with a pull request. I must just sort out how to use a localy modified Chart library in my project with cabal sandbox. If you have a tip or a page to help me get started, please share.

Cheers.

paul-r-ml avatar Feb 12 '15 16:02 paul-r-ml

I'd prefer not to expose the internals of Graphics.Rendering.Chart.Axis.LocalTime, as that just increases the size of the API which I need to try to preserve to keep backwards compatibility. However, I guess if it's essential, I could move some key stand along functions into a separate helpers module. Can you give some concrete examples re how you want to customize the granularity? If your requirements are general enough, it might be best to just add them to this module.

Also, I wonder how Chart decides how often labels are actually displayed below the axis.

The key function is avoidOverlaps, which leaves out overlaps if the font size is too big to display all the labels:

https://github.com/timbod7/haskell-chart/blob/master/chart/Graphics/Rendering/Chart/Axis/Types.hs#L263

timbod7 avatar Feb 16 '15 00:02 timbod7

Having said the above, I can see that the TimeSeq stuff is general enough that it doesn't belong buried in the Axis logic.

I'd certainly be happy to see this move out into a separate module (still within the chart library), perhaps Data.Time.Extended, following the pattern described here:

http://jaspervdj.be/posts/2015-01-20-haskell-design-patterns-extended-modules.html.

I will do this when I have a chance, though I'm not sure when that will be :-) I'm happy to accept a pull request of course.

timbod7 avatar Feb 16 '15 00:02 timbod7

Hopefully I will be able to come up with this pull request in the course of April. Best regards,

paul-r-ml avatar Mar 13 '15 14:03 paul-r-ml