Add Secondary Chart Axis for Overlapped Column Chart Image

Hello,

How can I get these column bars to overlap?

Sample code snippet:
 
IPresentation pptxDoc = Presentation.Create(); 
// Create an instance of Presentation Renderer for converting chart to image 
pptxDoc.PresentationRenderer = new PresentationRenderer(); 
//Adds a blank slide to the Presentation 
ISlide slide = pptxDoc.Slides.Add(SlideLayoutType.Blank); 
//Adds chart to the slide with position and size 
IPresentationChart chart = slide.Charts.AddChart(100, 10, 700, 500); 
//Specifies the chart title 
chart.ChartTitle = "Sales Analysis"; 
//Specifies the chart type 
chart.ChartType = OfficeChartType.Column_Stacked; 
//Sets chart data - Row1 
chart.ChartData.SetValue(1, 2, "Jan"); 
chart.ChartData.SetValue(1, 3, "Feb"); 
//Sets chart data - Row2 
chart.ChartData.SetValue(2, 1, 2010); 
chart.ChartData.SetValue(2, 2, 900); 
chart.ChartData.SetValue(2, 3, 800); 
//Sets chart data - Row3 
chart.ChartData.SetValue(3, 1, 2011); 
chart.ChartData.SetValue(3, 2, 800); 
chart.ChartData.SetValue(3, 3, 700);
//Sets chart data - Row4 
chart.ChartData.SetValue(4, 1, 2012); 
chart.ChartData.SetValue(4, 2, 700); 
chart.ChartData.SetValue(4, 3, 600); 
//Sets the data range of the category axis 
chart.PrimaryCategoryAxis.CategoryLabels = chart.ChartData[2, 1, 4, 1];
//Creates a new chart series with the name 
IOfficeChartSerie seriesJan = chart.Series.Add("Jan"); 
//Sets the data range of chart series – start row, start column, end row, end column 
seriesJan.Values = chart.ChartData[2, 2, 4, 2]; 
//Creates a new chart series with the name 
IOfficeChartSerie seriesFeb = chart.Series.Add("Feb"); 
//Sets the data range of chart series – start row, start column, end row, end column 
seriesFeb.Values = chart.ChartData[2, 3, 4, 3]; 
//Set the primary axis for the serie
seriesFeb.UsePrimaryAxis = false;
using (var stream = new MemoryStream()) 
{ 
    pptxDoc.PresentationRenderer.ConvertToImage(chart, stream); 
    slide.Shapes.AddPicture(stream, 100, 10, 700, 500); 
} 
FileStream outputStream = new FileStream("Sample.pptx", FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite); 
pptxDoc.Save(outputStream); 
pptxDoc.Close(); 
outputStream.Flush(); 
outputStream.Dispose(); 
 

I'm using the latest Syncfusion.Presentation.Net.Core and Syncfusion.PresentationRenderer.Net.Core nuget package versions (v19.1.0.57)

Thanks in advance!


6 Replies

LB Lokesh Baskar Syncfusion Team May 10, 2021 07:50 AM UTC

Hi Yasmin,

Thank you for contacting Syncfusion support.

From the given details, we suspect that your requirement is to generate Stacked Column chart in presentation. Please refer the KB documentation given in below link.

https://www.syncfusion.com/kb/6427/how-to-add-stacked-column-chart-in-presentation

Please let us know if you have any other questions.

Regards,
Lokesh B
 



YE Yasmin Eldokany May 10, 2021 10:58 AM UTC

Hi Lokesh,

Thanks for your reply, no I'd like an overlapped column chart rather than a stacked column chart.

I also tried using a Column_Clustered chart and setting the serie's Overlap format to 100% (using this documentation reference)

//Set the serie format of chart
serieFeb.SerieFormat.CommonSerieOptions.Overlap = 100;
serieFeb.SerieFormat.CommonSerieOptions.GapWidth= 50;
But still the resulting chart image looks like this:



LB Lokesh Baskar Syncfusion Team May 11, 2021 05:07 PM UTC


On further analysis on the given code snippet, we have found that when we create a chart using Essential Presentation and converting the chart to image and then save it as pptx. We have the same reported issue. Please refer to the screenshot given below.

 
 

When we save as pptx document without converting chart to image, then we can achieve your requirement. We have prepared the sample to achieve your end requirement. Please refer to the sample link given below.
https://www.syncfusion.com/downloads/support/forum/165300/ze/PresentationSample160500476.zip

Please refer to the generated output from sample in the below screenshot.
 
 

 
We have a different output between when export chart as image and not export chart as image.  We suspect that this could be an issue.  We will validate this issue and update you the further details on 13th May 2021. 

If we misunderstood your requirement means, could you please share with us the expected output document. Thereby, we will check further on your requirement and will provide you the appropriate solution at the earliest.

Please let us know if you have any other questions.

Regards, 
Lokesh B 



LB Lokesh Baskar Syncfusion Team May 13, 2021 01:17 PM UTC


We are facing some complexities while validating the reported issue in Office chart to Image conversion. Currently, we are checking with corresponding team. We will validate and update you with more details on 17th May 2021.
 

Please lets us know if you have any other questions.

Regards,
Lokesh B
 



LB Lokesh Baskar Syncfusion Team May 17, 2021 06:24 PM UTC

Hi Yasmin,

We deeply regret for the inconveniences caused.

We are facing some complexities while validating the reported in Office chart to Image conversion and we need some time to analyze the behavior to check the feasibility to resolve the reported issue. Currently, we are validating on this issue with high priority and will update you with more details on 18th May 2021.

Please let us know if you have any other questions.

Regards,
Lokesh B
 



LB Lokesh Baskar Syncfusion Team May 18, 2021 01:45 PM UTC

Hi Yasmin,

Thank you for your patience.

On further analyzing the reported chart series is not overlapping in chart to image conversion, we have found that we does not support for series overlapping in chart to image conversion. We have logged this as a feature request in our database and also, we do not have any immediate plans to implement this feature. At the planning stage for every release cycle, we review all open features. We will let you know when this feature is implemented.

The status of the feature report can be tracked through the below link:
https://www.syncfusion.com/feedback/25428/support-chart-series-overlapping-in-the-chart-to-image-conversion  

Please lets us know if you have any other questions.

Regards,
Lokesh B



Loader.
Up arrow icon