4
我可以根據上方(紅色)或下方(綠色)或之間(黃色)更改標記顏色,但不能更改標記之間的線的顏色。這可能嗎?現在,它只是顯示爲一條藍線。根據HighCharts中的值更改樣條線的顏色
function makeRun(divId, last, current, goal, title, yAxisTitle) {
var width = 1000; var SizeOfFont = '14px';
var min = checkMinMaxArray(current, last, goal, 'min') * 995/1000; //sets min closely below the real min. **consider changing to 4/5 digits**
var max = checkMinMaxArray(current, last, goal, 'max') * 1005/1000; //sets max closely above the real max
//if there are projections, color code the columns here
preprocessData = function (data, last, goal) {
var nData = [];
var colorGood = 'green'; var colorBad = '#E42217'; var colorUse;
for (var i = 0; i < data.length; i++) {
if (data[i] <= goal[i]) { colorUse = colorGood; }
else if (data[i] > last[i]) { colorUse = colorBad; }
else { colorUse = '#FFE303'; }
nData.push({
y: data[i],
x: i,
fillColor: colorUse,
color: colorUse
});
}
return nData;
};
var chart = new Highcharts.Chart({
chart: {
renderTo: divId,
height: 275, //little bigger than alotted height to make more readable
width: width //dependent on #gauges
},
title: {
text: title, //should all be the same, can make a parameter if need to be different
style: { //size of text above
fontSize: SizeOfFont
}
},
xAxis: {
//categories: xAxisTitles,
labels: { //size of the Text above^^
style: {
fontSize: SizeOfFont
}
}
},
yAxis: {
min: min,
max: max,
title: {
text: yAxisTitle, //parameter since some are days, percents, etc
style: {//size of y axis title
fontSize: SizeOfFont
}
},
labels: {
style: {//size of the y axis tick labels
fontSize: SizeOfFont
}
}
},
credits: {//gets rid of the highcharts logo in bottom right
enabled: false
},
legend: {//the legend at the bottom
style: {
fontSize: '12px'
}
},
series: [{
type: 'spline',
name: '2012',
data: last,
color: 'orange',
marker: {
symbol: 'diamond'
}
}, {
type: 'spline',
name: '2013',
data: preprocessData(current, last, goal),
marker: {
symbol: 'diamond'
}
}, {
type: 'spline',
name: 'Goal',
data: goal,
color: 'blue',
marker: {
symbol: 'diamond'
}
}]
});
}
請參閱http://stackoverflow.com/questions/9963907/highcharts-can-i-customize-the-colors-of-individual-series –
上面的鏈接不是我所需要的 - 它顯示瞭如何將整個數據系列有一定的顏色。 我需要能夠更改標記之間的顏色。 – bramwell2010
這在線圖中是不可能的 –