-
Notifications
You must be signed in to change notification settings - Fork 140
Getting a chart as an image 2.5.x
Kevin Hill edited this page Mar 4, 2016
·
2 revisions
You can use the $lava->Ready event in combination with google's getChartURI() method, to retrieve the image URI of the chart.
When building your chart, include the Ready event as such (you can change the callback name):
$lava = new Khill\Lavacharts\Lavacharts;
$lava->LineChart('MyChart')
->datatable($myDataTable)
->setOptions([
'events' => [
$lava->Ready('getImageCallback')
]
]);
and then include the callback function in your view:
<script type="text/javascript">
function getImageCallback (event, chart) {
console.log(chart.getImageURI());
// This will return in the form of "data:image/png;base64,iVBORw0KGgoAAAAUA..."
}
</script>
Complete Documentation available at lavacharts.com