Circular Gauge set value not working

TeeChart for Java (NetBeans, Eclipse, Android Studio, etc)
Post Reply
mts
Newbie
Newbie
Posts: 18
Joined: Fri Apr 29, 2011 12:00 am

Circular Gauge set value not working

Post by mts » Mon Jun 04, 2012 12:49 pm

I'm not sure what I'm doing wrong. I have a very simple circular gauge on a chart. I copied an example to give it a nice look. Here's the code snippet:

TChart chart1;
private CircularGauge gaugeSeries1;
double dHigh = 8000;
double dLow = 0;

chart1.setText("");
chart1.setClipPoints(false);
chart1.getHeader().setVisible(false);
chart1.getLegend().setVisible(false);
chart1.getAspect().setView3D(false);
chart1.getAspect().setSmoothingMode(true);
chart1.getAspect().setTextSmooth(false);
chart1.getWalls().getBack().setTransparency(100);
gaugeSeries1.setMaximum(dHigh);
gaugeSeries1.setMinimum(dLow);
gaugeSeries1.clear();
double diff = dHigh - dLow;
chart1.getAxes().getLeft().setIncrement(diff/10.0);
chart1.getAxes().getLeft().setMinMax(dLow,dHigh);

gaugeSeries1.getFrame().getOuterBand().setColor(Color.fromArgb(153,153,153));
gaugeSeries1.getFrame().getMiddleBand().getGradient().setVisible(true);
gaugeSeries1.getFrame().getMiddleBand().getGradient().setStartColor(Color.fromArgb(80,80,80));
gaugeSeries1.getFrame().getMiddleBand().getGradient().setEndColor(Color.WHITE);
gaugeSeries1.getFrame().getInnerBand().setColor(Color.fromArgb(213,213,213));


gaugeSeries1.setValue(3200);

The gauge is just staying at 0. Not sure why. I also have a general question about how gauge series work. A series usually contains a bunch of data points with X,Y values, but the gauge only displays a Y value since X is time and it always displays the Y at current time. So what does adding data points to the series do? Do you just use setValue to set the gauge value, or are there reasons to add data points to the series? Also how do the chart axes interact with the gauge series? On a line series I set all the min/max and scaling via the chart axes, but on gauge it has setMinimum and setMaximum functions. But the increment seems to still be set via the chart axes property. Are some properties taken from the chart axes and others from the gauge series? This is very confusing to me.

Yeray
Site Admin
Site Admin
Posts: 9613
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Circular Gauge set value not working

Post by Yeray » Tue Jun 05, 2012 10:48 am

Hello Mark,
mts wrote:The gauge is just staying at 0. Not sure why.
This is what I get with your code:
Chart1.png
Chart1.png (44.61 KiB) Viewed 19855 times
I see the needle at 3200 as set with the setValue call. What I see at 0 are the geen and red lines, but you haven't set them as the rest of the gauges so theay still have the default values, that are 0-70 for the green line and 80-100 for the red line.
For example, I can change it for this:

Code: Select all

        gaugeSeries1.setGreenLineEndValue(5600);
        gaugeSeries1.setRedLineStartValue(6400);
        gaugeSeries1.setRedLineEndValue(8000);
And I get this, what I'm not sure if it's something similar to what you expected:
Chart2.png
Chart2.png (49.04 KiB) Viewed 19859 times
mts wrote:I also have a general question about how gauge series work. A series usually contains a bunch of data points with X,Y values, but the gauge only displays a Y value since X is time and it always displays the Y at current time. So what does adding data points to the series do? Do you just use setValue to set the gauge value, or are there reasons to add data points to the series? Also how do the chart axes interact with the gauge series? On a line series I set all the min/max and scaling via the chart axes, but on gauge it has setMinimum and setMaximum functions. But the increment seems to still be set via the chart axes property. Are some properties taken from the chart axes and others from the gauge series? This is very confusing to me.
This series is thought to have different values through the time, where the needle indicates the actual value. And the green and red lines just indicate two zones or value intervals.
It inherits from Series class, and that's why it has the add() methods, the XValues and YValues ValueLists, etc... but they aren't used. Well, only the YValue[0] is used, but it's thought to be modified through the setValue() method.
I hope I've clarified it a little bit. If you still have any doubt, don't hesitate to let us know.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

mts
Newbie
Newbie
Posts: 18
Joined: Fri Apr 29, 2011 12:00 am

Re: Circular Gauge set value not working

Post by mts » Tue Jun 05, 2012 2:36 pm

Thanks for the clarification on the series.

It still is not updating however. I have the chart on a panel, which is part of another panel on a scroll pane. I'm making a scrollable view of gauges in a grid format. So the chart is several levels down. I tried explicitly calling gaugeSeries1.repaint() and chart1.repaint() to no avail. Also when I use the regular gauges series over the circular one it updates. It will be difficult to give a better code sample, as it's very dependent on the entire project but I'll try if I can't figure out why this chart won't refresh.

mts
Newbie
Newbie
Posts: 18
Joined: Fri Apr 29, 2011 12:00 am

Re: Circular Gauge set value not working

Post by mts » Tue Jun 05, 2012 8:02 pm

Ok I got it to work only when I set the limits to 300 or less. I attached three screenshots, one is chart limits of 0-300, another 0-400 and last one my desired 0-8000. All three have the axis increment set at high - low / 10. I also set the green line and red line at 80% and 90-100% of the value as follows:

gaugeSeries1.setGreenLineEndValue(dHigh * .8);
gaugeSeries1.setRedLineStartValue(dHigh * .9);
gaugeSeries1.setRedLineEndValue(dHigh);

I set the chart value to 50 for all three charts with:

gaugeSeries1.setValue(50);

The chart 0-300 looks as expected. I get a nice gauge spanning 0-300, increments every 30, the green and red lines look good and my value looks correct. But in all the others it's all wrapped around. You can see in the 0-400 the increments are right but the green and red lines wrap around and the value is approx 70, not the desired 50. This wrap around effect just increases as I set the series limits higher to 500, 600 etc. Then on the 0-8000 chart you can't even see the green/red lines, even though they are set, and the value of 50 doesn't even register. Actually no values register. I am getting no exceptions, just nothing is happening.

Is there some setting not right that is causing my chart to wrap around when it exceeds this 300 limit?
Attachments
chart bad 0-8000.png
chart bad 0-8000.png (38.05 KiB) Viewed 19853 times
chart bad 0-400.png
chart bad 0-400.png (40.58 KiB) Viewed 19862 times
chart good 0-300.png
chart good 0-300.png (39.91 KiB) Viewed 19857 times

Yeray
Site Admin
Site Admin
Posts: 9613
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Circular Gauge set value not working

Post by Yeray » Wed Jun 06, 2012 7:27 am

Hi Mark,

What TeeChart Java version are you using? It works fine for me both in NetBeans (Swing) and Eclipse (SWT) with v3.2012.0202.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

mts
Newbie
Newbie
Posts: 18
Joined: Fri Apr 29, 2011 12:00 am

Re: Circular Gauge set value not working

Post by mts » Wed Jun 06, 2012 2:54 pm

I was using a 2011 version, whatever the official release for 2011 was. I tried using the 2011 beta version, as I'm registered for that, but it gave me a bunch of compile errors saying some methods were non existent. Very strange.

However, I downloaded a 2012 evaluation and everything seems to work correctly. So there must have been a bug fix in there somewhere. Thanks for the suggestion, I'm not sure why I didn't try this in the first place.

Yeray
Site Admin
Site Admin
Posts: 9613
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Circular Gauge set value not working

Post by Yeray » Wed Jun 06, 2012 3:10 pm

Hi Mark,

Great! I'm glad to hear it! :)
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply