Google Chart do not show Last value in PieChart

18 views
Skip to first unread message

Inzimam Tariq

unread,
Oct 10, 2017, 8:12:07 AM10/10/17
to Google Visualization API
Hi,
I'm using twig file and copied code from google site. When I tried adding hard coded values its perfect But I have to show add values in pie chart So, When I try dynamically It shows all but the last value do not show up in chart. Also legend of the chart shows that value as "other" not the name & value of that.
I tried with 
data = new google.visualization.DataTable();
and also with 
var data = google.visualization.arrayToDataTable([]);
methods But the result is same. Can Anybody help me on this?
Here is how I'm adding values to chart
Method 1. var data = new google.visualization.DataTable(); 
data.addColumn('string', 'Store'); 
data.addColumn('number', 'Type'); 
data.addRows([ 
        {% for category in categories %} 
        {% if loop.last %} 
             ['{{ category.name }}', {{ category.survey }}] 
        {% else %}['{{ category.name }}', {{ category.survey }}], 
       {% endif %} 
       {% endfor %} 
]);
Method 2. var data = google.visualization.arrayToDataTable([
         
['Task', 'Hours per Day'],
         
{% for category in categories %}
          ['{{ category.name }}', {{ category.survey }}], 
       {% endfor %} 
        ]);

Inzimam Tariq

unread,
Oct 10, 2017, 9:38:12 AM10/10/17
to Google Visualization API
There is no problem till we add string data dynamically But when we add integer values to second column here problem comes in.

Inzimam Tariq

unread,
Oct 11, 2017, 6:11:16 AM10/11/17
to Google Visualization API
Do anyone reply here?





On Tuesday, October 10, 2017 at 5:12:07 PM UTC+5, Inzimam Tariq wrote:
Reply all
Reply to author
Forward
0 new messages