I'm trying to make a Gauge like a compass

« 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 Anton on 22nd October 2017
Hi Richard,
I'm trying to make a gauge to be more like a compass of sorts. Here is the code:

     var odo = new RGraph.Gauge({
    anglesStart: -RGraph.HALFPI-RGraph.PI,
    anglesEnd: RGraph.HALFPI,
    valueText: 'true',
    valueTextYPos: -1,
    valueTextDecimals: 1,
    labelsSpecific: [['-100',-100],['-45',-45],['-15',-15],['0',0],['15',15],['45',45],['100',100],['180',180]],
    labelsCount: 8,
    needleType: 'line',
    needleTail: 'true',
    needleSize: 100,
    needleWidth: 3,
    centerpinRadius: 10,
    centerpinColor: 'black',
    colorsRanges: [[-180,-100,'white'],[-100,-45, 'green'], [-45, -15,'yellow'], [-15, 15, 'red'], [15, 45, 'yellow'], [45,100,'green'],[100,180,'white']],

I'm trying to make use of labelsSpecific option in it and all I get is double-labeling at equally spaced positions, that look exactly like '100',100 and so on. Am I missing something here? I want just a certain degrees marked.


P.S.: sorry for hijacking this thread.
Posted by Richard on 22nd October 2017
Hi there,

Well you'd be better off withe Odometer if you're showing a compass. That way you can use a background image like this demo does:


Posted by Anton on 23rd October 2017
Thank you Richard.
That is certainly a solution to my problem, although it's not ideal. I would want to change the colored ranges eventually and it would be a very tedious job to make that many background images. From what I understand, the Odometer does not offer this custom "colorsRanges" which are extremely useful for me.
Anyway, thank you for your suggestion, I'll try it.
Posted by Anton on 23rd October 2017
As a solution, I've passed
labelsSpecific: ['','','','','','','','','','','','','','','','','-100','','','','','','','','','','','','-45','','','','','','','-15','','','','','','','','15','','','','','','','45','','','','','','','','','','','','100','','','','','','','','','','','','','','','',''],
and it works. Not the most elegant way of doing things, I assume.

Add a reply

« Back to message list