Pie chart handling of numbers that don't add up to 100

2,654 views
Skip to first unread message

JLB

unread,
Apr 3, 2008, 1:03:15 PM4/3/08
to Google Chart API
Hi again all:

A question. If the numbers provided to Google Chart for generating a
pie chart do not add up to 100, should not the pie chart still be make-
able? Should not the total of all 'slices' always be taken as 'one
hundred percent' of the pie, and the numbers scaled down internally
accordingly?

If you pass it the numbers 100 and 900 instead of 10 and 90, you get:

http://chart.apis.google.com/chart?cht=p&chs=145x145&chd=t:900,100 (a
pie with two equal 50% slices)

instead of:

http://chart.apis.google.com/chart?cht=p&chs=145x145&chd=t:90,10 (a
pie with one 90% slice and one 10% s lice)

The two charts should be identical, should they not?

--JLB

JV

unread,
Apr 4, 2008, 11:41:08 AM4/4/08
to Google Chart API
If you don't define data scaling Goggle Charts assumes that t encoded
values are between 0 and 100. Everything larger then 100 is coded to
the value 100. So in the first example it creates a chart as it were
with two values of 100.

You have the choice of either multiplying all of your values with a
constant such that all new values are <= 100 or add data scaling e.g.
add &chds=0,1000 (the first value has to be 0, the second one large
enough to handle all of your data)

Jessica Blank

unread,
Apr 4, 2008, 4:34:34 PM4/4/08
to google-c...@googlegroups.com
I am somewhat confused as to the purpose of this behaviour. What you're saying is that it 'clips' all values over 100 to 100? Under what circumstances is this sort of behaviour desirable?

PHP's Image_Graph correctly handles this situation, which really doesn't seem that hard, computationally speaking. Actually, it seems trivial. If you're given values of 1000, 100 and 1, the 1000 slice should be 1000/1101 (~90.8%) of the pie, the 100 slice should be 100/1101 (~9.1%) of the pie, and the 1 pie should be 1/1101 of the pie... When would the 'clip to 100' behaviour ever be desired?

Barry Hunter

unread,
Apr 5, 2008, 9:07:27 AM4/5/08
to google-c...@googlegroups.com
The default Text Encoding which you are using is DEFINED has having
the range 0-100 at all times, so values outside that are undefined.
This is is deliberate as having a defined range, helps the API has it
has a known range so doesnt have to guess. With &chd=t:900,100 it
doesnt know that you mean 0-1000 as your range. The encoding system is
common to all graphs, admittedly with pie it could make a more
educated guess, but I beleive that would cause more confusion.

And it saves space, by you rescaling your data to that range it makes
the data smaller, eg, 9000000,10000000,9000000 for example can easily
be represented by 90,100,90 which is far less bytes, if you have a
lots of points this is significant, so the user can use vary arbiraty
scales.

So the 'clip to 100' is not even real behaviour, but rather a
manifastaion of how it works.

However it seems as this seems to frequently cause confusion, and it
will simplify some implementations, as mentioned Google have added a
data-scaling option, so if you explitily tell it your scale you can
use arbitary values.

--
Barry

- www.nearby.org.uk - www.geograph.org.uk -

J. Random Coder

unread,
Apr 5, 2008, 2:57:53 PM4/5/08
to google-c...@googlegroups.com
On Sat, Apr 5, 2008 at 9:07 AM, Barry Hunter <barryb...@googlemail.com> wrote:

The default Text Encoding which you are using is DEFINED has having
the range 0-100 at all times, so values outside that are undefined.
This is is deliberate as having a defined range, helps the API has it
has a known range so doesnt have to guess. With &chd=t:900,100 it
doesnt know that you mean 0-1000 as your range. The encoding system is
common to all graphs, admittedly with pie it could make a more
educated guess, but I beleive that would cause more confusion.

I must admit that I am a bit confused. You believe that passing Google Chart the values of 900 and 100, and getting back a pie with a 90% slice and a 10% slice, will cause *more* confusion than getting back a pie with two 50% slices? How is this so?
 


And it saves space, by you rescaling your data to that range it makes
the data smaller, eg, 9000000,10000000,9000000 for example can easily
be represented by 90,100,90 which is far less bytes, if you have a
lots of points this is significant, so the user can use vary arbiraty
scales.

Well, of course, but real-world data is seldom like this. Real-world data might be something like 'this division has done $53.4 million in profits, this division has done $23.2 million, this division has done $37.2 and this one $7.9". Given that the entire raison d'etre for Google Chart is making charting easy, why should the user be presented with the unpalatable choices of:

1) Pre-converting all of these values to numbers under 100, representing percentages

or

2) Adding them all up and passing the total to the scaling parameter...

Basically, #2 strikes me as users having to provide redundant data. Why should users have to provide what basically amounts to a 'total' value for all of their values provided, when they are most likely already providing all of the values anyways? I can understand a situation where you want the total value represented by the pie to be 1000, and you have only a 150 slice and a 50 slice and the rest is 'empty'... but most situations in which users will utilise this tool will likely not be of that nature.

In other words, if no scaling parameter is provided, the system should assume that the arbitrary values provided by the user add up to 100% of the 'pie'.
 

J. Random Coder

unread,
Apr 5, 2008, 2:59:54 PM4/5/08
to google-c...@googlegroups.com
(Incidentally, this is Jessica, writing from a different email address)
Reply all
Reply to author
Forward
0 new messages