Not able to display highcharts in php -
i have started use highcharts in 1 of implementation wasn't able render charts following codes. miss out anything?
<html xmlns="http://www.w3.org/1999/xhtml" height="100%"> <head> <script type="text/javascript" src="js/jquery-latest.js"></script> <script type="text/javascript" src="js/highcharts.js"></script> <script type="text/javascript"> $(document).ready(function() { var chart; var options = { chart: { renderto: 'container', type: 'column' }, title: { text: 'testing' }, legend: { layout: 'vertical', floating: true, backgroundcolor: '#ffffff', align: 'right' verticalalign: 'top', y: 60, x: -60 }, tooltip: { formatter: function() { return this.x + ': ' + this.y; } }, series: [{ type: 'column', data: [] }] } $.getjson("data.php", function(json) { options.series[0].data = json; chart = new highcharts.chart(options); }); }); </script> </head> <body> <div id="container" style="min-width: 400px; height: 400px; margin: 0 auto"></div> </body> </html>
the output of data file this:
[["a",13],["b",3],["c",7]]
you have forgot comma in code, change:
backgroundcolor: '#ffffff', align: 'right' verticalalign: 'top',
to:
backgroundcolor: '#ffffff', align: 'right', verticalalign: 'top',
here working example of code: http://jsfiddle.net/hcjcr/
tip: learn how use debugger in chrome or firebug in firefox. spot these errors , others in second. it's worth time.
Comments
Post a Comment