2

I'm try to draw multiple charts in the Vue page.

This is my chartOptions.

this.chartOptions[i] = {
      xaxis: {
        type: "datetime",
        categories: measure_at[i]
      },
      yaxis: {
        labels: {
          minWidth: 10
        }
      },
      zoom: {
        enabled: false
      },
      dataLabels: {
        enabled: false
      },
      stroke: {
        width: [3, 3, 3],
        curve: "straight",
        dashArray: [0, 3, 3]
      },
      markers: {
        size: [6, 0, 0],
        hover: {
          sizeOffset: 10
        }
      },
      grid: {
        borderColor: "#f1f1f1"
      },
      colors: ["#757575", MEASUREMENT_COLORS[1], MEASUREMENT_COLORS[2]],
      tooltip: {
        enabledOnSeries: [0]
      }
    };

As you can see, the type of my xaxis is "datetime", and categories code is like this.

measure_at[i] = new Date(
        data.records[i].measure_at * 1000

When I run my code, the following error occurs and the chart cannot be displayedenter image description here

And When I log chartOptions[i], it seems to be the correct datetime format

enter image description here

AngusHo53
  • 51
  • 1
  • 6
  • Please post text, not images. The date format in the categories array is not supported by ECMA-262, so parsing is implementation dependent. Given the unusual format, it will almost certainly result in an invalid Date. – RobG Nov 04 '20 at 00:32
  • But I use date.toLocaleString() to handle my categories. It should be in datetime format? – AngusHo53 Nov 04 '20 at 08:43
  • There is no expectation that the string created by *toLocaleString* can be parsed by the built–in parser, quite the opposite. – RobG Nov 04 '20 at 10:07
  • One other option is to provide timestamps in the xaxis.categories instead of a date strings. – junedchhipa Nov 05 '20 at 10:37

0 Answers0