This is a migrated thread and some comments may be shown as answers.

RadChart throws StackOverflow Exception when saving Xaml

1 Answer 45 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Alexander
Top achievements
Rank 1
Alexander asked on 08 Sep 2016, 03:56 PM

I am working on a project that takes some basic controls and some telerik wpf controls, places them on a canvas, and saves these for redisplay later. All of the controls are generated at runtime.

Whenever I attempt to save the Xaml of a RadChart, after approximately 30 seconds, the XamlWriter.Save method throws a StackOverflow exception. The problem is reproducible.

Create project referencing the .NET Framework 4.

Telerik.Window.Controls
Telerik.Window.Controls.Chart
Telerik.Window.Controls.Charting
Telerik.Window.Controls.Data
Telerik.Window.Controls.DataVisualization
Telerik.Window.Data

Place the following code on a new window:

<Canvas Name="testCanvas" Height="350" Width="525">
    <telerik:RadChart Name="testChart" Height="350" Width="525"/>
</Canvas>

Place this in code-behind:

public MainWindow()
{
    InitializeComponent();
    this.PreviewMouseDoubleClick += Window_PreviewMouseDoubleClick;
    testCanvas.Loaded += testCanvas_Loaded;
}
private void testCanvas_Loaded(object sender, RoutedEventArgs e)
{
    testChart.DefaultView.ChartLegend.UseAutoGeneratedItems = true;
    Telerik.Windows.Controls.Charting.DataSeries barSeries = new Telerik.Windows.Controls.Charting.DataSeries();
    barSeries.LegendLabel = "Expenses";
    barSeries.Definition = new Telerik.Windows.Controls.Charting.BarSeriesDefinition();
    barSeries.AddRange(new List<Telerik.Windows.Controls.Charting.DataPoint> {
        new Telerik.Windows.Controls.Charting.DataPoint() { YValue = 45, XCategory = "Jan" },
        new Telerik.Windows.Controls.Charting.DataPoint() { YValue = 48, XCategory = "Feb" },
        new Telerik.Windows.Controls.Charting.DataPoint() { YValue = 53, XCategory = "Mar" },
        new Telerik.Windows.Controls.Charting.DataPoint() { YValue = 41, XCategory = "Apr" },
        new Telerik.Windows.Controls.Charting.DataPoint() { YValue = 32, XCategory = "May" },
        new Telerik.Windows.Controls.Charting.DataPoint() { YValue = 28, XCategory = "Jun" },
        new Telerik.Windows.Controls.Charting.DataPoint() { YValue = 63, XCategory = "Jul" },
        new Telerik.Windows.Controls.Charting.DataPoint() { YValue = 74, XCategory = "Aug" },
        new Telerik.Windows.Controls.Charting.DataPoint() { YValue = 77, XCategory = "Sep" },
        new Telerik.Windows.Controls.Charting.DataPoint() { YValue = 85, XCategory = "Oct" },
        new Telerik.Windows.Controls.Charting.DataPoint() { YValue = 89, XCategory = "Nov" },
        new Telerik.Windows.Controls.Charting.DataPoint() { YValue = 80, XCategory = "Dec" }
    });
    testChart.DefaultView.ChartArea.DataSeries.AddRange(new List<Telerik.Windows.Controls.Charting.DataSeries> { barSeries });
}
 
private void Window_PreviewMouseDoubleClick(object sender, MouseButtonEventArgs e)
{
 
    var fileName = @"c:\temp\tester.xaml";
    using (var fs = new FileStream(fileName, FileMode.Create, FileAccess.Write, FileShare.Read))
    using (var xw = new XmlTextWriter(fs, System.Text.Encoding.UTF8))
    {
        xw.Formatting = Formatting.Indented;
        xw.Indentation = 4;
        xw.IndentChar = ' ';
 
        //place breakpoint here
        XamlWriter.Save(testCanvas, xw);
    }
}

Run project and then double-click the window. At the "XamlWriter.Save(testCanvas, xw)", a stackoverflow exception will eventually occur

Please let me know what I can do to correct this issue.

 

Thanks

1 Answer, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 13 Sep 2016, 10:41 AM
Hello Alexander,

Note that RadChart has many known issues and limitations. This is why we created the new RadChartView. I recommend you to try it and see if it works for you. The new charting components have better implementation and improved performance. You can learn more about this in the RadChart vs. RadChartView help article.

I tested your code with RadCartesianChart (part of RadChartView) and the exception is not reproduced.

Regards,
Martin
Telerik by Progress
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Tags
Chart
Asked by
Alexander
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Share this question
or