I have a problem with the Gauge chart

« Back to message list

Enter your email address to get email updates on this topic. You can stop receiving updates by clicking the link in the update email messages.

Posted by David Cook on 20th June 2017

I tried to enter this into the forum, but it gives a CAPTCHA error though no CAPTCHA is ever displayed.

Anyway, here is my question - it concerns RGraph.Gauge...

I'm creating a 'Gauge designer' (using RGraph.Gauge) which lets the user diddle all the options.

The textFont option seems to work well when textAccessible is false (CANVAS mode), but when textAccessible is true (DOM mode), setting textFont is ignored (uses what was set in the original options block).

I'm setting the font using: gauge.set({ textFont: 'somefonttheuserselected' });

Even putting code directly in my event, e.g.: gauge.set({ textFont: 'Courier' });
...fails if it is in DOM mode... but succeeds if it is in Canvas mode.

Again, this is for Gauge - I have not tested this on other chart types.

Any suggestions would be appreciated!
Posted by Richard on 20th June 2017

Try clearing the text node cache before you redraw the chart:


Posted by David Cook on 20th June 2017
Thanks Richard:

I added the RGraph.text2.domNodeCache.reset(); call... and indeed it worked such that I can now change the font in DOM as well as Canvas mode.

I noted one thing though... I am currently just calling that each time I make a change, and upon successive calls I get this Alert:

RGraph.text2.domNodeCache.reset is not a function. (In 'RGraph.text2.domNodeCache.reset()', 'RGraph.text2.domNodeCache.reset' is undefined)

So... it works the first time. I wrapped it in a 'try/catch' so it avoids the alert - but is that routine something I should only call once (eg., perhaps after I create the initial instance of the Gauge)?

It seems that calling the .reset() routine works (eg., it allows fonts to be changed for both DOM and Canvas) - and that I should only ever call it once. Is this correct?
Posted by Richard on 20th June 2017
Hi there,

Well that function IIRC is created when you add text - so maybe check to see if the function exists before trying to call it:

if (RGraph.text2.domNodeCache && typeof RGraph.text2.domNodeCache.reset === 'function') {

Posted by David Cook on 20th June 2017
Worked like a charm! Thanks once again!

Add a reply

« Back to message list