Black Lives Matter. Please consider donating to Black Girls Code today.
https://www.blackgirlscode.com

Date data in quarter format

The data iam sending is

x:(9) [“2016-1”, “2016-2”, “2016-3”, “2016-4”, “2017-1”, “2017-2”, “2017-3”, “2017-4”, “2018-1”]
y:(9) [48, 51, 68, 31, 7, 40, 76, 44, 28]

Its intended to be quarters, but is interpreted as months

is there a workaround?

I can’t think of a nice workaround other than setting using ticktext/tickvals

I’ve just created a feature request https://github.com/plotly/plotly.js/issues/4960 as it seems to be easy to implement by adopting the changes in d3-time-format. Please correct me if I’m wrong.

If you only want to be able to use “%q” format directive to format dates on X-axis (following https://plotly.com/javascript/tick-formatting/#using-tickformat-(date)), you could just amend plotly.js by adding a new field to the definition of var d3_time_formats = { ... (around line 27518 in the latest dist), smth like this:

var d3_time_formats  = {
...

      q: function(d, p) {
        return d3_time_formatPad(1 + ~~(d.getMonth() / 3), p, 1);
      },
...
}