Scroll arrow locked

TeeChart for Java (NetBeans, Eclipse, Android Studio, etc)
Post Reply
WhebJava
Newbie
Newbie
Posts: 10
Joined: Mon Feb 15, 2010 12:00 am

Scroll arrow locked

Post by WhebJava » Mon Sep 05, 2011 7:27 pm

Hello,

I'm trying to make the scroll arrow to go only where there is value in the series. In Delphi works with the lock, when the series finish.
I read in the tutorial 08 the instructions, but I could not.
I did something wrong?

The following code:

Code: Select all

JFrame frame = new JFrame();
        JPanel panel = new JPanel();
        panel.setSize(600, 600);
        TChart chart = new TChart();
        chart.getAxes().getBottom().getLabels().setValueFormat("0");
        
        panel.add(chart);
        Bar bar = new Bar(chart.getChart());
        for (int i = 0; i < 10; i++) {
           bar.add(i);
        }
        
        AxisArrow axisDown = new AxisArrow(chart.getChart().getAxes().getBottom());
        axisDown.setScrollInverted(false);
        chart.getChart().getTools().add(axisDown);
        
        chart.getAxes().getBottom().setAutomatic(false);
        chart.getAxes().getBottom().setMinimum(0.0);
        chart.getAxes().getBottom().setMaximum(10.0);
        
        frame.add(panel);
        frame.setSize(600, 600);
        frame.setVisible(true);

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

Re: Scroll arrow locked

Post by Yeray » Tue Sep 06, 2011 2:31 pm

Hello,

Are you sure you are doing the same in Delphi and in Java?
The following code, in Delphi, doesn't "lock" the axis for me here:

Code: Select all

uses Series, TeeTools;

procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
begin
  Chart1.View3D:=false;

  with Chart1.AddSeries(TBarSeries) do
    for i:=0 to 9 do
      Add(i);

  (Chart1.Tools.Add(TAxisArrowTool) as TAxisArrowTool).Axis:=Chart1.Axes.Bottom;
end;
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

WhebJava
Newbie
Newbie
Posts: 10
Joined: Mon Feb 15, 2010 12:00 am

Re: Scroll arrow locked

Post by WhebJava » Thu Sep 08, 2011 11:32 am

Hi Yeray,

I'm doing in Java.
I want to lock the scroll when it came to the limits of the series.

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

Re: Scroll arrow locked

Post by Yeray » Thu Sep 08, 2011 1:35 pm

Hello,
WhebJava wrote:I'm doing in Java.
I want to lock the scroll when it came to the limits of the series.
I understood you are trying to do it in Java, but I also understood you already achieved it in Delphi:
WhebJava wrote:In Delphi works with the lock, when the series finish.
So I was trying to see how did you do that in Delphi. I'd say it will probably be similar.
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

WhebJava
Newbie
Newbie
Posts: 10
Joined: Mon Feb 15, 2010 12:00 am

Re: Scroll arrow locked

Post by WhebJava » Mon Sep 12, 2011 7:37 pm

I translate from Delphi to Java, but it did not work as I wanted, so I asked here.
In java it does not block the scroll when the series ends.
It would be a problem? Or am I doing wrong?

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: Scroll arrow locked

Post by Narcís » Tue Sep 13, 2011 10:46 am

Hi WhebJava,

Code below works fine for me here. Can you please check if it works fine at your end?

Code: Select all

    private void initChart() {
        commander1.setChart(tChart1.getChart());

        final Line l = new Line(tChart1.getChart());
        l.fillSampleValues();

        final AxisArrow axisDownLeft = new AxisArrow(tChart1.getChart().getAxes().getBottom());
        axisDownLeft.setPosition(AxisArrowPosition.START);

        final AxisArrow axisDownRight = new AxisArrow(tChart1.getChart().getAxes().getBottom());
        axisDownRight.setPosition(AxisArrowPosition.END);

        tChart1.addChartPaintListener( new ChartPaintAdapter() {
            @Override
            public void seriesPainted(ChartDrawEvent e) {
                boolean leftActive = false;
                boolean rightActive = false;

                if (l.firstDisplayed() > 0) {
                    rightActive = true;
                } else {
                    rightActive = false;
                }

                if (l.lastDisplayed() < l.getCount() - 1) {
                    leftActive = true;
                } else {
                    leftActive = false;
                }

                axisDownLeft.setActive(leftActive);
                axisDownRight.setActive(rightActive);
            };

            @Override
            public void chartPainted(ChartDrawEvent e) {
                //
            };
        });

    }
Thanks in advance.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

WhebJava
Newbie
Newbie
Posts: 10
Joined: Mon Feb 15, 2010 12:00 am

Re: Scroll arrow locked

Post by WhebJava » Tue Sep 13, 2011 4:19 pm

Hi Narcis,

It is something similar to what you did have to do.
I will make the necessary changes, thanks for the tips. :wink:

Post Reply