If you calculate your thresholds, you can add them to the scatter chart by adding two more series to your DataTable, something like this:
var data = new google.visualization.DataTable();
data.addColumn('number', 'X');
data.addColumn('number', 'Y');
data.addColumn('number', 'Avg X');
data.addColumn('number', 'Avg Y');
/* populate X,Y data
*
*
*/
// calculate average, max, and min of X and Y
var avg = google.visualization.data.group(data, [], [{
column: 0,
type: number,
aggregation: google.visualization.data.average
}, {
column: 0,
type: number,
aggregation: google.visualization.data.max
}, {
column: 0,
type: number,
aggregation: google.visualization.data.min
}, {
column: 1,
type: number,
aggregation: google.visualization.data.average
}, {
column: 1,
type: number,
aggregation: google.visualization.data.max
}, {
column: 1,
type: number,
aggregation: google.visualization.data.min
}]);
data.addRows([
[avg.getValue(0, 0), null, avg.getValue(0, 4), null],
[avg.getValue(0, 0), null, avg.getValue(0, 5), null],
[avg.getValue(0, 1), null, null, avg.getValue(0, 3)],
[avg.getValue(0, 2), null, null, avg.getValue(0, 3)],
]);
var chart = new google.visualization.ScatterChart(document.getElementById('chart_div'));
chart.draw(data, {
series: {
1: {
lineWidth: 1,
pointSize: 1
},
2: {
lineWidth: 1,
pointSize: 1
}
}
});
I haven't tested it, so you're probably going to have to play with it some. I suspect that the #group call might throw an error for not passing it a key column, and I may have messed up the placement of data in the array (I'm feeling a tad bit dyslexic at the moment), but the basic idea is what you need.