histogram tooltip number format

162 views
Skip to first unread message

dunba...@gmail.com

unread,
Feb 10, 2016, 10:16:46 AM2/10/16
to Google Visualization API
Hi, 

I like the Histogram chart but one thing is needling me, which is that I can't seem to have number formatted tooltips. In the classic charts like ColumnChart, it's simply a matter of using the number formatter, for example: 

var formatter = new google.visualization.NumberFormat({pattern:'###.# %'});
formatter
.format(data,1);
 
However, when I do this for Histogram, the formatting doesn't appear in the tooltip like it does in other charts. Any clues what I am doing wrong, or is this a bug? 

Thanks, 
Nick  

Daniel LaLiberte

unread,
Feb 10, 2016, 11:04:49 AM2/10/16
to Google Visualization API
Hi Nick,

Sounds like you found a bug.  We should be using the formatted representation of the value in the tooltips, but I see a place in the code where the unformatted value is used, so this might be easy to fix, if I have time to get around to it.

--
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 google-visualizati...@googlegroups.com.
To post to this group, send email to google-visua...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-visualization-api.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-visualization-api/64e9854f-3c42-426b-90fa-ae9de051ed9f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Nick Dunbar

unread,
Feb 10, 2016, 11:12:22 AM2/10/16
to google-visua...@googlegroups.com
Hi Daniel, 

Thanks for getting back to me so quickly. Please try and fix this - if you do it will be perfect. 

Well almost, if were it possible to fit Normal or Lognormal curves to the histogram (analogous to trendlines) that would be amazing. 

Nick 

--
You received this message because you are subscribed to a topic in the Google Groups "Google Visualization API" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-visualization-api/LQg2V8dnAcU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-visualizati...@googlegroups.com.

To post to this group, send email to google-visua...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-visualization-api.

Daniel LaLiberte

unread,
Feb 10, 2016, 11:29:33 AM2/10/16
to Google Visualization API
I think I have a fix for the lack of formatting now.  Should show up in the next release.

Can't help you with log scale used with histogram, or even combining the histogram with other charts.  The current histogram implementation is not designed with these things in mind, but we are thinking of a new design that would allow much more.  The only workaround for now is to implement your own histogram calculations.


For more options, visit https://groups.google.com/d/optout.

Nick Dunbar

unread,
Feb 10, 2016, 11:48:25 AM2/10/16
to google-visua...@googlegroups.com
OK, thanks. When are you planning the next release? 

Daniel LaLiberte

unread,
Feb 10, 2016, 12:04:31 PM2/10/16
to Google Visualization API
We'd be done by now, but I'm trying to stabilize a new feature regarding bar widths, which is raising entanglements with other features.   Hopefully done this week, so I should start rolling out the new release next week.


For more options, visit https://groups.google.com/d/optout.

Nick Dunbar

unread,
Feb 10, 2016, 12:19:13 PM2/10/16
to google-visua...@googlegroups.com
Great. In the gstatic loader, do I need to change from '43' to pick up these changes? 

Daniel LaLiberte

unread,
Feb 10, 2016, 12:59:33 PM2/10/16
to Google Visualization API
You'll need to be loading '44' at first, which is available now, but not yet updated for this fix.  Then load 'upcoming' when we start the release cycle, if you want the latest.  Then back to '44' if you want to stick with that.


For more options, visit https://groups.google.com/d/optout.

Nick Dunbar

unread,
Feb 11, 2016, 9:57:01 AM2/11/16
to google-visua...@googlegroups.com
Hi Dan, something weird came up when I swtiched from version '43' to '44'. The histogram algorithm appears to be broken in '44' for multiple series. It works fine in '43' so you might want to check that. Please keep '43' frozen in the meantime. 
Regards, 
Nick 


Daniel LaLiberte

unread,
Feb 11, 2016, 10:20:32 AM2/11/16
to Google Visualization API
Nick,

Thanks for reporting that.  Indeed, histogram is broken in v44 for multiple series.  I'm glad you caught that.

Version 43 will remain frozen indefinitely as is, barring security concerns.


For more options, visit https://groups.google.com/d/optout.

Daniel LaLiberte

unread,
Feb 11, 2016, 10:33:03 AM2/11/16
to Google Visualization API
I discovered that for histogram, if you have the bar.variableWidth option set, it will mess things up.  Could that be what you are seeing?  If not, could you give me the details of your chart and options, since I am not seeing a problem after all, other than with the bar.variableWidth option.

Nick Dunbar

unread,
Feb 11, 2016, 11:10:18 AM2/11/16
to google-visua...@googlegroups.com
I'm not using that option - here they are below. My data table has about 10 or 11 separate series in it, and about 500-600 points in total. 

var chart = new google.visualization.ChartWrapper({
        chartType: 'Histogram',
        containerId: 'chart_div',
        dataTable: histogramTable,
options: {
            title: 'Title',
            width: 900,
            height: 500,
   focusTarget: 'datum',
   tooltip: {isHtml: 'true'},
   backgroundColor: 'transparent',
   interpolateNulls: false,
   isStacked: true,
   theme: 'material',
animation:{
        duration: 500,
        easing: 'out'
      },
hAxis: {format: '##.#%', textStyle: {fontSize: 12}},
histogram: { lastBucketPercentile: 5 }
}
        });    


Daniel LaLiberte

unread,
Feb 11, 2016, 11:28:41 AM2/11/16
to Google Visualization API
The theme:'material' option might be causing a problem, depending on what you are seeing.  It modifies the bar.groupWidth, which now does affect the Histogram whereas it used to be ignored for histogram.  You should be able override that behavior by specifying bar.group.gap: 1  but that appears to not be working as expected, so I do need to fix that.  Or maybe we should change the theme:'material' behavior to leave the bar.groupWidth alone for histogram.



For more options, visit https://groups.google.com/d/optout.

Nick Dunbar

unread,
Feb 11, 2016, 11:39:42 AM2/11/16
to google-visua...@googlegroups.com
All the bars appear stacked at the extreme left and right side of the chart, and disabling 'material' makes no difference. The exact same options work fine in version '43'. 

Daniel LaLiberte

unread,
Feb 11, 2016, 12:19:22 PM2/11/16
to Google Visualization API
Where your data is might make a difference as well, especially if the problem appears to be how the buckets are calculated or filled rather than how things are drawn.  I made a bunch of changes trying to deal with precision calculations of bucket boundaries, so I may need to see your actual data to figure this out.    Could you send me data in private email, or post an example that uses some smaller safe subset of data that still shows the problem?  Thanks.


For more options, visit https://groups.google.com/d/optout.

Nick Dunbar

unread,
Feb 15, 2016, 11:28:40 AM2/15/16
to google-visua...@googlegroups.com
Hi Dan, 
I don't know how to extract the data from the dataTable buried in my code into a form that I can send you or is usable as a safe subset. 

But you can generate something like it using this code: 

var histogramTable = new google.visualization.DataTable();
 histogramTable.addColumn('string', 'name');
 for (var i=0; i<11; i++){ 
 histogramTable.addColumn('number', i); 
}
 for (var i=0; i<500; i++) {
histogramTable.addRow(['',,,,,,,,,,,]);
}
for (var i=0; i<500; i++) {
var index = Math.floor((Math.random() * 11) + 1);
    histogramTable.setValue(i,index,Math.exp(-pow((Math.random()-0.5),2));
       }





Daniel LaLiberte

unread,
Feb 16, 2016, 2:03:23 PM2/16/16
to Google Visualization API
Your undefined values are the cause of values being stacked on the left, since they are treated like 0 in this case.   There is logic to skip null or undefined values, especially if interpolateNulls is false, but there seems to have been some problem with it.    I updated v44, however, and now it seems to work OK.   See this example using your data: https://jsfiddle.net/dlaliberte/bofqmmd4/



For more options, visit https://groups.google.com/d/optout.

Nick Dunbar

unread,
Feb 17, 2016, 7:44:21 AM2/17/16
to google-visua...@googlegroups.com
Thanks Dan. '44' seems to work ok now with my original code, including the number formats. 

Daniel LaLiberte

unread,
Feb 17, 2016, 8:42:10 AM2/17/16
to Google Visualization API
Glad to hear it is working for you now.  


For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages