Hi,

Can someone point me to an example where a csv file is used instead of hard 
coding the data for generating a treemap, I am referring to the program in 
https://developers.google.com/chart/interactive/docs/gallery/treemap . 

I am pasting below the program with changes which I have tried to generate 
the treemap using CSV. Unfortunately, although I am able to load the csv 
file, the treemap is not getting generated. Instead I get an error - Failed 
to find row with id "null".

I feel that there is something wrong in the way I am storing the CSV file 
to arrayData. I am investigating further, but, in case, anyone could help 
me, it would really be appreciated.


<html>
  <head>
    <script type="text/javascript" src=
"https://www.gstatic.com/charts/loader.js";></script>
    <script type="text/javascript">
      google.charts.load('current', {'packages':['treemap']});
      google.charts.setOnLoadCallback(drawChart); 
      var arrayData = new Array();
     $.get("tradevolume.csv", function(csvString) {
        // transform the CSV string into a 2-dimensional array
        arrayData = $.csv.toArrays(csvString, {onParseValue: $.csv.hooks.
castToScalar});
      });
      function drawChart() {
        var data = google.visualization.arrayToDataTable(arrayData);
        tree = new google.visualization.TreeMap(document.getElementById(
'chart_div'));

        tree.draw(data, {
          minColor: '#f00',
          midColor: '#ddd',
          maxColor: '#0d0',
          headerHeight: 15,
          fontColor: 'black',
          showScale: true
        });

      }
    </script>
  </head>
  <body>
    <div id="chart_div" style="width: 900px; height: 500px;"></div>
  </body>
</html>

A subset of the data file is given below

['Location', 'Parent', 'Market trade volume (size)', 'Market increase/decrease 
(color)']
['Global',    null,                 0,                               0]
['America',   'Global',             0,                               0]
['Europe',    'Global',             0,                               0]


Thanks

Sachin

-- 
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 https://groups.google.com/group/google-visualization-api.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-visualization-api/f53c5e18-3045-4362-b48c-07c5d363ffc0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to