我可以在Highstock代码中使用不同的if条件吗? [英] Can I use different if-conditions in Highstock-code?
问题描述
我希望我的Highstock-Chart非常活跃。我从 var dataarray 中提取系列和yAxis的数量。所以我可以得到2系列或6或3或或或...
但现在我必须根据到达的系列数设置yAxis和系列的代码。如果 dataarray 是例如2程序应该跳过相应的条件。
但这在现实生活中不起作用。这是我的代码。我能做些什么呢?我不能在Highstock-Code中使用JavaScript?
不,你不能这样做,这不是因为Highstock,而是Javascript语言。
以这种方式创建图表:
new Highcharts。 StokChart({
// options
})
{abc:something,xyz:somethineElse}
你不能放置if-else条件。
我认为您可以创建如下所示的内容:
var xAxis ,
系列;
if(x == 2){
xAxis = {/ * options * /};
series = [/ * options * /];
} else {
//其他
}
var chartName = new Highcharts.StockChart({
xAxis:xAxis,
series :系列
});
I want that my Highstock-Chart is very dynamic. I extract the number of series and yAxis from var dataarray. So I can get e.g. 2 series or 6 or 3 or or or...
But now I have to set the code for the yAxis and series according to the number of series that are arriving. And if dataarray is e.g. 2 long the program should jump in the accordingly if-condition.
But that doesn't work in real life. Here is my code. What can I do instead? Can't I use JavaScript in Highstock-Code?
No you can't, and it's not because Highstock, but Javascript langauge.
When you create chart in that way:
new Highcharts.StokChart({
//options
})
you are passing a literal { abc: something, xyz: somethineElse }
where you can't put if-else conditions.
I think you can create something like this:
var xAxis,
series;
if(x == 2) {
xAxis = { /* options */ };
series = [ /* options */ ];
} else {
// something else
}
var chartName = new Highcharts.StockChart({
xAxis: xAxis,
series: series
});
这篇关于我可以在Highstock代码中使用不同的if条件吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!