Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to dynamically set the minPointLength except 0

I like to set dynamically the value of the minPointLengh for high chart. But the below mentioned code is not working. can you please help me to get it done.

$(function () {
    $('#container').highcharts({
        chart: {
            type: 'column'
        },
        xAxis: {
            categories: ['Sep', 'Oct', 'Nov', 'Dec']
        },

        plotOptions: {
        var minPointLength; 
                if(this.y > 0)  
                  minPointLength = 3,  
             else  
                  minPointLength = 0,
            series: {
                        minPointLength: minPointLength,
            }
        },
        series: [{
            data: [4, 0, 1, 5]
        }]
    });
});
like image 575
Nirmal Srinath Avatar asked Sep 19 '25 13:09

Nirmal Srinath


1 Answers

My suggestion: change any 0 values to null values.

The minPointLength will not affect any points with null y values.

Update code to:

$(function () {
    $('#container').highcharts({
        chart: {
            type: 'column'
        },
        xAxis: {
            categories: ['Sep', 'Oct', 'Nov', 'Dec']
        },

        plotOptions: {
            series: {
              minPointLength: 3
          }
        },
        series: [{
            data: [4, null, 1, 5]
        }]
    });
});

Example:

  • http://jsfiddle.net/3d3fuhbb/155/

Additional reason that your code wouldn't work: you are trying to set the minPointLength property directly within the plotOptions object - it needs to be inside one of the series selector objects (ie 'series: {}', 'column: {}', etc).

like image 187
jlbriggs Avatar answered Sep 21 '25 01:09

jlbriggs