Anfuca Anfuca - 5 months ago 41
Javascript Question

JSON and Highcharts

I'm recently new using JSON and i´m not able to draw any kind of charts from Highcharts. Since last Friday i'm reading and reading over the internet, i'm learning a lot, for sure, but right now i'm desperate. I just want a simple bar and a pie!

From my php file, Json_encode prints something this:


I think that is the correct format, string with the "" and int without it.

And this is the code that i'm trying (i'm putting the entire example from some web i found):

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script src=""></script>
<script src=""></script>
<script type="text/javascript" src=""> </script>
<script type="text/javascript">
$(document).ready(function() {
var options = {
chart: {
renderTo: 'container',
type: 'column',
marginRight: 130,
marginBottom: 25
title: {
text: 'Project Requests',
x: -20 //center
subtitle: {
text: '',
x: -20
xAxis: {
categories: []
yAxis: {
title: {
text: 'Requests'
plotLines: [{
value: 0,
width: 1,
color: '#808080'
tooltip: {
formatter: function() {
return '<b>'+ +'</b><br/>'+
this.x +': '+ this.y;
legend: {
layout: 'vertical',
align: 'right',
verticalAlign: 'top',
x: -10,
y: 100,
borderWidth: 0
}, {
series: []

$.getJSON("myphpname.php", function(json) {
options.xAxis.categories = json[0]['data'];
options.series[0] = json[1];
chart = new Highcharts.Chart(options);

<div id="container" style="min-width: 400px; height: 400px; margin: 0 auto"></div>

Thanks for all!!!


The code is ok. The problem was that I was using a free server.

With XAMPP, at the localhost it works perfect!

Thanks for all!