Hello, Marc .
I got it. Thanks.
For the export and import problem,
Could you please run my code example , if it can not start, please let me know.
If you can run the code example, could you please try to click operation--> save.
Then click operation--> load.
I think you will find that something is wrong.
If you can load the saved tej or xml correctly, please let me know too.
I have tried many times, the tej can not loaded correctly.
Thanks again .
TChart serializable problem
Re: TChart serializable problem
Hello,
I've ran your application (well, I moved the code to a NetBeans application but it's pretty much your code).
I've been able to reproduce the error you reported here when exporting to XML. We are investigating it.
However, I've been able to export and import the chart using tej without many problems. I've only modified/corrected a few things:
- I've commented the initialization of the chart size because I've placed the chart at design time so it already has a size:
- In saveItem button, I've uncommented the line where you are exporting the chart to a tej and I've commented the line where you export the chart to an xml. Also, I've slightly changed the path:
- In saveItem button I've commented the line where you set a text to the first label. note you are doing this after clearing the labels, so it gives an IndexOutOfBoundsException. I've also commented the repaint:
Here you have the complete saveItem action:
- I've modified the openItem button to import the tej and I've added the refreshControl call mentioned previously.
I've ran your application (well, I moved the code to a NetBeans application but it's pretty much your code).
I've been able to reproduce the error you reported here when exporting to XML. We are investigating it.
However, I've been able to export and import the chart using tej without many problems. I've only modified/corrected a few things:
- I've commented the initialization of the chart size because I've placed the chart at design time so it already has a size:
Code: Select all
//tChart1.setBounds(new Rectangle(0, 0, 500, 500));
Code: Select all
tChart1.getExport().getTemplate().toFile("c:\\tmp\\tt23.tej");
//tChart1.getExport().getTemplate().toXML("c:\\tmp\\tt23.xml");
Code: Select all
bottom.getLabels().getItems().clear();
/*bottom.getLabels().getItems().set( 0, "new-1");
tChart1.repaint();*/
Code: Select all
saveItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (tChart1 != null) {
try {
tChart1.setText("Stored chart");
tChart1.getSeries(0).setTitle("StoreA");
tChart1.getSeries(1).setTitle("StoreB");
Axis bottom = tChart1.getAxes().getBottom();
System.out.println(bottom.getLabels().getItems().size());
bottom.getLabels().getItems().add((double) 1, "MyXLabel-1");
bottom.getLabels().getItems().add((double) 2, "MyXLabel-2");
tChart1.repaint();
JOptionPane.showMessageDialog(null, "Current tchart will be stored");
tChart1.getExport().getTemplate().toFile("c:\\tmp\\tt23.tej");
//tChart1.getExport().getTemplate().toXML("c:\\tmp\\tt23.xml");
tChart1.getAspect().setView3D(true);
tChart1.setText("New Chart");
tChart1.getSeries(0).setTitle("new A");
tChart1.getSeries(1).setTitle("new B");
bottom = tChart1.getAxes().getBottom();
System.out.println(bottom.getLabels().getItems().size());
bottom.getLabels().getItems().clear();
/*bottom.getLabels().getItems().set( 0, "new-1");
tChart1.repaint();*/
} catch (IOException ex) {
}
}
}
});
Code: Select all
openItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (tChart1 != null) {
try {
tChart1.setChart(tChart1.getImport().getTemplate().fromFile("c:\\tmp\\tt23.tej")); //load fail
//tChart1.getImport().getTemplate().fromXML("c:\\tmp\\tt23.xml");
//tChart1.updateUI();
//tChart1.repaint();
tChart1.refreshControl();
} catch (Exception ex) {
}
}
}
});
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: TChart serializable problem
Hello, Yeray:
Thank you so much.
For the export and import tej,
I should use:
instead of
this is why can not import a tej and show it.
However, for xml,
both of them are ok.
For currently xml export and import, there is some errors with it.
java.lang.NullPointerException
at com.steema.teechart.drawing.Gradient.getCustomTargetRectangle(Gradient.java:448)
This will result the "MyXLabel-1" and "MyXLabel-2" do not showed.
I hope this conclusion will benefit other guys who come across similar problem.
In fact, i have another question, sorry.
Can i add some custom properties defined by myslef into xml or tej?
for example the created date, the author of this tchart, the data source path to create this tej.
thanks.
Thank you so much.
For the export and import tej,
I should use:
Code: Select all
tChart.setChart( tChart.getImport().getTemplate().fromFile("c:\\tt23.tej"));
instead of
Code: Select all
tChart.getImport().getTemplate().fromFile("c:\\tt23.tej");
However, for xml,
both of them are ok.
Code: Select all
tChart.getImport().getTemplate().fromXML("c:\\tt23.xml") ; //this is ok
tChart.setChart(tChart.getImport().getTemplate().fromXML("c:\\tt23.xml")); //this is ok too
For currently xml export and import, there is some errors with it.
java.lang.NullPointerException
at com.steema.teechart.drawing.Gradient.getCustomTargetRectangle(Gradient.java:448)
This will result the "MyXLabel-1" and "MyXLabel-2" do not showed.
I hope this conclusion will benefit other guys who come across similar problem.
In fact, i have another question, sorry.
Can i add some custom properties defined by myslef into xml or tej?
for example the created date, the author of this tchart, the data source path to create this tej.
thanks.
Re: TChart serializable problem
Hello,
+1! Thanks for sharing.rubby wrote:I hope this conclusion will benefit other guys who come across similar problem.
Yes, being a source code customer allows you to add any property you like to the TChart and they will be exported/imported with the other properties.rubby wrote:Can i add some custom properties defined by myslef into xml or tej?
for example the created date, the author of this tchart, the data source path to create this tej.
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |