Open prefect4742 opened 7 years ago
I "fixed" this by extending XAxisRenderer and overriding computeAxisValues() to always use my granularity, multiplying the granularity by 2 until the number of gridlines went below a threshold.
A feaure request could be to allow a formatter-like construct for computing the axis values, leaving it up to the library user to decide. Bonus if it also allowed different formats for differn lines - I use thicker lines for midnight than the hours in-between, by adding a BarChart for the midnight lines. :)
Hi @prefect4742, I'm afraid that I'm facing a similar problem like you. In my case, I have a chart with X axis representing timestamps (properly formatted). I would like to show specific labels and their corresponding gridlines, for example, the labels which are located at midnight of every day.
Did you manage to solve the problem? Could you provide some code to illustrate your solution? Thanks in advance :)
I'm trying to make a chart where the data is measurement over days/weeks, and I'm having problems getting the x-axis gridlines stay where I want them to.
I don't have regular data so it't not guaranteed that I have data points on the exact points where "midnight" is for each data, so I faked som data that's outside of the visible y limits. But still the gridlines move when I zoom. How can I fix the gridlines in place so that they stay even when I zoom in/out? For visibility, it's nice that there are lines appearing between the datelines when I zoom in.
I've traced the problem to the rounding of the granularity (I think) in AxisRenderer.computeAxisValues. The easy solution would be to patch the library myself but I thought I'd ask first if there is a way to configure this, as using the stock library as-is is always preferred :)