Re: Dealing with null and zero values - is it possible?

144 views
Skip to first unread message

asgallant

unread,
Oct 17, 2012, 11:55:38 AM10/17/12
to google-visua...@googlegroups.com
The "built in" way to distinguish nulls from 0's is to set the "focusTarget" option to "category", which will put all data points at a given axis value into the tooltip.  0's will show up in the tooltip, but nulls won't.

You could also change the axis label for a row with a null data point to indicate that the data is null, but that wouldn't distinguish between columns if one is null and the other isn't.

If neither of those work for you, what would you like to happen when there is a null vs a 0?

On Wednesday, October 17, 2012 6:59:40 AM UTC-4, Alan Sparkes wrote:
Have interesting situation where some fo data set contains zero and null. Each has a specific meaning. Zero means "no money spent". NUll means "we dont have data".

Currently when we hit this in our data display we get a meaningless/at best ambiguous chart like the example attached. THe code is below.

What would be useful is to be able to add a text label to the bar or column which would enable us to describe the data meaning as above.

IS this possible? I cant find an example of null handling with zeros that gives a clue.

Any pointers from more seasoned GV API'ers most welcome :) 

// Load the Visualization API and the piechart package.
  google.load('visualization', '1.0', {'packages':['corechart']});

  // Set a callback to run when the Google Visualization API is loaded.
  google.setOnLoadCallback(drawChart);

  // Callback that creates and populates a data table,
  // instantiates the pie chart, passes in the data and
  // draws it.
  function drawChart() {

// Create the data table.
var data = new google.visualization.DataTable();

data.addColumn('string', 'Year(Type)');
data.addColumn('number', 'Recurrent'); 
data.addColumn('number', 'Capital'); 
data.addRows([['2012(Planned)',0,0]
        ]);

// Set chart options
        var options = {
height: 450,
width: 550,
focusTarget: 'category',
vAxis: {title: "% GDP"},
        hAxis: {title: ""},
isStacked: true, backgroundColor: '#F6F6F6'
        };

// Instantiate and draw our chart, passing in some options.
var chart = new google.visualization.ColumnChart(document.getElementById('chart_div'));
chart.draw(data, options);
  }

Alan Sparkes

unread,
Oct 22, 2012, 6:35:02 AM10/22/12
to google-visua...@googlegroups.com
Thanks for reply - ideally i'd like to be able to put a text label on the horizontal axis at the point of null or zero to the effect of 'zero spending' / 'no data' on evrry column where relevant.
Any visual way that this can be demonstrated is fine but we dont want to 'hide' this info in the tool tip if avoidable.

If we did look at the tool tip route can't the tooltip be reformatted to distinguish values of null and zero?

The main goal is to communicate visually whats been spent eg 2mill or zero , and where there is no data available - at a glance .

asgallant

unread,
Oct 22, 2012, 10:50:50 AM10/22/12
to google-visua...@googlegroups.com
The way to add tags to the axis like that is to use annotations; unfortunately, they are not available on ColumnCharts.
Reply all
Reply to author
Forward
0 new messages