javascriptjsfiddletradingview-api

Tradingview lightweight chart showing invalid date in Safari


I'm trying to get a lightweight chart from Tradingview working in Safari, but it's only working in Chrome and Firefox browsers. In chrome it shows a moving line while in Safari it only shows a straight line and "invalid date".

function setChartData(dates, chart_data) {

    var chart = LightweightCharts.createChart(document.getElementById("chart"), { width: 946, height: 710,                                                                                              
      localization: {
          timeFormatter: businessDayOrTimestamp => {
              return Date(businessDayOrTimestamp);
            },
          },
      });

The code can be found here in a JSFiddle: https://jsfiddle.net/mideruit/xpyrd4L2/


Solution

  • The problem seems to be the date format, Safari requires the date format to be yyyy/mm/dd HH:MM instead of yyyy-mm-dd HH:MM:SS