Auto scrolling in Tee chart

TeeChart for Java (NetBeans, Eclipse, Android Studio, etc)
Post Reply
vijay
Newbie
Newbie
Posts: 15
Joined: Mon Jun 07, 2010 12:00 am

Auto scrolling in Tee chart

Post by vijay » Mon Aug 09, 2010 2:05 pm

hello,

Is there any way do enable auto scrolling on specific axis using teechart in java.

I used below method ,but i have to explicitly call everytime.
chart.getAxes().getBottom().scroll(1, false);

I want to auto scroll one axis based on the values.

Advance thanks for your reply.

Thanks,
Vijaya Raghava Rao

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

Re: Auto scrolling in Tee chart

Post by Yeray » Wed Aug 11, 2010 3:15 pm

Hi Vijaya,

You have to use SetMinMax function, giving the Min and Max values you want your axis to go from and to.
Please, take a look at the Tutorials and the JavaDoc in the installation Docs folder
You could find examples about this on Tutorial 8 - Zoom and Scroll
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

vijay
Newbie
Newbie
Posts: 15
Joined: Mon Jun 07, 2010 12:00 am

Re: Auto scrolling in Tee chart

Post by vijay » Thu Sep 02, 2010 7:56 am

Hello Yeray,

Thank you very much for reply.

We can shift XAxis Min max values using setMinMax() and also chart.getAxes().getBottom().scroll(1, false).

In both cases i have to repeatedly call one of the above methods to shift the Axis min & max.

I wanted to know is there any method provided for continuous scrolling.

Advance thanks for you reply.

Thanks,
Vijaya Raghava Rao

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

Re: Auto scrolling in Tee chart

Post by Yeray » Fri Sep 03, 2010 11:20 am

Hi Vijaya,

When the axes are automatic, they are scaled automatically to show all the values visible in the chart. If you are adding values for example with a timer, every time you add a value the chart should be rescaled to fit all the values.
However, if you want to always show the last X values, you have to scroll the axes manually. Here it is an example:

Code: Select all

    private Timer timer1;
    private com.steema.teechart.styles.Line line1;
    private int numVals = 20;
    private void initChart() {
        tChart1.getLegend().setVisible(false);

        line1 = new com.steema.teechart.styles.Line(tChart1.getChart());
        java.util.Random rand = new java.util.Random();
        line1.add(rand.nextDouble() * 100);
        for (int i= 1; i < numVals; i++) {
            line1.add(line1.getYValues().getValue(i-1) + rand.nextDouble() * 10 - 5);
        }

        timer1 = new Timer(1000, new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                java.util.Random rand = new java.util.Random();
                line1.add(line1.getYValues().getValue(line1.getCount()-1) + rand.nextDouble() * 10 - 5);
                
                double min = line1.getXValues().getValue(line1.getCount()-numVals);
                double max = line1.getXValues().getValue(line1.getCount()-1);
                tChart1.getAxes().getBottom().setMinMax(min, max);
            }
        });

        timer1.start();
    }
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

vijay
Newbie
Newbie
Posts: 15
Joined: Mon Jun 07, 2010 12:00 am

Re: Auto scrolling in Tee chart

Post by vijay » Tue Sep 07, 2010 2:36 pm

Hello yeray,

Thanks for your reply.

As discussed above we are following manually updating min & max values of XAxis fo scrolling functionality.

After running for long time we are getting No more handles exception from SWT.

I thin it's because of more values in line series.we are using FastLine for displaying line series.

Is there any way to clear the invisible points( previous points which are not Visible).

Thanks,
Vijaya Raghava Rao

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

Re: Auto scrolling in Tee chart

Post by Yeray » Fri Sep 10, 2010 7:18 am

Hi Vijaya,

You could use the delete() method. In the example above:

Code: Select all

        timer1 = new Timer(1000, new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                java.util.Random rand = new java.util.Random();
                line1.add(line1.getXValues().getValue(line1.getCount()-1) + 1, line1.getYValues().getValue(line1.getCount()-1) + rand.nextDouble() * 10 - 5);
                line1.delete(0, line1.getCount() - numVals);
                
                double min = line1.getXValues().getValue(line1.getCount()-numVals);
                double max = line1.getXValues().getValue(line1.getCount()-1);

                tChart1.getAxes().getBottom().setMinMax(min, max);
            }
        });
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