<html>
<head>
<# insertNativeBrowserApiScriptTag() #>
<script type="text/javascript" src="" target="_blank" rel="nofollow">https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(drawChart);
function drawChart() {
var chartDiv = document.getElementById('chart_div');
var headers = ["Coupon", "Market Yield"];
var cells = vo.cells(headers, 0/*firstRow*/, null/*numberOfRows*/, function(data) {
var rowCount = data[0].length;
if (rowCount > 50) {
chartDiv.innerHTML = "Too much data - "+rowCount+" records. Please filter down to 50 or fewer.";
return;
}
// this is like this: [[1,3,4],[0.1,0.2,0.3]]; we need it like this: [[Title1, Title2], [1,0.1], [2,0.2], [3,0.3]].
var flipped = [headers];
for (var y = 0; y<rowCount; y++) {
flipped[y+1] = [];
for (var x = 0; x<data.length; x++) {
flipped[y+1][x] = data[x][y];
}
var options = {
title: 'Coupon vs Market Yield',
hAxis: {title: headers[0]},//, minValue: 0, maxValue: 15},
vAxis: {title: headers[1]},//, minValue: 0, maxValue: 15},
legend: 'none'
};
var chart = new google.visualization.ScatterChart(chartDiv);
chart.draw(google.visualization.arrayToDataTable(flipped), options);
}
});
}
</script>
</head>
<body>
<div id="chart_div" style="width: 900px; height: 500px;"></div>
</body>
</html>
JS view example.iok | 62K |
It looks like you're new here. If you want to get involved, click one of these buttons!