0

What I'm working with

I have data that I want to chart showing the intensity of rainfall over a period of time. The API documentation that I'm getting this data from says the following:

A very rough guide is that a value of 0 in./hr. corresponds to no precipitation, 0.002 in./hr. corresponds to very light precipitation, 0.017 in./hr. corresponds to light precipitation, 0.1 in./hr. corresponds to moderate precipitation, and 0.4 in./hr. corresponds to heavy precipitation.

Therefore, it seems logical to use a log scale for most of the data (otherwise everything less than moderate rain would be imperceptible), but this obviously causes a problem for when there is no rain predicted.

Possible Solution

The answer to this question suggested adding a small amount to the data and modifying the tooltip to match the original data.

Problem

This would work very nicely, but I don't know how to modify just the data that the tooltip of a Google Chart (the charting tool I'm using) references.

The Google Chart help documents here and here describe several possible roles columns from the chart's data table can play, and one of them is to be the HTML that is rendered in the tooltip. However, I was really hoping to not have to rewrite the HTML for that. Is there anyone here that knows an easy way to just modify the data shown in the tooltip?

Community
  • 1
  • 1
tlewis3348
  • 424
  • 2
  • 7
  • 21
  • Evidently, there is some work in progress to create a pseudo-logarithmic scale that allows zero and negative values (see [here](https://groups.google.com/forum/#!topic/google-visualization-api/NR8sQkjCtOA) for more info). It's not currently working properly though. See the linked post for a full explanation as to why that is. – tlewis3348 May 14 '15 at 21:44

1 Answers1

1

The second link you provide gives you the easiest way to modify your tooltip content, Link. Just add another column like dataTable.addColumn({type: 'string', role: 'tooltip'});and then provide your own tooltip, like looping through all your rows and checking for zero values and replacing the tooltips where needed.

Henrik Aronsson
  • 1,383
  • 9
  • 17
  • That's not terrible, but it's also not great either. It's practically impossible to get the tooltips to be formatted like the default. All I want to do is change the value that shows up in the tooltip to be something other than what it is in the chart. – tlewis3348 May 18 '15 at 10:34
  • Yes, I see your problem with this, and I agree that the tooltips should share layout through the whole chart. Have you tried with creating your own tooltip as they show in the example you linked? It's not very hard, and you can get the result just as you want. I've made a fiddle, [have a look](http://jsfiddle.net/atgb7pd9/4/). – Henrik Aronsson May 18 '15 at 11:14
  • Yeah, it looks like that's the closest I can get for the time being, but it's still an awkward half-solution at best since it doesn't quite look the same. I'll give you an upvote though. – tlewis3348 May 18 '15 at 14:57