ocespedes
ocespedes

Reputation: 1303

Highcharts xAxis with datetime not showing any chart

I'm trying to draw a line chart with the x axis with dates, but is not showing anything just a blank space only showing the title of the chart.

there are no errors on console, and the configuration is like this:

new Highcharts.Chart({
                            chart: {
                                type: 'line',
                                renderTo: document.getElementById('patientFrequency')
                            },
                            title: {
                                text: 'Patient frequency'
                            },
                            xAxis: {
                                type: 'datetime',
                                title: {
                                    text: 'days'
                                }
                            },
                            series: {
                                data: chartdata
                            }
                        });

the chartdata is an array with [date, frequency] for each point.

Any thoughts? Thanks

Upvotes: 0

Views: 3593

Answers (1)

Barbara Laird
Barbara Laird

Reputation: 12717

series should be an array of objects.

$(function() {
    var chartdata = [
                [Date.UTC(2010, 0, 1), 29.9],
                [Date.UTC(2010, 2, 1), 71.5],
                [Date.UTC(2010, 3, 1), 106.4]
            ];
  new Highcharts.Chart({
    chart: {
      type: 'line',
      renderTo: document.getElementById('patientFrequency')
    },
    title: {
      text: 'Patient frequency'
    },
    xAxis: {
      type: 'datetime',
      title: {
        text: 'days'
      }
    },
    series: [{
      data: chartdata
    }]
  });
});

http://jsfiddle.net/bs4cjLkd/

Upvotes: 1

Related Questions