✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
🧬 Learn how to build RNA-Seq data apps with Python & Dash. Register for the May 20 Webinar!

Stacked bar chart with Y axis in HH:MM:SS

Dear All,

I want to convert the Y axis values on a plot I made with Plotly JS from minutes to HH:MM:SS.
To this end I am using the following piece of javascript code:

function pad(v) {

return v < 10 ? '0' + v : String(v)


function sec2dt(v) {

var MIN = 60
var HOUR = 60 * 60

v = v * MIN;

var h = Math.floor(v / HOUR)
var m =  Math.floor((v - (h * HOUR)) / MIN)
var s = Math.floor(v - (h * HOUR) - (m * MIN))

// you have to provide YYYY-MM-DD

// for plotly to understand it as a date
return `2017-01-01 ${h}:${pad(m)}:${pad(s)}`


and I map my y values as follows:

data1 = [{x:services1,y:y1.map(sec2dt),name: ‘b1’,type: ‘bar’}]

But it turns out the resulting stacked bar chart has un unordered Y axis now.

Can someone help me?

It works fine for a single bar chart (without stacking), but not for stacked bar charts…