Setting Chart Tooltip is throwing a reference error since update last night

Over the past few days I developed a script to use with charts to update their tooltip with additional data using the “Before Render Snippet” option on a chart

This was working and demo’d yesterday, however I came in this morning to a message from my boss saying none of the charts I modified are working.

I’m now getting this error “Uncaught TypeError: Cannot set property ‘formatter’ of undefined”

Inspecting the chart object I see the Tooltip node is no longer exposed, was this changed? 

I also checked the installed package and I can see the following

“Modified By Skuid, 18/02/2015 02:02” so it looks like a new minor version of the package was pushed last night? 

Below is a simpler version of my code that causes the same error:

var chart = arguments[0]<br>chart.tooltip.formatter = function(){<br> s = 'my test string';<br> return s;<br>}<br>&nbsp;



I’ll ask “the Charts man” (J Tingle) to follow up with more details here, but my understanding is that with this point release, Skuid’s default tooltip formatting settings for charts were moved into the plotOptions property for each Chart type (e.g. chartObj.plotOptions.funnel.tooltip) and into Series-specific tooltip properties (e.g. chartObj.series[0].tooltip), as appropriate for settings which should be global to the chart type (such as the pointFormatter for the Funnel chart) and settings which should be series-specific, since each series points can be on different fields (such as the number of decimals, prefix, and suffix, which will be different from field to field) This would account for the tooltip property having disappeared from the chart object in your before render snippet.

That being said, you should still be able to set a global tooltip property, but to future-proof yourself from any changes Skuid may make to our default Chart configurations for a particular Chart type, I would highly recommend that you always check to see if a given property, such as tooltip, is defined before assigning properties to it, like this:


var chart = arguments[0];<br><b>// Override the tooltip globally, for all series<br></b><b>// First, make sure tooltip has been defined,<br></b><b>// and if not, define it<br></b><b>var tooltip = chart.tooltip;<br></b><b>if (!tooltip) tooltip = chart.tooltip = {};</b><br>tooltip.formatter = function(){<br>&nbsp; &nbsp; s = 'my test string';<br>&nbsp; &nbsp; return s;<br>};




Charts man, here! Zach got the solution: chart.tooltip isn’t defined. Previously, chart.tooltip was always defined, even if it was empty, so the snippet worked. With this latest release, we only define it when it’s being used (no use in sending extra chart configuration off to the charting library). Does this get you back up and running?

Thanks, will have a look at this now. 

Yep, back up and running with that solution, appreciate the quick turnaround on a response.