[英]Make HighCharts Axis Labels being and end at my min/max
Why wont my HighCharts y axis labels begin at 0.5 and end at 17? 为什么我的HighCharts y轴标签不会从0.5开始到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.
而是y轴标签从0开始到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)? 无论如何,我是否可以控制此设置并强制y轴标签以我的最小值开始,以我的最大值结束(最好不要更改我的
tickAmount
值)?
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 使用yAxis.tickPositioner这将工作
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. 您可以将
tickInterval
属性设置为0.5值,并使用labels.step
属性容纳可见刻度的数量,或者在tickPositions
数组中指定刻度。
API Reference: API参考:
http://api.highcharts.com/highcharts/yAxis.labels.step http://api.highcharts.com/highcharts/yAxis.labels.step
http://api.highcharts.com/highcharts/yAxis.tickInterval http://api.highcharts.com/highcharts/yAxis.tickInterval
http://api.highcharts.com/highcharts/yAxis.tickPositions http://api.highcharts.com/highcharts/yAxis.tickPositions
Examples: 例子:
http://jsfiddle.net/bfky8gce/ - setting tickInterval to 0.5 http://jsfiddle.net/bfky8gce/-将tickInterval设置为0.5
http://jsfiddle.net/1gxp8zt7/ - using tickPositions http://jsfiddle.net/1gxp8zt7/-使用tickPositions
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.