Jump to content
Software FX Community

Clear AxesY cause to export fail


AlexeyRedko

Recommended Posts

Hi,

I have a PDF report generator that contains many charts. That reason lead me to create only one chart and clear its properties before I export it to an image each time. What I got is a report with only one chart (the first one), so I sieve all my custom method and I found that AxesY.Clear() lead to 'Object reference not set to an instance of an object.' exception when I'm trying to export (any other chart properties clear method not damaging).

Sample code:

			[color= rgb(43, 145, 175);]Chart[/color] WPFChart = [color= blue;]new[/color] [color= rgb(43, 145, 175);]Chart[/color](); 			[color= green;]// First chart fill[/color]			[color= rgb(43, 145, 175);]SeriesAttributes[/color] SA = [color= blue;]new[/color] [color= rgb(43, 145, 175);]SeriesAttributes[/color]();			SA.ItemsSource = [color= blue;]new[/color] [color= rgb(43, 145, 175);]List[/color]<[color= blue;]double[/color]>() { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };			SA.Stroke = [color= rgb(43, 145, 175);]Brushes[/color].Red;			SA.StrokeThickness = 2d;			SA.Gallery = [color= rgb(43, 145, 175);]Gallery[/color].Line;			WPFChart.Series.Add(SA); 			[color= green;]// Clear chart [/color]			WPFChart.Series.Clear();			WPFChart.AxesY.Clear();	  		    [color= green;]// Second chart fill[/color]			SA = [color= blue;]new[/color] [color= rgb(43, 145, 175);]SeriesAttributes[/color]();			SA.ItemsSource = [color= blue;]new[/color] [color= rgb(43, 145, 175);]List[/color]<[color= blue;]double[/color]>() { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };			SA.Stroke = [color= rgb(43, 145, 175);]Brushes[/color].Red;			SA.StrokeThickness = 2d;			SA.Gallery = [color= rgb(43, 145, 175);]Gallery[/color].Line;			WPFChart.Series.Add(SA); 			[color= green;]// Export chart to file[/color]			[color= blue;]string[/color] FilePath = [color= rgb(163, 21, 21);]@"C:\Temp\TestWPFChart.png"[/color]; 			[color= blue;]if[/color] ([color= rgb(43, 145, 175);]File[/color].Exists(FilePath))				[color= rgb(43, 145, 175);]File[/color].Delete(FilePath); 			[color= blue;]using[/color] ([color= rgb(43, 145, 175);]FileStream[/color] FS = [color= blue;]new[/color] [color= rgb(43, 145, 175);]FileStream[/color](FilePath, [color= rgb(43, 145, 175);]FileMode[/color].CreateNew))			{				WPFChart.Export([color= rgb(43, 145, 175);]FileFormat[/color].Png, FS); // Export crush!!!		    }
I'm looking for some workaround or ideas.
Thanks,
Alexey 

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...