Is there a way to easily display a line of best fit in a scatter chart. I've seen what google recommends and don't quite understand how to implement it in my code, since I populate my chart differently than the example.
Here is my current code (displays points only):
function drawVisualization() {
// Create and populate the data table.
var data = new google.visualization.DataTable();
data.addColumn('date', 'X');
data.addColumn('number', 'FIRST
ONE);
data.addRow([new Date(2011,06,30), 0]);
data.addRow([new Date(2011,07,20), 42]);
data.addRow([new Date(2011,07,01), 0]);
data.addRow([new Date(2011,07,05), 0]);
data.addRow([new Date(2011,07,05), 0]);
data.addRow([new Date(2011,07,07), 0]);
data.addRow([new Date(2011,07,07), 200]);
data.addRow([new Date(2011,07,08), 0]);
data.addRow([new Date(2011,07,07), 0]);
data.addRow([new Date(2011,07,07), 0]);
data.addRow([new Date(2011,07,07), 0]);
data.addRow([new Date(2011,07,07), 0]);
data.addRow([new Date(2011,07,07), 0]);
data.addRow([new Date(2011,07,07), 0]);
data.addRow([new Date(2011,07,07), 0]);
data.addRow([new Date(2011,07,07), 0]);
data.addRow([new Date(2011,07,07), 0]);
data.addRow([new Date(2011,07,07), 0]);
data.addRow([new Date(2011,07,07), 0]);
data.addRow([new Date(2011,07,07), 42]);
data.addRow([new Date(2011,07,07), 42]);
data.addRow([new Date(2011,07,07), 42]);
data.addRow([new Date(2011,07,07), 86]);
data.addRow([new Date(2011,07,12), 0]);
data.addRow([new Date(2011,07,14), 0]);
data.addRow([new Date(2011,07,21), 118]);
data.addRow([new Date(2011,07,22), 200]);
data.addRow([new Date(2011,07,22), 200]);
data.addRow([new Date(2011,07,22), 86]);
data.addColumn('number', 'SECOND ONE');
data.addRow([new Date(2011,07,05), , 200]);
data.addRow([new Date(2011,07,05), , 0]);
data.addRow([new Date(2011,07,07), , 42]);
data.addRow([new Date(2011,07,14), , 0]);
data.addRow([new Date(2011,07,21), , 118]);
data.addColumn('number', 'THIRD ONE');
data.addRow([new Date(2011,07,05), , , 200]);
data.addRow([new Date(2011,07,07), , , 58]);
data.addRow([new Date(2011,07,11), , , 0]);
data.addRow([new Date(2011,07,13), , , 42]);
data.addRow([new Date(2011,07,22), , , 42]);
data.addRow([new Date(2011,07,22), , , 142]);
data.addRow([new Date(2011,07,22), , , 42]);
data.addColumn('number', 'FOURTH ONE');
data.addRow([new Date(2011,07,05), , , , 200]);
data.addRow([new Date(2011,07,22), , , , 0]);
data.addRow([new Date(2011,07,12), , , , 42]);
// Create and draw the visualization.
var chart = new google.visualization.ScatterChart(
document.getElementById('chart_div'));
chart.draw(data, {/*title: 'Cool shapes',*/
width: 600, height: 400,
vAxis: {title: "Conformance Score",
titleTextStyle: {color: "blue"}},
hAxis: {title: "Date", titleTextStyle: {color:
"blue"}}}
);
}
--
You received this message because you are subscribed to the Google Groups
"Google Visualization API" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-visualization-api?hl=en.
