Developed by: CZ.NIC

Latest version: OGRA Git repository

OGRA library

Example: Using the callback method

callback: Function
Callback method is called after drawing of chart is complete. First parameter for callback method is reference to the chart that has been just created.
callback_args: Array
Optional list of additional parameters for callback method.

HTML:

Import OGRA and create element for future chart and report message.

<script type="text/javascript" src="https://gitlab.labs.nic.cz/labs/ogra/raw/master/ogra.js"></script>

<div id="my_chart"></div>

<div id="report"></div>

Javascript:

Prepare your data and create chart.

var data = {"cols":[{"label":"Year", "type":"string"},{"label":"Sales", "type":"number"},{"label":"Expenses", "type":"number"}],"rows":[{"c":[{"v":"2004"},{"v":1000},{"v":400}]},{"c":[{"v":"2005"},{"v":1170},{"v":460}]},{"c":[{"v":"2006"},{"v":660},{"v":1120}]},{"c":[{"v":"2007"},{"v":1030},{"v":540}]}]};			

function my_method(chart_reference, arg1, arg2) {		
	var element = document.getElementById("report");
	element.style.color = "red";
	element.innerHTML = "Chart is complete! " + arg1 + ", " + arg2;
}

Ogra.graph("my_chart", data, "column", "google", {callback: my_method, callback_args:["my_arg1", "my_arg2"]} );

Result:

Edit in jsFiddle

More examples


CZ.NIC

© 2013 CZ.NIC