I have a PHP file which renders a PNG image (see online, based on Google Charts example). I want to "execute" this file using cronjob, and use it to generate PNG image on my server every day.
Is this possible? I can run PHP/Bash using cronjob. I tried running PHP script which executed the HTML using PHP's eval()
, but how would I pipe the output to PNG file?
google.charts.load("current", {
packages: ['corechart']
});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Element', 'Density', {
role: 'style'
}],
['Copper', 8.94, '#b87333', ],
['Silver', 10.49, 'silver'],
['Gold', 19.30, 'gold'],
['Platinum', 21.45, 'color: #e5e4e2']
]);
var options = {
title: "Density of Precious Metals, in g/cm^3",
bar: {
groupWidth: '95%'
},
legend: 'none',
};
var chart_div = document.getElementById('chart_div');
var chart = new google.visualization.ColumnChart(chart_div);
// Wait for the chart to finish drawing before calling the getImageURI() method.
google.visualization.events.addListener(chart, 'ready', function() {
chart_div.innerHTML = '<img src="' + chart.getImageURI() + '">';
console.log(chart_div.innerHTML);
});
chart.draw(data, options);
}
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<div id='chart_div'></div>