TeeChart for Java (NetBeans, Eclipse, Android Studio, etc)
-
WhebJava
- Newbie
- Posts: 10
- Joined: Mon Feb 15, 2010 12:00 am
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
- Posts: 9613
- Joined: Tue Dec 05, 2006 12:00 am
- Location: Girona, Catalonia
-
Contact:
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;
-
WhebJava
- Newbie
- Posts: 10
- Joined: Mon Feb 15, 2010 12:00 am
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
- Posts: 9613
- Joined: Tue Dec 05, 2006 12:00 am
- Location: Girona, Catalonia
-
Contact:
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.
-
WhebJava
- Newbie
- Posts: 10
- Joined: Mon Feb 15, 2010 12:00 am
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
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
-
Contact:
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.
-
WhebJava
- Newbie
- Posts: 10
- Joined: Mon Feb 15, 2010 12:00 am
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.