Hi. I am experiencing a problem when using the NearestPoint-tool: For some reason, it keeps drawing lines to points of series not present in the chart. So the question is, have you experienced before that Series that are removed still triggers the NearestPoint's listener?
I have created a small program which I will upload on your pages, illustrating the problem. Observe what happens after you enter a new Series. It might be related to the code but I explisitly remove all series.
Thanks in advance
M
NearestPoint-problem
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Marius,
Thank you very much for the example project. I could reproduce the issue there but couldn't reproduce it using TeeChart.Features.jar, shipped with TeeChart for Java, going to the Tools\Nearest Point example and adding an additional series there.
Can you reproduce the problem in the demo (click the edit button for adding a new series and populating it)? If the problem can not be reproduced in the demo, could you please send us the full sources of the project you posted at the upload page so that we can reproduce and debug the problem here?
Thanks in advance.
Thank you very much for the example project. I could reproduce the issue there but couldn't reproduce it using TeeChart.Features.jar, shipped with TeeChart for Java, going to the Tools\Nearest Point example and adding an additional series there.
Can you reproduce the problem in the demo (click the edit button for adding a new series and populating it)? If the problem can not be reproduced in the demo, could you please send us the full sources of the project you posted at the upload page so that we can reproduce and debug the problem here?
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 |
Instructions - How to post in this forum |
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Marius,
Full test project sources would be fine.
Thanks in advance.
Full test project sources would be fine.
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 |
Instructions - How to post in this forum |
Enjoy
Code: Select all
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import com.steema.teechart.TChart;
import com.steema.teechart.styles.PointerStyle;
import com.steema.teechart.styles.Points;
import com.steema.teechart.tools.NearestPoint;
import com.steema.teechart.tools.NearestPointStyle;
public class PointTest extends JFrame implements ActionListener
{
JPanel dmb = new JPanel();
TChart myChart = new TChart();
JButton newSerButton = new JButton("Press for new series. Notice what happens when a new series is included");
NearestPoint tool = null;
int indicator = 0;
double[] testData = new double[50];
double[] testX = new double[50];
double[] testData1 = new double[50];
double[] testX1 = new double[50];
double[] testData2 = new double[50];
double[] testX2 = new double[50];
public static void main(String[] args)
{
new PointTest().setVisible(true);
}
public PointTest()
{
initialize();
}
public void initialize()
{
/******************/
for(int i=0;i<50;i++)
{
testData[i] = (i+50)*Math.pow(Math.random(),Math.random());
testX[i] = i;
testData1[i] = (i+50)*Math.pow(1,Math.random());
testX1[i] = i*Math.random()*7;
testData2[i] = (i+50)*Math.pow(2,Math.random());
testX2[i] = i*Math.random()*3;
}
/******************/
myChart.getChart().getAspect().setView3D(false);
newSerButton.addActionListener(this);
dmb.add(myChart);
dmb.add(newSerButton);
super.add(dmb);
super.setSize(600,400);
}
public void addSeries()
{
// I am removing all series, and invalidating the tool...
myChart.removeAllSeries();
if(tool != null)
{
myChart.doInvalidate();
tool = null;
}
Points p = new Points(myChart.getChart().chart);
if(indicator == 0)
{
p.add(testData);
p.getXValues().setValues(testX);
indicator ++;
}
else if(indicator == 1)
{
p.add(testData1);
p.getXValues().setValues(testX1);
indicator ++;
}
else
{
p.add(testData2);
p.getXValues().setValues(testX2);
indicator = 0;
}
// Newing the tool, to re-bind the listeners...
tool = new NearestPoint(myChart.getChart());
tool.getBrush().setVisible(true);
tool.setSeries(p);
tool.getBrush().setColor(new com.steema.teechart.drawing.Color(0,0,100));
tool.setStyle(NearestPointStyle.NONE);
tool.setSize(10);
tool.getPen().setColor(new com.steema.teechart.drawing.Color(50,100,150));
tool.setDrawLine(true);
p.getPointer().setStyle(PointerStyle.DIAMOND);
p.getPointer().getPen().setVisible(false);
myChart.getChart().addSeries(p);
myChart.repaint();
}
public void actionPerformed(ActionEvent e)
{
addSeries();
}
}
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Marius,
Thanks for the example code. We could reproduce the issue here. What happens is that every time you click the button and therefore addSeries() is called a new NearestPoint tool is created and assigned to the new series. So you have a tool for each series.
You have severial options here:
1. Only add one NearestPoint tool in the chart and assign it to the last series:
2. Disable existing tools and only enable last series tool:
There are some other combinations based on what I told you above. You'll have to decide for the option more suitable to your needs.
Hope this helps!
Thanks for the example code. We could reproduce the issue here. What happens is that every time you click the button and therefore addSeries() is called a new NearestPoint tool is created and assigned to the new series. So you have a tool for each series.
You have severial options here:
1. Only add one NearestPoint tool in the chart and assign it to the last series:
Code: Select all
if (tChart.getTools().size()==0)
{
tool = new NearestPoint(tChart.getChart());
}
2. Disable existing tools and only enable last series tool:
Code: Select all
for (int i=0; i<tChart.getTools().size(); i++)
{
tChart.getTools().getTool(i).setActive(false);
}
tool = new NearestPoint(tChart.getChart());
Hope this helps!
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Marius,
You're welcome. I'm glad to hear that helped.
You're welcome. I'm glad to hear that helped.
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |