I am trying to export my WPF chart control to an image but I am getting an exception saying "Object reference not set". I am wondering what I am doing wrong here.
I am trying to export to xps.
My another requirement is to convert to jpeg.
Can you guys please help me doing this?
SeriesMapping sm1 = new SeriesMapping();
sm1.SeriesDefinition = new LineSeriesDefinition();
sm1.LegendLabel = "Line Series 1";
sm1.CollectionIndex = 0;
ItemMapping im1 = new ItemMapping();
im1.DataPointMember = DataPointMember.YValue;
sm1.ItemMappings.Add(im1);
SeriesMapping sm2 = new SeriesMapping();
sm2.SeriesDefinition = new LineSeriesDefinition();
sm2.LegendLabel = "Line Series 2";
sm2.CollectionIndex = 1;
ItemMapping im2 = new ItemMapping();
im2.DataPointMember = DataPointMember.YValue;
sm2.ItemMappings.Add(im2);
var itemsSource = new List<double>[] { new List<double> { 9, 2, 3, 4 }, new List<double> { 5, 7, 3, 4 } };
this.RadChart1.SeriesMappings.Add(sm1);
this.RadChart1.SeriesMappings.Add(sm2);
this.RadChart1.ItemsSource = itemsSource;
Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();
dlg.DefaultExt = ".xps";
string fileName = string.Empty;
I am trying to export to xps.
My another requirement is to convert to jpeg.
Can you guys please help me doing this?
SeriesMapping sm1 = new SeriesMapping();
sm1.SeriesDefinition = new LineSeriesDefinition();
sm1.LegendLabel = "Line Series 1";
sm1.CollectionIndex = 0;
ItemMapping im1 = new ItemMapping();
im1.DataPointMember = DataPointMember.YValue;
sm1.ItemMappings.Add(im1);
SeriesMapping sm2 = new SeriesMapping();
sm2.SeriesDefinition = new LineSeriesDefinition();
sm2.LegendLabel = "Line Series 2";
sm2.CollectionIndex = 1;
ItemMapping im2 = new ItemMapping();
im2.DataPointMember = DataPointMember.YValue;
sm2.ItemMappings.Add(im2);
var itemsSource = new List<double>[] { new List<double> { 9, 2, 3, 4 }, new List<double> { 5, 7, 3, 4 } };
this.RadChart1.SeriesMappings.Add(sm1);
this.RadChart1.SeriesMappings.Add(sm2);
this.RadChart1.ItemsSource = itemsSource;
Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();
dlg.DefaultExt = ".xps";
string fileName = string.Empty;
if (!((bool)dlg.ShowDialog()))
{
fileName = dlg.FileName;
}
this.RadChart1.ExportToXps(fileName);