Jump to content
Software FX Community

Export/Import not working...


User (Legacy)

Recommended Posts

I'm kicking the tires of ChartFX 6.2 and created an app that should allow 

end-users to modify a graph on the screen go Gallery.Doughnut using the

built in tools, then save the report into a memory stream by clicking

btnExport. Then I change the graph from Gallery.Doughnut to Gallery.Pie.

When the I click on the second button (btnImport), the memory stream should

get imported back into the graph and it should return to Gallery.Doughnut

but it isn't working... No error messages, just that the graph does not

change. I'm using the code below:

private MemoryStream myChart = new MemoryStream();

private void btnExport(object sender, System.EventArgs e) {

chart1.Export(FileFormat.XML, myChart);

//I used the code below to verify that myChart really did contain data and

it did.

byte[] byteArray = myChart.ToArray();

easy = Encoding.UTF8.GetString(byteArray, 0, byteArray.Length);

MessageBox.Show(easy);

}

private void btnImport(object sender, System.EventArgs e) {

try {

chart1.Import(FileFormat.XML, myChart);

chart1.Refresh();

}

catch (Exception ex) {

MessageBox.Show(ex.Message);

}

}

Am I doing something wrong or are there issues with the Export/Import

functionality?

Thanks,

Bret.

post-2107-13922379569725_thumb.gif

Link to comment
Share on other sites

Please note that Exporting to an XML behaves in a special way because only 

properties different than the default value are exported. If you are not

interested in having the chart as text (as it seems in your case as the

memory stream since to be localized to the current instance of your app) I

would recommend you use FileFormat.Binary.

In any case, try resetting the stream position before importing the chart,

e.g.

myChart.Position = 0;

Regards,

JC

Software FX Support

"Bret Lowry" <bretl@sunbelt-software.com> wrote in message

news:iL5Ml$pPFHA.1804@webserver3.softwarefx.com...

> I'm kicking the tires of ChartFX 6.2 and created an app that should allow

> end-users to modify a graph on the screen go Gallery.Doughnut using the

> built in tools, then save the report into a memory stream by clicking

> btnExport. Then I change the graph from Gallery.Doughnut to Gallery.Pie.

> When the I click on the second button (btnImport), the memory stream

> should get imported back into the graph and it should return to

> Gallery.Doughnut but it isn't working... No error messages, just that the

> graph does not change. I'm using the code below:

> private MemoryStream myChart = new MemoryStream();

>

> private void btnExport(object sender, System.EventArgs e) {

>

> chart1.Export(FileFormat.XML, myChart);

>

> //I used the code below to verify that myChart really did contain data and

> it did.

>

> byte[] byteArray = myChart.ToArray();

>

> easy = Encoding.UTF8.GetString(byteArray, 0, byteArray.Length);

>

> MessageBox.Show(easy);

>

> }

>

> private void btnImport(object sender, System.EventArgs e) {

>

> try {

>

> chart1.Import(FileFormat.XML, myChart);

>

> chart1.Refresh();

>

> }

>

> catch (Exception ex) {

>

> MessageBox.Show(ex.Message);

>

> }

>

> }

>

> Am I doing something wrong or are there issues with the Export/Import

> functionality?

>

> Thanks,

>

> Bret.

>

>

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...