Black Lives Matter. Please consider donating to Black Girls Code today.

How to localize datetime x-axis?

When the x-axis of a graph is datetime type, plotly automatically format the value in american format. Is it possible to localize the format use by plotly? Is it possible to declare different date/time formats for different languages and choose the target language when the graph is plotted?

By localize, do you mean displaying the months in a non-English language or simply rearranging the order of the day/month/year values?

To achieve the former, you’ll (unfortunately) need to specify custom tick labels using xaxis.tickvals ans xaxis.ticktext.

The latter is easier to get done: simply set the xaxis.tickformat attribute to the format of your choice. Search these forums for plenty of tickformat examples.

Yes, i would like to display the date in a non-English format.
I use the same chart to display data for different periods (day, week, month, year). Automatically, Plotly manages very well the xaxis labels by setting the correct format (hours, days or months). I would like to use this feature with day, month, … translated in other language (like d3.locale() function).