CPU パラメータ、ディスク パラメータ、メモリ パラメータのハイチャートを描画しようとしています。ドロップダウンをクリックして特定のパラメータを選択できます。私の仕事は、特定のパラメーターをクリックしたときにハイチャートを描画することです。前のグラフを描画したままにしたい。つまり、ドロップダウンから任意のパラメータを選択してグラフを追加したいと考えています。私は次のコードを書いた
function DrawTrendCpu(plot,TypeOfParameter,sub_type) {
itemdata=[];
$(function () {
$('#container').highcharts({
chart: {
zoomType: 'xy'
},
title: {
text: 'Server Monitroting Tool'
},
subtitle: {
text: TypeOfParameter+' usage'
},
xAxis: {
type: 'datetime',
categories: ['TIME']
},
yAxis: [{ // Primary yAxis
labels: {
formatter: function() {
return this.value +'%';
},
style: {
color: '#89A54E'
}
},
title: {
text: "core " +sub_type,
style: {
color: '#89A54E'
}
}
}],
legend: {
layout: 'vertical',
align: 'left',
x: 120,
verticalAlign: 'top',
y: 80,
floating: true,
backgroundColor: '#FFFFFF'
},
series: []
});
});
if (TypeOfParameter=='memory')
{
for (i = 0; i< plot.length; i++) {
x = parseFloat(plot[i][3]);
itemdata.push((x));
}
var chart = $('#container').highcharts();
chart.addAxis({ // Secondary yAxis
title: {
text: 'Rainfall'
},
lineWidth: 2,
lineColor: '#08F',
opposite: true
});
chart.addSeries({
name: 'memory',
type: 'spline',
color: '#08F',
yAxis: "memory usage ",
data: itemdata
});
}
else if(TypeOfParameter=='cpu')
{
console.log("cpu")
//console.log(plot["all"])
console.log(plot[0].length,"hey")
for (i = 0; i< plot[0].length; i++) {
itemdata.push(parseFloat(plot[i][8]));
}
var chart = $('#container').highcharts();
chart.addSeries({
name: "core "+sub_type,
data: itemdata
}, false);
chart.redraw();
}
else if (TypeOfParameter=='disk')
{
for (i = 0; i< plot.length; i++) {
x = parseFloat(plot[i][3]);
itemdata.push((x));
}
var chart = $('#container').highcharts();
chart.addSeries({
name: "disk "+sub_type,
data: itemdata
},false);
chart.redraw();
}
}
私がやろうとしているのは、余分な軸を動的に追加することですが、エラー18が表示されます。助けてください。私は初心者です。