Skip to content

Getting a chart as an image 3.0.x

Kevin Hill edited this page Aug 29, 2017 · 3 revisions

You can use 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->LineChart('MyChart', $myDataTable, [
    'events' => [
        '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>