Dear all,

I'm currently trying to color the column chart via JSON.
In the end my JSON looks like this:
{ "cols":[ {"id":"","label":"Rang","type":"number"}, {"id":"","label":"Land"
,"type":"string"}, {"id":"","label":"Index","type":"number"}, {"id":"",
"label":"Stand","type":"string"}, {"id":"","label":"Farbe","type":"string",
"role":"style"}], "rows": [{"c":[ {"v":1,"f":null}, {"v":"Japan","f":null}, 
{"v":-49.25,"f":null}, {"v":"Q3 | 2013","f":null},{"v":#777777,"f":null}]}, 
{"c":[ {"v":2,"f":null}, {"v":"Ungarn","f":null}, {"v":-19.8,"f":null}, 
{"v":"Q4 | 2013","f":null},{"v":#777777,"f":null}]}, {"c":[ 
{"v":3,"f":null}, {"v":"Deutschland","f":null}, {"v":-13.75,"f":null}, 
{"v":"Q4 | 2013","f":null},{"v":#777777,"f":null}]}, {"c":[ 
{"v":4,"f":null}, {"v":"Irland","f":null}, {"v":-12.63,"f":null}, {"v":"Q1 
| 2014","f":null},{"v":#777777,"f":null}]}, {"c":[ {"v":5,"f":null}, 
{"v":"Portugal","f":null}, {"v":-11.93,"f":null}, {"v":"Q1 | 
2014","f":null},{"v":#777777,"f":null}]}, {"c":[ {"v":6,"f":null}, 
{"v":"Slowenien","f":null}, {"v":-11.64,"f":null}, {"v":"Q1 | 
2014","f":null},{"v":#777777,"f":null}]}, {"c":[ {"v":7,"f":null}, 
{"v":"Griechenland","f":null}, {"v":-10.12,"f":null}, {"v":"Q4 | 
2013","f":null},{"v":#777777,"f":null}]}, {"c":[ {"v":8,"f":null}, 
{"v":"Island","f":null}, {"v":-5.63,"f":null}, {"v":"Q1 | 
2014","f":null},{"v":#777777,"f":null}]}, {"c":[ {"v":9,"f":null}, 
{"v":"Estland","f":null}, {"v":-5.24,"f":null}, {"v":"Q4 | 
2013","f":null},{"v":#777777,"f":null}]}, {"c":[ {"v":10,"f":null}, 
{"v":"Tschechische Republik","f":null}, {"v":-5.17,"f":null}, {"v":"Q4 | 
2013","f":null},{"v":#777777,"f":null}]}, {"c":[ {"v":11,"f":null}, 
{"v":"USA","f":null}, {"v":1.92,"f":null}, {"v":"Q4 | 
2013","f":null},{"v":#08088A,"f":null}]}, {"c":[ {"v":12,"f":null}, 
{"v":"Korea","f":null}, {"v":2.52,"f":null}, {"v":"Q1 | 
2014","f":null},{"v":#777777,"f":null}]}, {"c":[ {"v":13,"f":null}, 
{"v":"Italien","f":null}, {"v":3.5,"f":null}, {"v":"Q4 | 
2013","f":null},{"v":#777777,"f":null}]}, {"c":[ {"v":14,"f":null}, 
{"v":"Niederlande","f":null}, {"v":4.7,"f":null}, {"v":"Q1 | 
2014","f":null},{"v":#777777,"f":null}]}, {"c":[ {"v":15,"f":null}, 
{"v":"Dänemark","f":null}, {"v":6.54,"f":null}, {"v":"Q4 | 
2013","f":null},{"v":#777777,"f":null}]}, {"c":[ {"v":16,"f":null}, 
{"v":"Mexiko","f":null}, {"v":6.88,"f":null}, {"v":"Q1 | 
2014","f":null},{"v":#777777,"f":null}]}, {"c":[ {"v":17,"f":null}, 
{"v":"Türkei","f":null}, {"v":9.32,"f":null}, {"v":"Q4 | 
2013","f":null},{"v":#777777,"f":null}]}, {"c":[ {"v":18,"f":null}, 
{"v":"Spanien","f":null}, {"v":10.62,"f":null}, {"v":"Q4 | 
2013","f":null},{"v":#777777,"f":null}]}, {"c":[ {"v":19,"f":null}, 
{"v":"Israel","f":null}, {"v":10.67,"f":null}, {"v":"Q4 | 
2013","f":null},{"v":#777777,"f":null}]}, {"c":[ {"v":20,"f":null}, 
{"v":"Schweiz","f":null}, {"v":11.45,"f":null}, {"v":"Q1 | 
2014","f":null},{"v":#777777,"f":null}]}, {"c":[ {"v":21,"f":null}, 
{"v":"Slowakei","f":null}, {"v":14.1,"f":null}, {"v":"Q1 | 
2014","f":null},{"v":#777777,"f":null}]}, {"c":[ {"v":22,"f":null}, 
{"v":"Österreich","f":null}, {"v":15.36,"f":null}, {"v":"Q1 | 
2014","f":null},{"v":#777777,"f":null}]}, {"c":[ {"v":23,"f":null}, 
{"v":"Finnland","f":null}, {"v":17.95,"f":null}, {"v":"Q1 | 
2014","f":null},{"v":#777777,"f":null}]}, {"c":[ {"v":24,"f":null}, 
{"v":"Luxemburg","f":null}, {"v":18.51,"f":null}, {"v":"Q1 | 
2014","f":null},{"v":#777777,"f":null}]}, {"c":[ {"v":25,"f":null}, 
{"v":"Frankreich","f":null}, {"v":28.16,"f":null}, {"v":"Q4 | 
2013","f":null},{"v":#777777,"f":null}]}, {"c":[ {"v":26,"f":null}, 
{"v":"Grossbritanien","f":null}, {"v":30.44,"f":null}, {"v":"Q4 | 
2013","f":null},{"v":#777777,"f":null}]}, {"c":[ {"v":27,"f":null}, 
{"v":"Neuseeland","f":null}, {"v":31.41,"f":null}, {"v":"Q4 | 
2013","f":null},{"v":#777777,"f":null}]}, {"c":[ {"v":28,"f":null}, 
{"v":"Schweden","f":null}, {"v":32.05,"f":null}, {"v":"Q1 | 
2014","f":null},{"v":#777777,"f":null}]}, {"c":[ {"v":29,"f":null}, 
{"v":"Australien","f":null}, {"v":36.02,"f":null}, {"v":"Q1 | 
2014","f":null},{"v":#777777,"f":null}]}, {"c":[ {"v":30,"f":null}, 
{"v":"Belgien","f":null}, {"v":38.07,"f":null}, {"v":"Q4 | 
2013","f":null},{"v":#777777,"f":null}]}, {"c":[ {"v":31,"f":null}, 
{"v":"Kanada","f":null}, {"v":42.07,"f":null}, {"v":"Q1 | 
2014","f":null},{"v":#777777,"f":null}]}, {"c":[ {"v":32,"f":null}, 
{"v":"Norwegen","f":null}, {"v":50.26,"f":null}, {"v":"Q1 | 
2014","f":null},{"v":#777777,"f":null}]}Code hier eingeben...


And my Code to draw the chart is this:
<source>
<html>
  <head>
  <!-- Google laden -->
<script type="text/javascript"
src='https://www.google.com/jsapi?autoload=
{
"modules":
[{
"name":"visualization",
"version":"1"
}]
}'>
</script>

<script type="text/javascript">

google.setOnLoadCallback(drawVisualization);
 // Daten
var jsonData = jQuery.ajax({
       url: "charting/Test.php?country=2", //2=USA
       dataType:"json",
       async: false
     }).responseText;

// zeichnen
function drawVisualization() {
var wrap = new google.visualization.ChartWrapper
({
    'chartType':'ColumnChart',
    'dataTable':new google.visualization.DataTable(jsonData),
    'containerId':'Line_div',
'options':{
'chartArea': {'width': '95%'}, 
'legend': {position: 'bottom', alignment: 'center'}
                               
},
     });
     wrap.draw();
 }
 
</script> 
   
  </head>
  <body>
 
  <div id="Line_div" style="height: 300px;"></div>
  
  
  
  </body>
</html>
</source>

The error I get ist "Invalid JSON string"

Can you tell me what I am doing wrong?

Thank you very much in advance for your help.

I'm looking forward to your feedback

Best
Manuel


-- 
You received this message because you are subscribed to the Google Groups 
"Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-visualization-api.
For more options, visit https://groups.google.com/d/optout.

Reply via email to