You cannot change the legend to show the "sentence".
After some experimentation, I found that there is undocumented support for
changing the tooltip contents. I expect that this will be changed in the
future, as it doesn't behave the same way as custom tooltips in other
charts, but for now this should work. You need to rearrange your three
columns in this order: "Country", "Value", "Sentence", and set the "role"
property of the "Sentence" column to "tooltip". If you are using the
DataTable#addColumns method, it would be like this:
data.addColumn('string', 'Country');
data.addColumn('number', 'Value');
data.addColumn({type: 'string', label: 'Sentence', role: 'tooltip'});
or if using the arrayToDataTable method:
['Country', 'Value', {type: 'string', label: 'Sentence', role: 'tooltip'}]
On Monday, April 28, 2014 12:27:46 PM UTC-4, Wendy Bardsley wrote:
>
> Hi Andrew,
> This works great, except the 2nd line of the tooltip (sentence) starts
> with a space-colon-space, and it's bolded. Also the legend is still showing
> the numbers. Can I get the legend to show the sentence instead? Can you
> point to some documentation about the tooltip formatting (Showing a colon
> is the most important thing I want to get rid of, or move to the row above)?
> Thanks so much,
> Wendy
>
> On Friday, April 25, 2014 3:00:55 PM UTC-7, Andrew Gallant wrote:
>>
>> What you want to do is use the "Sentence" column as the formatted value
>> of the "Value" column. You can use a DataView to accomplish this:
>>
>> // create a DataView based on the DataTable "data"
>> var view = new google.visualization.DataView(data);
>> view.setColumns([0, {
>> type: 'number',
>> calc: function (dt, row) {
>> return {v: dt.getValue(row, 2), f: dt.getValue(row, 1)};
>> }
>> }]);
>>
>> then draw the chart using the DataView instead of the DataTable.
>>
>> On Friday, April 25, 2014 5:23:03 PM UTC-4, Wendy Bardsley wrote:
>>>
>>> Hello,
>>> I've created a map that has 3 columns of Data: Country,
>>> Sentence(string), Value.
>>> I only want to use the value to draw the colors on the map, but would
>>> like to omit it from the tooltip and just display Country(name) and
>>> Sentence.
>>> After adding the 2nd string, it omits the Country Name on the tooltip,
>>> bolds the sentence and puts the value on a newline with Value: 2 (for
>>> example, number is bolded).
>>> How can I format the tooltip so it shows the country name bolded on the
>>> first line, sentence on the 2nd line (not bold), and omits the value for
>>> the tooltip, while using it to draw the map?
>>> The value has no intrinsic meaning, it doesn't relate to a unit, just to
>>> degree of severity.
>>> Thanks for any help, or pointing me to documentation about adding
>>> columns,
>>> Wendy
>>>
>>>
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-visualization-api.
For more options, visit https://groups.google.com/d/optout.