Chartjs-Chart js not working properly in Safari

1👍

So, it was a problem related with moment js. It didn’t want as input a list with string dates. Had to convert them to moment(date,"YYYY-MM-DD"):

var dados_temp = {{tag3_data.x|safe}}
var dados_moment = jQuery.map(dados_temp, function(x) { return moment(x,"YYYY-MM-DD"); });

0👍

as a hacky workaround to the MM-dd-yyyy issue specific to safari/chart.js you can simply parse the date before hand and then do, for example, '12/12/2021'.replace('/','-') on the string and feed that into the chart.js data set instead of feeding it a date pipe parsed date it will work.

const date = '12/12/2021'.replace('/','-')
this.chartLabels.push(date)

as opposed to

const transDate = new Date(it.asOfDate)
this.chatLabels.push(this.datePipe.transform(transDate, 'MM-dd-yyyy'))

Leave a comment