ostav,
Вариант ...
<html>
<head>
<meta charset="utf-8" />
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("visualization", "1", {
packages: ["corechart"]
});
google.setOnLoadCallback(drawChart);
function drawChart(add_index) {
var data = google.visualization.arrayToDataTable([
['Year', 'Sales', 'Expenses'],
['2004', 1000, 400],
['2005', 1170, 460],
['2006', 660, 1120],
['2007', 1030, 540]
]);
if (add_index.length) data = google.visualization.arrayToDataTable(add_index);
var options = {
title: 'Company Performance'
};
var chart = new google.visualization.LineChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
</script>
</head>
<body>
<input type="checkbox" id="1" />Platinum
<br />
<input type="checkbox" id="2" />Gold
<br />
<input type="checkbox" id="3" />GoldP2
<br />
<input type="checkbox" id="4" />Balance
<br />
<input type="checkbox" id="5" />Aggressive
<br />
<input type="checkbox" id="6" />Million
<br />
<input type="button" id="check" value="Анализ индексов" />
<br />
<script type="text/javascript">
document.getElementById("check").onclick = function () {
var index = [
['Неделя', 'Platinum', 'Gold', 'GoldP2', 'Balance', 'Aggressive', 'Million', 'Средний'],
['27.05.2012-03.06.2012', 1, 2, 3, 4, 5, 6, 7],
['03.06.2012-10.06.2012', 1, 2, 3, 4, 5, 6, 7],
['10.06.2012-17.06.2012', 1, 2, 3, 4, 5, 6, 7],
['27.05.2012-03.06.2012', 1, 2, 3, 4, 5, 6, 7],
['03.06.2012-10.06.2012', 1, 2, 3, 4, 5, 6, 7]
];
var add_index = [
[0, 0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0, 0]
];
var add_y = 0
while (++add_y < index.length - 1) {
add_index.push([0, 0, 0, 0, 0, 0, 0, 0])
add_index[0][0] = index[0][0]
add_index[0][7] = index[0][7]
add_index[1][0] = index[1][0]
var i = 0;
var y = 0;
while (++i <= 6) {
if (document.getElementById(i).checked) {
y = y + 1
add_index[0][i] = index[0][i]
add_index[1][i] = index[1][i]
add_index[add_y + 1][0] = index[add_y + 1][0]
add_index[add_y + 1][i] = add_index[add_y][i] + index[add_y + 1][i]
}
}
}
var aver_y = 0
while (++aver_y < add_index.length) {
var i7 = 0;
while (++i7 < 7) {
add_index[aver_y][7] = add_index[aver_y][7] + add_index[aver_y][i7]
}
add_index[aver_y][7] = add_index[aver_y][7] / y
}
drawChart(add_index)
}
</script>
<div id="chart_div" style="width: 900px; height: 500px;"></div>
</body>
</html>