Graph fun

Home

Graph fun

Oct132011

Have just written some code to make a graph for work. Actually written the code that writes some code, as I'm using Google's interactive chart API to make some graphs of my data, so have written some code that then outputs this script, that Google then turns in to a graph. I like it!


google.load( 'visualization', '1.0', { packages: [ 'corechart' ] } );
google.setOnLoadCallback( function () {
var data = google.visualization.arrayToDataTable( [
[ 'Date', 'Hit', 'Miss', 'Rate %' ],
["2011-10-06",1523043,3257565,68],
["2011-10-07",141,318,69],
["2011-10-08",0,0,0],
["2011-10-09",0,0,0],
["2011-10-10",1691122,5285465,75],
["2011-10-11",2561827,6440954,71],
["2011-10-12",2489872,6102828,71],
["2011-10-13",1336691,2662614,66]
] );
var chart = new google.visualization.ComboChart( document.getElementById( 'chart_div' ));
chart.draw( data, {
seriesType: 'bars',
width: '100%',
height: 400,
isStacked: true,
series: {
2: {
type: 'line',
targetAxisIndex: 1
}
},
vAxes: [
{
title: 'Actual hits and misses',
},
{
title: 'Hit rate %',
maxValue: 100
}
]
} );
} );


then the graph itself looks something like this



Next stop find some reason to use the gauge chart style, it looks great.

:: :: Comment / reply

Over to you, discussion about anything local, but please be considerate... Folkestone on TV, Kent gigs, Find a flatmate, rent a room, property queries, current news, what's new, local events, for sale, local services, what I like about Folkestone, ask questions, offer advice, plug yourself... the more it's used the more useful a resource it will become. If you want a gig listed click here to add it (fixed now!), or just click here to post a message...