Exporting/Importing problem
Exporting/Importing problem
Windows XP Pro SP2
VB 2005 Express
TeeChart V3 3.2.2796.22187
I am trying to export and import charts to .ten files, but when I import them, the series colors are incorrect. Of course, I don't know whether the problem is with the export or import or both, but something isn't working right. My code is below. I get the same result whether I include data or not, and the same result using a datastream instead of a file.
TChart1.Export.Template.IncludeData = True
TChart1.Export.Template.Save("c:\temp\c3.ten")
TChart1.Import.Template.Load("c:\temp\c3.ten")
I can send a jpeg of the chart before export and after import, and the .ten file itself, but you'll have to remind me how to upload files.
Jay
VB 2005 Express
TeeChart V3 3.2.2796.22187
I am trying to export and import charts to .ten files, but when I import them, the series colors are incorrect. Of course, I don't know whether the problem is with the export or import or both, but something isn't working right. My code is below. I get the same result whether I include data or not, and the same result using a datastream instead of a file.
TChart1.Export.Template.IncludeData = True
TChart1.Export.Template.Save("c:\temp\c3.ten")
TChart1.Import.Template.Load("c:\temp\c3.ten")
I can send a jpeg of the chart before export and after import, and the .ten file itself, but you'll have to remind me how to upload files.
Jay
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi JayG,
I'm not able to reproduce the problem here using the code below. Would you be so kind to modify it or send us a simple example project we can run "as-is" to reproduce the problem here? It would be helpful for us seeing how you initialize your chart.
You can post files at news://www.steema.net/steema.public.attachments newsgroup or at our upload page.
Thanks in advance.
I'm not able to reproduce the problem here using the code below. Would you be so kind to modify it or send us a simple example project we can run "as-is" to reproduce the problem here? It would be helpful for us seeing how you initialize your chart.
Code: Select all
private void Form1_Load(object sender, EventArgs e)
{
for (int i = 0; i < 5; i++)
{
tChart1.Series.Add(new Steema.TeeChart.Styles.Line());
tChart1[i].FillSampleValues();
}
MemoryStream stream = new MemoryStream();
tChart1.Export.Template.Save(stream);
stream.Position = 0;
tChart2.Import.Template.Load(stream);
}
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 |
Exporting/Importing problem
Narcis,
Thanks for your quick reply.
I should have given more details in my first post. When I do a simple example like yours, I don't see the problem. My application runs queries against SQL server databases. The TeeChart series data is supplied using the Datasource, XValues.Datamember, and YValues.Datamember properties. One of my smaller queries creates 25 to 30 series that have several thousand points.
It may take me while to figure out the simplest example that still exhibits the problem. I will try to do that, but for now I will upload a .ten file that includes the data that exhibits the problem, along with a .jpg that shows the same chart before it was exported.
Jay
Thanks for your quick reply.
I should have given more details in my first post. When I do a simple example like yours, I don't see the problem. My application runs queries against SQL server databases. The TeeChart series data is supplied using the Datasource, XValues.Datamember, and YValues.Datamember properties. One of my smaller queries creates 25 to 30 series that have several thousand points.
It may take me while to figure out the simplest example that still exhibits the problem. I will try to do that, but for now I will upload a .ten file that includes the data that exhibits the problem, along with a .jpg that shows the same chart before it was exported.
Jay
Exporting/Importing problem
I uploaded the .jpg and .ten files to the pulic.attachments newsgroup. The .ten file is zipped.
Jay
Jay
Exporting/Importing problem
OK, I found the cause.
If the column of a DataTable that is the YValues.Datamember of a series contains any null values, the series color is either not exported or not imported correctly.
Here is the simplest Visual Basic code I could come up with to reproduce the problem. You will have to supply a connection string (first "***") and a query string (second "***"). Make sure at least one null value is returned. Create a form with 2 charts, TChart1 and TChart2, and run the following code when a button is clicked.
Dim stream As New IO.MemoryStream
Dim Line1 As Steema.TeeChart.Styles.Line
Dim OleConnection As New OleDb.OleDbConnection("***")
Dim OleAdapter As OleDb.OleDbDataAdapter
Dim MyDataSet As New DataSet()
Dim DetailsTable As New DataTable
OleAdapter = New OleDb.OleDbDataAdapter("***", OleConnection)
OleConnection.Open()
OleAdapter.Fill(MyDataSet, "details")
OleConnection.Close()
DetailsTable = MyDataSet.Tables("details")
Line1 = New Steema.TeeChart.Styles.Line(TChart1.Chart)
Line1.DataSource = DetailsTable
Line1.YValues.DataMember = DetailsTable.Columns(0).ColumnName
Line1.Color = Color.Green
TChart1.Export.Template.IncludeData = True
TChart1.Export.Template.Save(stream)
stream.Position = 0
TChart2.Import.Template.Load(stream)
If you leave out "Line1.Color = Color.Green", it will appear to work because the same default color is used for the new series before exporting and the series when it is imported.
Jay
If the column of a DataTable that is the YValues.Datamember of a series contains any null values, the series color is either not exported or not imported correctly.
Here is the simplest Visual Basic code I could come up with to reproduce the problem. You will have to supply a connection string (first "***") and a query string (second "***"). Make sure at least one null value is returned. Create a form with 2 charts, TChart1 and TChart2, and run the following code when a button is clicked.
Dim stream As New IO.MemoryStream
Dim Line1 As Steema.TeeChart.Styles.Line
Dim OleConnection As New OleDb.OleDbConnection("***")
Dim OleAdapter As OleDb.OleDbDataAdapter
Dim MyDataSet As New DataSet()
Dim DetailsTable As New DataTable
OleAdapter = New OleDb.OleDbDataAdapter("***", OleConnection)
OleConnection.Open()
OleAdapter.Fill(MyDataSet, "details")
OleConnection.Close()
DetailsTable = MyDataSet.Tables("details")
Line1 = New Steema.TeeChart.Styles.Line(TChart1.Chart)
Line1.DataSource = DetailsTable
Line1.YValues.DataMember = DetailsTable.Columns(0).ColumnName
Line1.Color = Color.Green
TChart1.Export.Template.IncludeData = True
TChart1.Export.Template.Save(stream)
stream.Position = 0
TChart2.Import.Template.Load(stream)
If you leave out "Line1.Color = Color.Green", it will appear to work because the same default color is used for the new series before exporting and the series when it is imported.
Jay
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Jay,
How do you have null values identified in your database? I'm not able to reproduce the problem here using the code below.
Could you please modify the code snippet above so that we can reproduce the problem here?
Thanks in advance.
How do you have null values identified in your database? I'm not able to reproduce the problem here using the code below.
Code: Select all
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs)
tChart1.Series.Add(New Steema.TeeChart.Styles.Line())
tChart1(0).Add(1, 1)
tChart1(0).Add(2, 2)
tChart1(0).Add() 'Add a null value
tChart1(0).Add(4, 4)
tChart1(0).Add(5, 5)
Dim stream As MemoryStream = New MemoryStream()
tChart1.Export.Template.Save(stream)
stream.Position = 0
tChart2.Import.Template.Load(stream)
End Sub
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 |
Exporting/Importing problem
Hi,
The problem occurs when a line's data source is a data table, not when TChart has the value itself. Try this:
The line color is set to green before exporting, but after importing is is the default blue. If you leave out the line:
the color is still green after importing.
Jay
The problem occurs when a line's data source is a data table, not when TChart has the value itself. Try this:
Code: Select all
Dim stream As New IO.MemoryStream
Dim WhichRow As Integer
Dim Line1 As Steema.TeeChart.Styles.Line
Dim DetailsTable As New DataTable
Randomize()
DetailsTable.Columns.Add("ChartData", Type.GetType("System.Decimal"))
For WhichRow = 0 To 9
DetailsTable.Rows.Add()
DetailsTable.Rows(WhichRow)(0) = Rnd() * 100
Next WhichRow
DetailsTable.Rows(2)(0) = DBNull.Value
Line1 = New Steema.TeeChart.Styles.Line(TChart1.Chart)
Line1.DataSource = DetailsTable
Line1.YValues.DataMember = DetailsTable.Columns(0).ColumnName
Line1.Color = Color.Green
TChart1.Export.Template.IncludeData = True
TChart1.Export.Template.Save(stream)
stream.Position = 0
TChart2.Import.Template.Load(stream)
Code: Select all
DetailsTable.Rows(2)(0) = DBNull.Value
Jay
Exporting/Importing problem
I don't know if this will help, but I found that if I do this before export:
The line color is exported and imported correctly, but the nulls become zeros. Since I need to know which values are null when looking at the chart, my workaround for now is to save the color for each line to my database when a chart is exported. When I import it, I will have to query the database and set all the line colors from their saved values.
Jay
Code: Select all
TChart1.Series(0).Colors.Clear()
Jay
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi JayG,
It works fine for me here using the code snippet below. You can mark null values setting their color to transparent.
It works fine for me here using the code snippet below. You can mark null values setting their color to transparent.
Code: Select all
Private Function CreateDataSet() As DataTable
Dim DetailsTable As DataTable = New DataTable()
Dim DATA As DataColumn = New DataColumn("DATA",Type.GetType("System.Double"))
Dim COLOR As DataColumn = New DataColumn("COLOR",Type.GetType("System.Object"))
DetailsTable.Columns.Add(DATA)
DetailsTable.Columns.Add(COLOR)
Dim dataRow As DataRow
Dim y As Random = New Random()
Dim i As Integer
For i = 0 To 10- 1 Step i + 1
dataRow = DetailsTable.NewRow()
dataRow(DATA) = y.Next()
dataRow(COLOR) =(If i <> 2 Then Color.Green Else Color.Transparent)
DetailsTable.Rows.Add(dataRow)
Next
Return DetailsTable
End Function
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs)
Dim Line1 As Steema.TeeChart.Styles.Line = New Steema.TeeChart.Styles.Line(tChart1.Chart)
Line1.Clear()
Line1.DataSource = CreateDataSet()
Line1.YValues.DataMember = "DATA"
Line1.ColorMember = "COLOR"
Dim stream As System.IO.MemoryStream = New System.IO.MemoryStream()
tChart1.Export.Template.IncludeData = True
tChart1.Export.Template.Save(stream)
stream.Position = 0
tChart2.Import.Template.Load(stream)
End Sub
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 |
Exporting/Importing problem
I agree that your code could be another workaround. However, in my application where I could have 200 or more series with thousands of points each, simply saving the color of each series once in a separate database is more efficient.
Is there any chance that there will be a fix so that saving a chart with null values is as simple as saving a chart without null values? There must be something about the export or import process that is interpreting the color property (and/or other properties) differently when there are null values. How else would I be exporting a line that is displayed green and importing that same line but having it displayed blue?
Jay
Is there any chance that there will be a fix so that saving a chart with null values is as simple as saving a chart without null values? There must be something about the export or import process that is interpreting the color property (and/or other properties) differently when there are null values. How else would I be exporting a line that is displayed green and importing that same line but having it displayed blue?
Jay
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Jay,
The only solution to this would be implementing support for nullable types in TeeChart. I've added this to our wish-list to be considered for inclusion in future releases. In the meantime, the only solution is setting point's color to Color.Transparent.
The only solution to this would be implementing support for nullable types in TeeChart. I've added this to our wish-list to be considered for inclusion in future releases. In the meantime, the only solution is setting point's color to Color.Transparent.
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 |
Exporting/Importing problem
Narcis,
I want to make sure you understand that my problem is not with storing null values by making the point transparent. That works fine when working with charts "live".
The problem is that exporting and then importing a chart that has these transparent points causes the whole series to change color. Please see my post from 24 Sep 2007 at 09:30 (my first post on 24 Sep) for code that illustrates the problem.
Jay
I want to make sure you understand that my problem is not with storing null values by making the point transparent. That works fine when working with charts "live".
The problem is that exporting and then importing a chart that has these transparent points causes the whole series to change color. Please see my post from 24 Sep 2007 at 09:30 (my first post on 24 Sep) for code that illustrates the problem.
Jay
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Jay,
Yes, that's also true. I've added this defect (TF02012473) to our bug list to be fixed for next releases.
The problem is adding a null point (transparent) to the series, for example:
Yes, that's also true. I've added this defect (TF02012473) to our bug list to be fixed for next releases.
The problem is adding a null point (transparent) to the series, for example:
Code: Select all
private void Form1_Load(object sender, EventArgs e)
{
Steema.TeeChart.Styles.Line line1 = new Steema.TeeChart.Styles.Line(tChart1.Chart);
line1.FillSampleValues();
line1.Add(); //This causes Series.Color being lost
line1.Color = Color.Green;
System.IO.MemoryStream stream = new System.IO.MemoryStream();
tChart1.Export.Template.IncludeData = true;
tChart1.Export.Template.Save(stream);
stream.Position = 0;
tChart2.Import.Template.Load(stream);
}
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 Jay,
Just wanted to let you know that the issue has been fixed and will be included in the next maintenance release.
I've tested the fix works fine with your code as well.
Just wanted to let you know that the issue has been fixed and will be included in the next maintenance release.
I've tested the fix works fine with your code as well.
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 |
Exporting/Importing problem
Hi Narcís,
That was quick! Thank you. I'll keep an eye open for the next release .
Jay
That was quick! Thank you. I'll keep an eye open for the next release .
Jay