Javascript 对x值使用函数
使用highcharts时,我有一个带有2个视图的系列。datetime为1,samplenumber为1,我希望point.x值是一个函数,因此当highcharts抓取x时,函数将被执行,并根据某个范围变量返回样本号或日期时间Javascript 对x值使用函数,javascript,function,highcharts,Javascript,Function,Highcharts,使用highcharts时,我有一个带有2个视图的系列。datetime为1,samplenumber为1,我希望point.x值是一个函数,因此当highcharts抓取x时,函数将被执行,并根据某个范围变量返回样本号或日期时间 $(function () { Highcharts.setOptions({ // This is for all plots, change Date axis to loc
$(function () {
Highcharts.setOptions({ // This is for all plots, change Date axis to local timezone
global : {
useUTC : false
}
});
var chart = new Highcharts.Chart({
chart: {
renderTo: 'container',
zoomType: 'xy'
},
xAxis: {
type: 'linear'
},
series: [{
data: [
{x: calculateX, y:2, z: 4},
{x: calculateX, y:3, z: 5},
{x: calculateX, y:4, z: 6}
]
}]
});
});
var calculateX = function() {
return this.z
};
在这里拉小提琴:
现在,在更改视图时,我会将所有point.samplenumber或point.datetime值复制到point.x属性,该属性可以工作,但不是首选解决方案。只需进行一次更改 在脚本的主函数中编写函数
$(function () {
// Whole your code
var calculateX = function() {
return this.z
};
});
这是小提琴解决方案:@motormuis:Welcome:)