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

Free Support Forum - aspose.com

Plotting 0 for null values

HI,

I am exporting ppt chart using aspose 15.9. In case of line series i am passing empty data for first two category but it is automatically plotting the line as 0 value .I am attaching the ppt with sample data.
Data for line series is
2012 -
2013-
2014- 115.4
2015- 135
2016- 154.5
2017- 174.1
2018- 193.6

Data is blank fot 2012 and 2013 but line for 2012 and 2013 is plotting as 0
I want to display line from 2014 ,How to fix this issue.


Hi,


Thank you for posting.

I have observed your comments and like to request you to please share with us the sample code and generated output file so that we may investigate it further to help you out.

Best Regards,
Code for creating chart & attached output file

foreach (TKMIP.Entity.Charts.Model.ChartData data in dataset.data)
{
if (getChart == Constant.Chart_StackedColumn || getChart == Constant.Chart_ClusteredColumn)
{
if (data.value != "")
{
series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, dataIndex++, seriesIndex, Convert.ToDouble(data.value)));
}
else
{
series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, dataIndex++, seriesIndex, data.value));
}
if (getChart == Constant.Chart_StackedColumn)
{
if (series.Overlap == 0)
{
series.ParentSeriesGroup.Overlap = 100;
}
}
}
else if (getChart == Constant.Chart_StackedBar)
{
if (data.value != "")
{
series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, dataIndex++, seriesIndex, Convert.ToDouble(data.value)));
}
else
{
series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, dataIndex++, seriesIndex, data.value));
}
}
else if (getChart == Constant.Chart_Line)
{
if (dataset.seriesname.ToUpper().Contains("CAGR"))
{
chart.ChartData.Series[seriesIndex - 1].Labels.DefaultDataLabelFormat.ShowValue = false;
}
if (data.value != "")
{
series.DataPoints.AddDataPointForLineSeries(fact.GetCell(defaultWorksheetIndex, dataIndex++, seriesIndex, Convert.ToDouble(data.value)));
isLineChartStatus = true;
}
else
{
series.DataPoints.AddDataPointForLineSeries(fact.GetCell(defaultWorksheetIndex, dataIndex++, seriesIndex, data.value));
isLineChartStatus = true;
}
}
else
{
if (data.value != "")
{
series.DataPoints.AddDataPointForLineSeries(fact.GetCell(defaultWorksheetIndex, dataIndex++, seriesIndex, Convert.ToDouble(data.value)));
isLineChartStatus = true;
}
else
{
series.DataPoints.AddDataPointForLineSeries(fact.GetCell(defaultWorksheetIndex, dataIndex++, seriesIndex, data.value));
isLineChartStatus = true;
}
}
}

Hi,


I have observer your comments and like to request you once again to please share with us the sample application to reproduce the issue because this code has dependencies on a dataset so I am unable to generate the same chart on my end. Please share with us the requested data so that we may proceed further to help you out. Also, before you share the data, please try using Aspose.Slides for .NET 15.10.0 on your end.

Best Regards,
Presentation pres = new Presentation();

//Access first slide
ISlide sld = pres.Slides[0];

// Add chart with default data
IChart chart = sld.Shapes.AddChart(ChartType.ClusteredColumn, 0, 0, 500, 500);

//Setting chart Title
//chart.ChartTitle.TextFrameForOverriding.Text = "Sample Title";
chart.ChartTitle.AddTextFrameForOverriding("Sample Title");
chart.ChartTitle.TextFrameForOverriding.TextFrameFormat.CenterText = NullableBool.True;
chart.ChartTitle.Height = 20;
chart.HasTitle = true;

//Set first series to Show Values
chart.ChartData.Series[0].Labels.DefaultDataLabelFormat.ShowValue = true;

//Setting the index of chart data sheet
int defaultWorksheetIndex = 0;

//Getting the chart data worksheet
IChartDataWorkbook fact = chart.ChartData.ChartDataWorkbook;

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

//Adding new series
chart.ChartData.Series.Add(fact.GetCell(defaultWorksheetIndex, 0, 1, "Series 1"), ChartType.StackedColumn);
chart.ChartData.Series.Add(fact.GetCell(defaultWorksheetIndex, 0, 2, "Series 2"), ChartType.StackedColumn);
chart.ChartData.Series.Add(fact.GetCell(defaultWorksheetIndex, 0, 3, "cagr"), ChartType.Line);

//Adding new categories
chart.ChartData.Categories.Add(fact.GetCell(defaultWorksheetIndex, 1, 0, "Caetegoty 1"));
chart.ChartData.Categories.Add(fact.GetCell(defaultWorksheetIndex, 2, 0, "Caetegoty 2"));
chart.ChartData.Categories.Add(fact.GetCell(defaultWorksheetIndex, 3, 0, "Caetegoty 3"));

//Take first chart series
IChartSeries series = chart.ChartData.Series[0];

// Now populating series data

series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, 1, 1, 20));
series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, 2, 1, 50));
series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, 3, 1, 30));


//Setting fill color for series
series.Format.Fill.FillType = FillType.Solid;
series.Format.Fill.SolidFillColor.Color = Color.Red;


//Take second chart series
series = chart.ChartData.Series[1];

//Now populating series data
series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, 1, 2, 30));
series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, 2, 2, 10));
series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, 3, 2, 60));

//Setting fill color for series
series.Format.Fill.FillType = FillType.Solid;
series.Format.Fill.SolidFillColor.Color = Color.Green;
series = chart.ChartData.Series[2];
series.DataPoints.AddDataPointForLineSeries(fact.GetCell(defaultWorksheetIndex, 1, 3, ""));
series.DataPoints.AddDataPointForLineSeries(fact.GetCell(defaultWorksheetIndex, 2, 3, 50));
series.DataPoints.AddDataPointForLineSeries(fact.GetCell(defaultWorksheetIndex, 3, 3, 50));
series.Format.Fill.FillType = FillType.Solid;
series.Format.Fill.SolidFillColor.Color = Color.Olive;
pres.Save("C:\\Presentations\\AsposeChart.pptx", SaveFormat.Pptx);
Hi,

I have observed your requirements and worked with the code shared by you. I have been able to reproduce the issue. A ticket with ID SLIDESNET-37060 has been logged in our issue tracking system to further investigate and resolve the issue.This thread has been linked with the issue so that you may be automatically notified once the issue will be resolved.

We are sorry for your inconvenience,

The issues you have found earlier (filed as SLIDESNET-37060) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.