HBar with xmin/xmax

Share RGraph:  

« 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 August 2017
Hi Richard:

Seeing a possible problem using xmin/xmax with HBar.

Here is a simple example option block:

var options= {
                scaleZerostart: true,
                grouping: 'grouped',
                yaxispos: 'center',
                variant: 'hbar',
                textAccessible: true, };

    gauge = new RGraph.HBar({ id:'cvs', data:[[-8],], options:options });

You can see that my data is '-8' and that I am drawing a centered chart. The above draws correctly and I get a chart from -10 to +10 with the bar going from -8 to 0, as expected.

However, I want to control the minimum and maximum values displayed. When I add these to the options array:


The X axis goes crazy and the bar shows incorrectly.

The X axis becomes: -20 -12 -4 --4 --20 -12 -4 4 12 20

And yes, there are double hyphens in there. It seems to affect xmin specifically, as xmax seems to work ok.

Is this something I'm doing wrong? Or a bug perhaps?

Thanks, david
Posted by Richard on 20th August 2017
Hi there,

After an initial bit of confusion on my part, and a fix to alignment, this example appears to be generating a correct scale:


If you're not using version 4.62 - then either try that or the beta on the website.

As for the rest of today - I still have 100 pages to check through for links to 404 errors. Oh joy. (not that this is relevant to your issue)

Posted by David Cook on 20th August 2017
Hi Richard:

Not sure if you understood my original post. The example you posted was missing the element that caused it to mess up.

Specifically - if you would add the following to your example:

xmin: -20,
xmax: 20,

...I believe your X axis will now display incorrectly. As per my original post, I need to control the min/max of the scale - and when I try to control the min (as per above), the scale is messed up.

Just to make sure, I am using the latest stable version - but also tried the Beta and it has the same problem (this probably also affects VBar, though I have not yet confirmed that.

Posted by Richard on 20th August 2017
Hi there,

Gotcha, try this then:


With the canvas charts you need to set the Y axis to be in the center and just specify the max value (not the minimum value). The example shows a HBar and a regular Bar chart.


Add a reply

« Back to message list