Page 1 of 1

Scroll arrow locked

Posted: Mon Sep 05, 2011 7:27 pm
by 15355256
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);

Re: Scroll arrow locked

Posted: Tue Sep 06, 2011 2:31 pm
by yeray
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;

Re: Scroll arrow locked

Posted: Thu Sep 08, 2011 11:32 am
by 15355256
Hi Yeray,

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

Re: Scroll arrow locked

Posted: Thu Sep 08, 2011 1:35 pm
by yeray
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.

Re: Scroll arrow locked

Posted: Mon Sep 12, 2011 7:37 pm
by 15355256
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?

Re: Scroll arrow locked

Posted: Tue Sep 13, 2011 10:46 am
by narcis
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.

Re: Scroll arrow locked

Posted: Tue Sep 13, 2011 4:19 pm
by 15355256
Hi Narcis,

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