Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Time-based x Axis is missing context #329

Open
rbu opened this Issue · 4 comments

2 participants

Robert Buchholz David Chester
Robert Buchholz

The default formatter for a time-based x axis renders the time within the current order of magnitude, i.e. "Jan", "Feb". However, there is no context that signifies (in this example) the year. The same is true for lower orders of magnitue, e.g. days are missing month and year.
As it makes no sense to display this information every time, this cannot be solved by custom formatters.

Rickshaw should support formatters to display the context in the first tick only and drop it in later ticks, OR to display the context in a second row.

        |                |            ......                 |
     Jan 2013            Feb          ......              Jan 2014


OR

        |                |            ......                 |                 |
       Jan             Feb            ......                Jan               Feb
                           2013                                    2014

I'm happy to help with a pull request, but I'd like to get input on how this could be done first.

Robert Buchholz

One idea to do this:

  • the axis object guarantees the formatter execution order from left to right
  • it hands in a context object to the next formatter invocation that is returned by the previous invocation

A formatter then could:

  • check if the context is undefined (first invocation, render year, etc)
  • return the last rendered year in a context
  • on every invocation, check that the current year is the last rendered year, otherwise render a year and return changed context object
David Chester
Owner

I agree this is a good problem to solve, and I generally like this direction.

Rather than passing along previous contexts to each next invocation, can we make it simpler and more flexible by just passing the whole list of ticks along with the current index?

Robert Buchholz

That should work. Label formatter could then determine that it is the first tick or that the month/year context changed from the previous tick. It could even do special formatting on the last tick. I like it.

Robert Buchholz

I've dropped this idea for now, and moved to d3's time tick formatter as per #346. It generates the year as a context in a time series, at least when the first month of the year is displayed.

I'm not sure what the future of replicating time formatting outside of d3 is, or whether it makes sense to implement something like this upstream.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.