[英]Strange issue Highchart tick interval
I don't know whether I am doing something wrong or this is strange issue in Highcharts, Actually I am interested to change x and y axis tickmark using input box, if its possible to update tickmark interval without redraw its well and good, 我不知道我做错了什么或者这是Highcharts中的奇怪问题,实际上我有兴趣使用输入框更改x和y轴tickmark,如果它可以更新tickmark间隔而不重绘它的好,
Here strange issue is following has no effect onchange 这里奇怪的问题是对改变没有影响
var dummy = $('#xint').val();
chart.xAxis[0].options.tickInterval = dummy ;
but if I define variable dummy like this, tick intervals are getting updated, I really don't know whats really wrong here.. please some one help me 但是,如果我这样定义变量虚拟,滴答间隔正在更新,我真的不知道这里真的错了..请有人帮我
Here is link to Fiddle 这里是 Fiddle的 链接
var dummy = 0.2;
chart.xAxis[0].options.tickInterval = dummy ;
HTML HTML
<script src="http://code.highcharts.com/highcharts.js"></script>
<div id="container" style="height: 400px"></div>
<input id='xint' type='number'>
JAVASCRIPT JAVASCRIPT
$(function () {
var chart = new Highcharts.Chart({
chart: {
renderTo: 'container',
zoomType: 'xy',
marginLeft: 50,
marginBottom: 90
},
yAxis: {
reversed: true,
//min: 0,
//max: 50
},
plotOptions: {
series: {
stacking: 'normal'
}
},
xAxis: {
opposite: true
},
series: [{
name: '01-Jan-2014',
data: [
[28, 10],
[30, 0]
]
}]
});
$('#xint').change(function(){
setTimeout(function() { alert($('#xint').val());},10);
// This is not working
// var dummy = $('#xint').val();
// where as this is working..
var dummy = 0.2;
chart.xAxis[0].options.tickInterval = dummy ;
chart.xAxis[0].isDirty = true;
chart.redraw();
});
});
.val()
returns a string, you need a float: .val()
返回一个字符串,你需要一个float:
var dummy = parseFloat($('#xint').val());
EDITS FOR COMMENT 评论的编辑
Do not update the tickInterval
as you are doing it (it messes with the internals of Highcharts) Instead use: 不要像你正在做的那样更新
tickInterval
(它与Highcharts的内部相混淆)而是使用:
chart.yAxis[0].update({
tickInterval: dummy
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.