我正在使用HighCharts制作折线图,并尝试为每个系列更改线条颜色。我找到了这个例子here,但数据是硬编码的。我的数据是从Sql数据库中提取的,并使用一些VB代码传递到HTML页面。
var chart;
$(document).ready(function () {
chart = new Highcharts.Chart({
chart: {
renderTo: 'container',
defaultSeriesType: 'column'
},
title: {
text: 'Chart Title'
},
subtitle: {
text: 'Chart subtitle'
},
xAxis: {
categories: [<%= GraphDate %>]
,
labels:
{
rotation: -45,
align: 'right',
style:
{
}
}
},
yAxis: {
min: 160,
title: {
text: 'Temp'
}
},
legend: {
layout: 'vertical',
backgroundColor: '#FFFFFF',
align: 'left',
verticalAlign: 'top',
x: 400,
y: 0,
floating: true,
shadow: true
},
tooltip: {
formatter: function () {
return '' +
this.x + ': ' + this.y + ' ºC';
}
},
plotOptions: {
column: {
pointPadding: 0.2,
borderWidth: 0
}
},
series:
[<%= GraphSeries %>],
});
我尝试使用其他帖子中的方法进行样式设置,但是它没有生成图表。主要问题在于,这条线图有两个系列,所以下面的方法会设置两个系列的颜色,我需要在VB代码中如何设置系列格式呢?
series: [{
color: 'yellow',
data: [
[<%= GraphSeries %>]
]},
编辑:
$(document).ready(function () {
chart = new Highcharts.Chart({
colors: ['#4572A7', '#AA4643', '#89A54E', '#80699B', '#3D96AE', '#DB843D', '#92A8CD', '#A47D7C', '#B5CA92']
chart: {
renderTo: 'container',
defaultSeriesType: 'column'
}
setOptions
而不是new Highcharts.Chart
? - Sergio Tulentsev