create a pie chart without percent

382 views
Skip to first unread message

Jose Miguel Ramírez Escobedo

unread,
Aug 2, 2012, 1:45:02 PM8/2/12
to google-visua...@googlegroups.com
hi i read in the documentation for this chart type, and i saw that when i passed the values in the datatable google take this values and show the percentage in the pieces of the chart and when you hover a piece you can see the percent and the value you pass, so i supose that google calculate the percentage, welll but what i want to do is to pass a value to the datatable and this can be showed in the pieces(and not a percent) and when i hover show this value and if is posible a second value(this second  i don`t know if can pass it such another value or a parameter such a label) but i don`t want percentage neither shown in the pieces nor when i hover a piece, thank you.

asgallant

unread,
Aug 3, 2012, 1:32:28 AM8/3/12
to google-visua...@googlegroups.com
Set the "pieSliceText" chart option to "value" to show the value of the pie slice instead of the percentage.  You can use formatters on a dataTable column or manually set the formatted value of dataTable cells to change what exactly is displayed.

Jose Miguel Ramírez Escobedo

unread,
Aug 3, 2012, 2:45:43 PM8/3/12
to google-visua...@googlegroups.com
thank you, the pieSliceText works, but i`m sorry, i couldn´t solve the second situation, how can i show information diferent from the default information that the chart displayed when hover in a piece, you said that i can do this when i built the datatable with the addColumn or addRow but i didn`t how to do it if you have an example it would be great, thank you

asgallant

unread,
Aug 3, 2012, 10:39:32 PM8/3/12
to google-visua...@googlegroups.com
When adding rows, you can manually format by passing an object with "v" and "f" parameters - "v" is the actual value and "f" is the formatted value:

data.addRows([
    ['Foo'{v5f'5 Widgets'}],
    ['Bar'{v7f'7 Gadgets'}],
    ['Bat'{v3f'3 Gizmos'}]
]);

If you want to format all of the cells in a column in the same way, you can use one of the formatters.  Like this:

// format the second column in the data table
// adding "Widgets" to each value
var formatter new google.visualization.NumberFormat({
    suffix' Widgets'
});
formatter.format(data1);

Jose Miguel Ramírez Escobedo

unread,
Aug 7, 2012, 6:44:14 PM8/7/12
to google-visua...@googlegroups.com
hi, ok thank you for the answer, but i think that i haven´t explained well, in my datatable with two columns i pass two values like this (1,234) the first one is my key the second one my real value, i find a property:
tooltip.text which display information when hovers over the piece of chart, so that i want to display when hover is other value, so for instance my 234 value is display in the piece but another value when hover the piece, and this tooltip.text just accept: both,value and percentage but i would like to know if there is a way to display diferent information that the value, percentage or both, thank you.

asgallant

unread,
Aug 7, 2012, 9:33:44 PM8/7/12
to google-visua...@googlegroups.com
Use the formatted values as I posted above.  The string can be anything you want (values, percentages, text, whatever).

If you want to have the tooltip values calculated for you, then you can use a DataView with a calculated column that returns the tooltip text you want, ie:

// use column 1 for the value to determine pie slice size
// and use column 2 for the tooltip text 
data.addRows([
    ['Foo'5, 23],
    ['Bar'7, 47],
    ['Baz'3, 89]
]);

var view new google.visualization.DataView(data);
view.setColumns([0{
    labeldata.getColumnLabel(1),
    type'number',
    calcfunction (dtrow{
               // use column 1 for the value to determine pie slice size
        var value dt.getValue(row1);
               // use column 2 for the value to put in the tooltip
        var formattedValue dt.getValue(row2);
        return {vvaluefformattedValue};
    }
}]);

Is that closer to what you want?

Jose Miguel Ramírez Escobedo

unread,
Aug 8, 2012, 11:21:05 AM8/8/12
to google-visua...@googlegroups.com
ok thank you, i could solve it
Reply all
Reply to author
Forward
0 new messages