0
votes

I am creating a trend report in jasper studio using highcharts reports and I have ran into an issue on how to display default date range when there is no data.

Basically I need to show 6 data points on my x-axis(6 months) as default. This is fine except the data set I am using is dynamic(taken from a mysql query) so sometimes there will be data points for all 6 months but for others there may only be a data point for one month.

How can I get the report to show all 6 months on the x axis even when there are no associated data points?

So after the sql returns my results it would look something like this:

var chart = new Highcharts.Chart({
  chart: {
    renderTo: 'container'
  },
  xAxis: {
    categories: ['Jan']
  },

  yAxis: {
    max: 200
  },

  series: [{
    data: [29.9]
  }]
});

So this will just display Jan on the x-axis but I need to display following 5 months also(no data points on the report, they are just labels).

1

1 Answers

1
votes

You'll need to fill out the categories and set the xAxis max

$('#container').highcharts({
    xAxis: {
        categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
        max: 5,
        min: 0
    },

    series: [{
        data: [29.9]
    }]
});

http://jsfiddle.net/omw2enjf/