Export diagramm shrink picture

Hello!

When i exporting diagramm it's shrink image in strange way.

I use Save method of sfChart with filename.


Chart is places in Grid


Attachment: INITAL_d14b0e0a.zip

3 Replies 1 reply marked as answer

GM Gayathri Manickam Syncfusion Team October 5, 2021 12:46 PM UTC

Hi Anton, 
 
Greetings from Syncfusion 
 
We have analyzed your query “Exported chart image shrink in Grid” and we can be able to reproduce the issue. You can resolve the issue by adding the below code snippet instead of Save method in the chart. Please refer the sample given below. 
 
Code snippet[C#] : 
          string fileName = "ExportedChart.png"; 
 
            FrameworkElement element = chart; 
            string imageExtension = null; 
            imageExtension = new FileInfo(fileName).Extension.ToLower(System.Globalization.CultureInfo.InvariantCulture); 
            BitmapEncoder imgEncoder = null; 
            imgEncoder = new PngBitmapEncoder(); 
            if (element != null) 
            { 
                DrawingVisual visual = new DrawingVisual(); 
                using (DrawingContext context = visual.RenderOpen()) 
                { 
                    var brush = new VisualBrush(element) { Stretch = Stretch.Fill }; 
                    context.DrawRectangle(brush, null, new Rect(0, 0, element.ActualWidth, element.ActualHeight)); 
                    context.Close(); 
                } 
 
                RenderTargetBitmap bitmap = new RenderTargetBitmap((int)element.ActualWidth, (int)element.ActualHeight, 96, 96, PixelFormats.Pbgra32); 
                bitmap.Render(visual); 
 
                imgEncoder.Frames.Add(BitmapFrame.Create(bitmap)); 
                using (Stream stream = File.Create(fileName)) 
                { 
                    imgEncoder.Save(stream); 
                } 
            } 
        } 
 
 
Thanks  
Gayathri M.  


Marked as answer

AN Anton October 5, 2021 02:43 PM UTC

Got some crop on the right side (legend)

<syncfusion:SfChart.Legend>

                    <syncfusion:ChartLegend

                        Margin="0,0,0,5"

                        HorizontalAlignment="Center"

                        VerticalAlignment="Center"

                        BorderBrush="Black"

                        BorderThickness="1"

                        CheckBoxVisibility="Visible"

                        CornerRadius="5"

                        DockPosition="Right"

                        IconHeight="10"

                        IconVisibility="Collapsed"

                        IconWidth="10"

                        ItemMargin="5" />

                </syncfusion:SfChart.Legend>


Attachment: export_c90b0a4b.zip


DD Devakumar Dhanapoosanam Syncfusion Team October 6, 2021 04:40 PM UTC

Hi Anton,

Query: Got some crop on the right side (legend)
We have tried to replicate the reported issue based on the provided code snippet using the ChartLegend, but we are afraid, that we were unable to reproduce the reported issue “crop on right side with legend” at our end. The sample we tested can be downloaded from the below location and exported image attached in the sample.

Output:
Since we are not aware of your exact application scenario, we were not able to reproduce this at our end, can you please revert us by modifying the sample based on your application along with replication procedure. This will be helpful for us to provide you better solution at the earliest.

Regards,
Devakumar D



Loader.
Up arrow icon