We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

In memory chart doesn't render.

Thread ID:





124248 May 26,2016 12:05 PM May 27,2016 08:04 AM WPF 2
Tags: SfChart
Stefano Tessarin
Asked On May 26, 2016 12:05 PM

Hi we aim print some graph and we thought to use SFCharts, but the plots are always empty, what's wrong?

this is the code:

        private SfChart DrawGraph(ObservableCollection<Sample> data, double start, double width, double? min, double? max)
            var graph = new SfChart
                Margin = new Thickness(10),
                AreaBorderThickness = new Thickness(0, 1, 1, 1),
                Background = Brushes.Black,
                FontFamily = new FontFamily("Courier New")

            var gridLineStyle = new System.Windows.Style
                TargetType = typeof(Line),
                Setters = { new Setter { Property = Line.StrokeProperty, Value = Brushes.DimGray } }

            graph.PrimaryAxis = new CategoryAxis
                MajorGridLineStyle = gridLineStyle,
                MinorGridLineStyle = gridLineStyle,
                Header = "Space",
                LabelFormat = "0.00",
                FontSize = 10,
                Foreground = Brushes.LimeGreen,
                FontWeight = FontWeights.Normal,
                EdgeLabelsDrawingMode = EdgeLabelsDrawingMode.Fit

            graph.SecondaryAxis = new NumericalAxis
                MajorGridLineStyle = gridLineStyle,
                MinorGridLineStyle = gridLineStyle,
                Header = "Value",
                Foreground = Brushes.LimeGreen,
                FontWeight = FontWeights.Normal,
                StripLines = new ChartStripLines(),
                Minimum = min,
                Maximum = max,
                LabelFormat = "0.00",
                Interval = (max - min) / 7

            graph.SecondaryAxis.StripLines.Add(new ChartStripLine
                Start = start,
                Width = width,
                Background = (SolidColorBrush)new BrushConverter().ConvertFromString("#8890ee90"),
                BorderBrush = Brushes.GreenYellow,
                BorderThickness = new Thickness(1.5)

            var line = new FastLineBitmapSeries
                Interior = Brushes.Yellow,
                StrokeThickness = 0.5,
                ItemsSource = data,
                XBindingPath = "Space2",
                YBindingPath = "Value",
                Trendlines = new ChartTrendLineCollection()

            return graph;

        private byte[] GraphToByteArray(SfChart graph, double printWidth, double printHeight)
            Size size = new Size(printWidth, printHeight);
            graph.Measure(new Size(printWidth / 2, printHeight / 2));
            graph.Arrange(new Rect(new Size(printWidth / 2, printHeight / 2)));

            RenderTargetBitmap renderBitmap =
                new RenderTargetBitmap(

            byte[] ret = null;

            using (MemoryStream outStream = new MemoryStream())
                BmpBitmapEncoder encoder = new BmpBitmapEncoder();

                //graph.Save(outStream, encoder);
                ret = outStream.ToArray();

            return ret;

This is the chart in a xaml window

While this is the chart printed from c# code

We have used the same parameters from the xaml page and the same data is binded to the
FastLineBitmapSeries, but as you can see the line does not appear.

Stefano Tessarin
Replied On May 27, 2016 02:45 AM

We were able to solve it by simply use PngBitmapEncoder instead of BmpBitmapEncoder.

Devi Aruna Maharasi Murugan [Syncfusion]
Replied On May 27, 2016 08:04 AM

Hi Stefano, 
Thanks for contacting Syncfusion Support. 
We are unable to reproduce the problem while save the chart using your code. We have prepared the sample based on your requirement and please find the sample in the below location.  
Also, by default SfChart having Print support. Please find the below documents for print.  
Devi M. 



This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.