We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Drawing combinational chart (Stacked Chart along with line) to PPT

Following is the code snippet that were are using for the purpose. I've attached a ppt file along with this message. The following chart doesn't reflects the exact chart type (stacked chart) which is needed here.

IChart chart;
if (isModifiedDisplay)
{
switch (k)
{
case 1:
x = (float)PPT_FourSlides_FirstQuadrant.X1;
y = (float)PPT_FourSlides_FirstQuadrant.Y1;
break;
case 2:
x = (float)PPT_FourSlides_ThirdQuadrant.X1;
y = (float)PPT_FourSlides_ThirdQuadrant.Y1;
break;
case 3:
x = (float)PPT_FourSlides_FourthQuadrant.X1;
y = (float)PPT_FourSlides_FourthQuadrant.Y1;
break;
}

chart = (k == 1) ? slide.Shapes.AddChart(ChartType.Line, x, y, (float)PPT_ThreeSlide_SizeDimension.X2, (float)PPT_ThreeSlide_SizeDimension.Y2) :
slide.Shapes.AddChart(ChartType.Line, x, y, (float)PPT_FourSlide_SizeDimension.X2, (float)PPT_FourSlide_SizeDimension.Y2);
}
else
{
switch (k)
{
case 1:
x = (float)PPT_FourSlides_FirstQuadrant.X1;
y = (float)PPT_FourSlides_FirstQuadrant.Y1;
break;
case 2:
x = (float)PPT_FourSlides_SecondQuadrant.X1;
y = (float)PPT_FourSlides_SecondQuadrant.Y1;
break;
case 3:
x = (float)PPT_FourSlides_ThirdQuadrant.X1;
y = (float)PPT_FourSlides_ThirdQuadrant.Y1;
break;
case 4:
x = (float)PPT_FourSlides_FourthQuadrant.X1;
y = (float)PPT_FourSlides_FourthQuadrant.Y1;
break;
}

chart = slide.Shapes.AddChart(ChartType.Line, x, y, (float)PPT_FourSlide_SizeDimension.X2, (float)PPT_FourSlide_SizeDimension.Y2);
}

//Setting Chart Title
chart.TextFormat.PortionFormat.FontHeight = fontSize;
chart.ChartTitle.AddTextFrameForOverriding(chartModel.chart.Caption.IsNullOrEmpty(true));
chart.ChartTitle.TextFrameForOverriding.TextFrameFormat.WrapText = NullableBool.True;
chart.HasTitle = true;
//Setting the index of chart data sheet
int defaultWorksheetIndex = 0;
IChartDataWorkbook fact = chart.ChartData.ChartDataWorkbook;
int seriesIndex = 1, categoryIndex = 1;

//Delete default generated series and categories
chart.ChartData.Series.Clear();
chart.ChartData.Categories.Clear();

foreach (ChartDataSet dataset in chartModel.dataset)
{
int dataIndex = 1;
string getChart = GetAsposeChartType(dataset.renderAs);

if (!string.IsNullOrEmpty(getChart))
{
var chartT = (ChartType)Enum.Parse(typeof(ChartType), getChart);
chart.ChartData.Series.Add(fact.GetCell(defaultWorksheetIndex, 0, seriesIndex, dataset.seriesname), chartT);
}

if (chart.ChartData != null && chart.ChartData.Series.Count > 0)
{
//Take first chart series
IChartSeries series = chart.ChartData.Series[seriesIndex - 1];
//Set first series to Show Values
chart.ChartData.Series[seriesIndex - 1].Labels.DefaultDataLabelFormat.ShowValue = true;
foreach (TKMIP.Entity.Charts.Model.ChartData data in dataset.data)
{
if (getChart == Constant.Chart_StackedColumn || getChart == Constant.Chart_ClusteredColumn || getChart == Constant.Chart_StackedBar)
{
series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, dataIndex++, seriesIndex, data.value));
}
else if (getChart == Constant.Chart_Line)
{
series.DataPoints.AddDataPointForLineSeries(fact.GetCell(defaultWorksheetIndex, dataIndex++, seriesIndex, data.value));
}
else
{
series.DataPoints.AddDataPointForLineSeries(fact.GetCell(defaultWorksheetIndex, dataIndex++, seriesIndex, data.value));
}
}
seriesIndex++;
}
}

Hi,


Thank you for your interest in Aspose.Slides.

I have observed your comments and the file shared by you, but I have not been able to understand it completely. Please explain it to us and share a sample application, instead of some part of the code, to reproduce the issue; so that we may investigate it further to help you out.

Best Regards,
Thanks for your reply. The problem that I'd mentioned had worked out. We added the property of overlay to the chart series and it gave us the desired output of stacked column.

Hi,


Thank you for your valuable feedback.

We are glad to know that your issue is resolved and things have started working on your end.

Please feel free to contact us if we could be of any help to you.

Best Regards,