I am using a scatter chart from the Google visualization plugin, and I am trying to:
- Have each point be a different color
- have each point be a different shape.
I see this generic recommendation here and tried this:
google.charts.load('current', { 'packages': ['corechart'] });
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Age', 'Weight'],
[8, 12],
[4, 5.5],
[11, 14],
[4, 5],
[3, 3.5],
[6.5, 7]
]);
var options = {
series: {
0: { pointShape: 'circle' },
1: { pointShape: 'triangle' },
2: { pointShape: 'square' },
3: { pointShape: 'diamond' },
4: { pointShape: 'star' },
5: { pointShape: 'polygon' }
},
pointSize: 28,
chartArea:{left:10,top:0,width:"96%",height:"92%"},
'backgroundColor': 'transparent',
hAxis: {
baselineColor: 'transparent',
gridlineColor: 'transparent',
textPosition: 'none', minValue: 0, maxValue: 15
},
vAxis: {
baselineColor: 'transparent',
gridlineColor: 'transparent',
textPosition: 'none', minValue: 0, maxValue: 15
},
gridlines: {
color: 'transparent'
},
legend: 'none'
};
But it doesn't seem to work on a scatter chart.
Does scatter chart support the ability to have different colors and shapes on each point?
Each series is assigned to a column:
series.0
= column1
in the dataseries.1
= column2
in the dataetc...
Since the
data
provided only has one Y-axis column, all of the points fall underseries.0
-->pointShape: 'circle'
.Add columns and fill the rest with
null
to change the shape for each point. See following working snippet...