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]
}]
});
});
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:
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With