conquester
conquester

Reputation: 1132

HighCharts not displaying series data

I have a timeseries data which I am trying to display with Highstocks: Here is the data:

{
  "title": {
    "text": "My Graph"
  },
  "series": [
    [
      {
        "name": "Future Index Longs",
        "data": [
          [
            "2019-02-05",
            104516
          ],
          [
            "2019-02-06",
            127260
          ],
          [
            "2019-02-07",
            156291
          ],
          [
            "2019-02-08",
            167567
          ]
        ]
      }
    ],
    [
      {
        "name": "Future Index Longs",
        "data": [
          [
            "2019-02-05",
            21
          ],
          [
            "2019-02-06",
            0
          ],
          [
            "2019-02-07",
            1263
          ],
          [
            "2019-02-08",
            12
          ]
        ]
      }
    ],
    [
      {
        "name": "Future Index Longs",
        "data": [
          [
            "2019-02-05",
            33873
          ],
          [
            "2019-02-06",
            61093
          ],
          [
            "2019-02-07",
            43125
          ],
          [
            "2019-02-08",
            41928
          ]
        ]
      }
    ],
    [
      {
        "name": "Future Index Longs",
        "data": [
          [
            "2019-02-05",
            47542
          ],
          [
            "2019-02-06",
            55084
          ],
          [
            "2019-02-07",
            75256
          ],
          [
            "2019-02-08",
            77786
          ]
        ]
      }
    ],
    [
      {
        "name": "Future Index Longs",
        "data": [
          [
            "2019-02-05",
            185952
          ],
          [
            "2019-02-06",
            243437
          ],
          [
            "2019-02-07",
            275935
          ],
          [
            "2019-02-08",
            287293
          ]
        ]
      }
    ]
  ]
}

The graph is empty and no data is displayed. What am I doing wrong?

Sorry to add this filler here but I am required to add more text to post this question and since this is a pretty simple question, I don't have much to add.

Upvotes: 0

Views: 875

Answers (2)

Wojciech Chmiel
Wojciech Chmiel

Reputation: 7372

To have a chart with datetime axes in Highcharts you have to pass the X value as the timestamp in milliseconds since 1970.

Highstock example:

Note that in Highcharts you have to define xAxis.type as datetime like that:

  xAxis: {
    type: 'datetime'
  }

Highcharts demo:

API reference:

Upvotes: 1

Alex G
Alex G

Reputation: 1917

You have the wrong format on your series, it should be an array of objects.

Like this: series: [{ ... }, { ... }]

Check this fiddle: https://jsfiddle.net/wg1vnyzp/1/

Upvotes: 1

Related Questions