javascript Highcharts - 如何从任意值开始 x 轴
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13693854/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Highcharts - How to start x axis from an arbitrary value
提问by L Lawliet
I am using [highcharts][1] to plot a graph between a range of values from data base. I want by X Axis values to start from the user input.
我正在使用 [highcharts][1] 在来自数据库的一系列值之间绘制图表。我希望 X 轴值从用户输入开始。
For example, if the user wants the values between range 50 and 100, I want my x axis to start from 50.
例如,如果用户想要 50 到 100 之间的值,我希望我的 x 轴从 50 开始。
The range would be of variable size. The size of the data is large so I can't do something like getting all and using min and max for display.
该范围的大小可变。数据的大小很大,所以我不能做一些事情,比如获取所有内容并使用最小值和最大值进行显示。
Thanks in advance.
提前致谢。
This is my chart object. I have two input fields for user that I use to query the database and return rows in between.
这是我的图表对象。我有两个用户输入字段,用于查询数据库并返回其间的行。
I use multiple type of graphs. The problem is that I have no idea on how to define the start of X axis as 50 if I am getting data from database between 50 and 100. It shows 50 values but start them from 0 upto 50.
我使用多种类型的图表。问题是,如果我从 50 到 100 之间的数据库获取数据,我不知道如何将 X 轴的起点定义为 50。它显示 50 个值,但从 0 到 50 开始。
I tried min 10 and so. That do start from that value but skips the first 10 or so values.
我尝试了 10 分钟等等。那确实从该值开始,但会跳过前 10 个左右的值。
The input field has id 'lower' and 'upper'.
输入字段具有 id 'lower' 和 'upper'。
var options = {
chart: {
renderTo: ctn.attr('id'),
type: $('#graph_type option:selected').val(),
zoomType: 'x'
},
title: {
text: $('#graph_title').val()
},
subtitle: {
text: "Graph - " + (graph_no + 1)
},
xAxis: {
title: {
text: $('#x_label').val()
}
},
yAxis: {
title: {
text: $('#y_label').val()
}
},
credits: {
enabled: false
},
series: []
};
回答by L Lawliet
Thanks everyone for the response. I found the solution. Min max was not actually doing as I wanted it to.
谢谢大家的回应。我找到了解决方案。Min max 实际上并没有像我想要的那样做。
I found the solution.
我找到了解决方案。
To start the x axis value from desired value use
要从所需值开始 x 轴值,请使用
plotOptions:
<your_graph_type>:{
pointStart: <your_value>
}
回答by Nagesh Salunke
I think setting min and max for xAxis will work. Refer this link
我认为为 xAxis 设置最小值和最大值会起作用。 参考这个链接
and you can say
你可以说
startOnTick: false, endOnTick:false
startOnTick: false, endOnTick:false
For example refer : example
例如参考:example
I have values set min of y to 20 and max to 217,
我将 y 的最小值设置为 20,最大值设置为 217,
yAxis: {
min: 20,
max:217,
startOnTick: false,
endOnTick:false
},
See how ther chart is displayed. I hope this helps.
查看图表的显示方式。我希望这有帮助。