我有一個很高的圖表,它在刷新時動態地將數據推入系列,但每次顏色都會更改如何修復圖表的顏色。我使用角度js和我的高圖形配置對象是如下在HighCharts中修復圖表的顏色
var chartConfig = {
credits: {
enabled: false
},
options: {
colors: ['#058DC7', '#50B432', '#ED561B', '#DDDF00', '#24CBE5', '#64E572', '#FF9655', '#FFF263', '#6AF9C4'],
chart: {
backgroundColor: '#EDEDED',
zoomType: 'x',
reflow: true
},
credits: false
},
series: [],
tooltip: {
headerFormat: '<span style="font-size:10px">{point.key}</span><table>',
pointFormat: '<tr><td style="color:{series.color};padding:0">{series.name}: </td>' +
'<td style="padding:0"><b>{point.y:.1f} mm</b></td></tr>',
footerFormat: '</table>',
shared: true,
useHTML: true
},
legend: {
enabled: true
},
series: [],
exporting: {
csv: {
dateFormat: '%Y-%m-%d'
}
},
title: {
text: '',
style: {
display: 'none'
}
},
xAxis: {
title: {}
},
func: function(chart) {
$timeout(function() {
chart.reflow();
}, 0);
}
};
如果顏色改變,那麼你就沒有更新的系列 - 您要添加一個新的。顯示您如何更新數據以獲得更多幫助。 – jlbriggs
我將系列數組設置爲null,然後再將值插入系列中 –
每次刷新時,我都會調用一個Ajax來獲取數據,然後將其插入到系列數組中 –