Page 1 of 1

Auto scrolling in Tee chart

Posted: Mon Aug 09, 2010 2:05 pm
by 15356328
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

Re: Auto scrolling in Tee chart

Posted: Wed Aug 11, 2010 3:15 pm
by yeray
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

Re: Auto scrolling in Tee chart

Posted: Thu Sep 02, 2010 7:56 am
by 15356328
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

Re: Auto scrolling in Tee chart

Posted: Fri Sep 03, 2010 11:20 am
by yeray
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();
    }

Re: Auto scrolling in Tee chart

Posted: Tue Sep 07, 2010 2:36 pm
by 15356328
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

Re: Auto scrolling in Tee chart

Posted: Fri Sep 10, 2010 7:18 am
by yeray
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);
            }
        });