Why wont my HighCharts y axis labels begin at 0.5 and end at 17? I have explicitly specified this in the initialisation code but its not adhering to it. Instead the y axis labels begin at 0 and end at 18.
Is there anyway I can control this and force the y axis labels to begin at my min value and end at my max value (and preferably not need to alter my tickAmount
value)?
Highcharts.chart('container', { chart: { }, yAxis: { min: 0.5, max: 17, //tickInterval: 10, tickAmount: 4, }, series: [{ data: [[5, 0.7], [10, 5]] }] });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <script src="https://code.highcharts.com/highcharts.js"></script> <p> I am expecting the y axis labels to begin at 0.5 (my min) and end at 17 (my max). Not begin at 0 and end at 20. </p> <div id="container" style="height: 400px"></div>
Use yAxis.tickPositioner this will work
Highcharts.chart('container', { chart: { }, yAxis: { min: 0.5, max: 17, tickPositions: [0.5, 3, 6, 9, 12, 15, 17], }, series: [{ data: [ [5, 0.7], [10, 5] ] }] });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <script src="https://code.highcharts.com/highcharts.js"></script> <p> I am expecting the y axis labels to begin at 0.5 (my min) and end at 17 (my max). Not begin at 0 and end at 20. </p> <div id="container" style="height: 400px"></div>
You can set tickInterval
property with 0.5 value and accommodate the number of visible ticks with labels.step
property or specify ticks inside tickPositions
array.
API Reference:
http://api.highcharts.com/highcharts/yAxis.labels.step
http://api.highcharts.com/highcharts/yAxis.tickInterval
http://api.highcharts.com/highcharts/yAxis.tickPositions
Examples:
http://jsfiddle.net/bfky8gce/ - setting tickInterval to 0.5
http://jsfiddle.net/1gxp8zt7/ - using tickPositions
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.