谷歌的图表点颜色
答
尝试采取看看这个jsFiddle Example通过asgallant创建here
“有的API中没有支持制作线和数据点都在同一系列不同的颜色。你可以假的你但是,通过使用一个DataView并在两列中重复数据,想要。使第一个系列着色为“黑色”,第二个着色为“红色”,使用lineWidth = 0和pointSize> 0。
从实例:
var options = {
title: 'Load vs Length',
titlePosition: 'out',
legend: {
position: 'none'
},
hAxis: {
title: 'Length (inch)',
viewWindow: {
min: 0
},
format: '#.000'
},
vAxis: {
title: 'Load (pound)',
viewWindow: {
min: 0
}
},
series: { //Create 2 separate series to fake what you want. One for the line and one for the points
0: {
color: 'black',
lineWidth: 2
},
1: {
color: 'red',
lineWidth: 0,
pointSize: 5
}
}
答
谢谢您的建议。但是,系列1不适用于我: 以下代码将蓝线打印出来,但不显示点。如果我切换1和0.然后它显示红色的点,但没有线。在系列之前,我只是在hAxis之后有了pointSize:4。这工作,除了点和线相同的颜色。
{title: 'progress',
vAxis: {
title: 'Grade',
titleTextStyle: {color: 'red'},
gridlines: {count: 7},
viewWindow: { min: 0,
max: 100,
valueLabelsInterval: 20}
},
hAxis: {
title: 'Q date',
titleTextStyle: {color: 'red'},
slantedText: true
},
series: {
0: {lineWidth: 2},
1: {
color: 'red',
lineWidth: 0,
pointSize: 4
}
}
}
+0
tnx,我会试试 –
+1
我们可以对有多行的图表做同样的事吗? – 2015-05-14 06:46:33
感谢,一个简单的pointColor会从谷歌很好,但无论如何......欢呼声,适合我! –
是的,应该有一个更简单的方法,但我想他们不想为相交线引入任何混淆。很高兴帮助! =) – Chase
对于有多行的图表,我们可以做同样的事吗? – 2015-05-14 06:46:27