Plotly.js: Tickformat attribute descriptions should link to d3 v3 timeformat docs

Created on 26 Sep 2018  路  10Comments  路  Source: plotly/plotly.js

Tickformat with "%V" for weekdays is not working:
https://codepen.io/anon/pen/NLQpEz

It should work as described in https://github.com/d3/d3-time-format/blob/master/README.md#locale_format

Where is the source of the formatting? Can anyone provide a link pls?

All the best

documentation

All 10 comments

We're (still unfortunately) using d3 v3. So that doc page isn't adequate. We should update the tickformat descriptions:

https://github.com/plotly/plotly.js/blob/a070a8d2dd89f8ecbee89eecee77979298bfd886/src/plots/cartesian/layout_attributes.js#L509-L518

and link it to

https://github.com/d3/d3-3.x-api-reference/blob/master/Time-Formatting.md#format

https://github.com/plotly/plotly.js/issues/424 is the issue regarding bumping d3.

Thanks for reporting.

For completeness, the items d3v3 is missing that v5 has are:

%Q - milliseconds since UNIX epoch.

%s - seconds since UNIX epoch.

%u - Monday-based (ISO 8601) weekday as a decimal number [1,7].

%V - ISO 8601 week of the year as a decimal number [01, 53].

%f - microseconds as a decimal number [000000, 999999]. Frustratingly, d3 did something different than we did with %f, which we added (before it was part of d3) to support more digits and increased flexibility over %L. They added it as a fixed 6 digits of precision, whereas we support any precision up to 6 digits (using %{n}f) and we truncate trailing zeros. The fixed precision of only 3 (%L) or 6 digits is, IMO, a significant limitation (though I can see wanting to keep trailing zeros, we could easily add that) so I guess we'll be keeping this particular difference from D3 long-term...

Perhaps not worth it until we upgrade our d3, but it would be possible for us to add Q,s,u,V similarly to how we added f.

Frustratingly, d3 did something different than we did with %f,
but it would be possible for us to add Q,s,u,V similarly to how we added f.

Ha good point, I forgot about that %f discrepancy. Thanks for the reminder!

It will be greate to also add %{n}f in documentation. Becasuse there is nothing about truncating trailing zeroes, however in provided link in d3-format version 1.3.0 has been added ~ operator for that purpose. I thought that there is no any option to truncate trailing zeroes but found this issue

Hi, about the @etpinard's comment "We're (still unfortunately) using d3 v3": there are plans for update Plotly's D3 in 2019?

there are plans for update Plotly's D3 in 2019?

You subscribed to https://github.com/plotly/plotly.js/issues/424 for the most up-to-date development info.


We for sure would like to upgrade d3 in the near future, but upgrading currently breaks our transition/animation code which (unfortunately) has a lot of not-so-well tested behavior and would require many days of manual testing. As newer major versions of d3 don't offer many new features of interest for us, we haven't gotten around to do it.

Is there any progress with this issue? I have the same issue, %w is ok but %V is outputting simply a "V", not the ISO week number.

        fig.update_layout(
            hoverlabel=dict(
                bgcolor="white",
                font_size=16,
                font_family="Rockwell"
            ),
            height=700,
            font=dict(
                size=16
            ),
            xaxis_tickformat = 'CW %V-%Y'
        )

Output:
image

We've implemented this and it should be out in the next version of Plotly.js, in the coming days.

We've implemented this and it should be out in the next version of Plotly.js, in the coming days.

Hi @nicolaskruchten - when do you plan to release the next version?

Plotly.js version 1.55 came out last Thursday, and it supports %V

Was this page helpful?
0 / 5 - 0 ratings

Related issues

danielsamuels picture danielsamuels  路  3Comments

tim-sauchuk picture tim-sauchuk  路  3Comments

chriddyp picture chriddyp  路  3Comments

nicolaskruchten picture nicolaskruchten  路  3Comments

etpinard picture etpinard  路  3Comments