Stacked Column Chart- Displaying a line if count is zero

195 views
Skip to first unread message

virendra chaudhary

unread,
Aug 9, 2016, 5:12:58 AM8/9/16
to Google Visualization API
I want to create Stacked Column Chart which should not display anything related to a entity whose count is zero.

I am using below html code. It is displaying a red line on top of green bar even if count is zero for the entity related to red(Failed). I want to remove this line.

Please help me.

<html>
  <head>
      <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>  
   <script type="text/javascript">
      google.charts.load('current', {packages: ['corechart', 'bar']});
google.charts.setOnLoadCallback(drawStacked);

function drawStacked() {
     var data = google.visualization.arrayToDataTable([
        ['Genre','Passed', 'Failed',  { role: 'annotation' } ],
        ['DashBoard', 10, 0, ''],
        
      ]);

      var options = {
        width: 600,
        height: 400,
        legend: { position: 'top', maxLines: 3 },
        bar: { groupWidth: '75%' },
colors:["green","red","black"],
        isStacked: true
      };

      var chart = new google.visualization.ColumnChart(document.getElementById('chart_div'));
      chart.draw(data, options);
    }
    </script>
  </head>
  <body>
    <div id="chart_div"></div>
  </body>
</html>



Many Thanks!

Daniel LaLiberte

unread,
Aug 9, 2016, 10:04:25 AM8/9/16
to Google Visualization API
Have you tried using a null value instead of 0?  

--
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 google-visualization-api+unsub...@googlegroups.com.
To post to this group, send email to google-visualization-api@googlegroups.com.
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/098b753c-adbd-4caf-a30f-d6b5e5b38b51%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

virendra chaudhary

unread,
Aug 9, 2016, 10:28:44 AM8/9/16
to Google Visualization API
Yes. I have tried null and blank but It is giving me error "All series on a given axis must be of the same data type"
To post to this group, send email to google-visua...@googlegroups.com.



--

Daniel LaLiberte

unread,
Aug 9, 2016, 11:48:31 AM8/9/16
to Google Visualization API
The type inferencing might have a problem if you use arrayToDataTable and the first rows contain nulls.  Not sure about that.  Try setting up your DataTable by explicitly typing the columns instead, by calling addColumn() for each column followed by addRows().  Hope that helps.



To unsubscribe from this group and stop receiving emails from it, send an email to google-visualization-api+unsubscr...@googlegroups.com.



--

--
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 google-visualization-api+unsub...@googlegroups.com.
To post to this group, send email to google-visualization-api@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--

virendra chaudhary

unread,
Aug 10, 2016, 5:31:55 AM8/10/16
to Google Visualization API
Thank You. It worked.
To unsubscribe from this group and stop receiving emails from it, send an email to google-visualization-api+unsub...@googlegroups.com.



--

--
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 google-visualization-api+unsub...@googlegroups.com.
To post to this group, send email to google-visua...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-visualization-api.



--
Reply all
Reply to author
Forward
0 new messages