Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
2
rated 0 times [  9] [ 7]  / answers: 1 / hits: 16940  / 13 Years ago, fri, november 18, 2011, 12:00:00

I have time-based data that ranges from 1 to 500. Time is plotted on the x axis and the values are on the y axis.



When the range between the minimum and maximum data-points is great the y-axis' start label is 0. I can tell Highcharts not to display the label by setting yAxis.startOnTick = false; but that's is not really what I'm after.



Here is a jsfiddle of the problem where you cannot tell if the first point is 0 or some other value. Having 0 here also looks like the min range for y is
0, not 1.



Can Highcharts display the first label and the first label should always be set to the minimum value in the dataset (relative to its axis).


More From » highcharts

 Answers
9

I am amazed how difficult this is. Not an optimal solution, but the best I can dream up with HighChart's api:



var someData = [1,5,82,9,300,5,42,199,5,6,99,1,56,52,250,64];

var chart = new Highcharts.Chart({

chart: {
renderTo: 'container'
},
yAxis:{
min: -10,
tickInterval: 1,
labels: {
formatter: function() {
if (this.value < someData[0])
return null;
else if (this.value == someData[0])
return this.value;
else if (this.value % 50 == 0)
return this.value;
}
}
},
series: [{
data: someData
}]

});


enter


[#89024] Friday, November 18, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
shamya

Total Points: 38
Total Questions: 101
Total Answers: 96

Location: Thailand
Member since Thu, Apr 22, 2021
3 Years ago
;