ClusteredBar chart with null values


#1

Dear,


I am using ASPose.Slide version 7.3 to create a .pptx presentation in which i added a simple clustered bar chart. For some bars (based on rules i have in my application), I need to hide only the bar and keep the value in the CategoryAxis, kindly find the result i desire in “ClusteredBar after edit.png” screenshot. In order to do so i am using a “null” value for the bar i need to hide, kindly find the code i am using bellow:
private void CreateSlide()
{
SlideEx slide = pres.Slides[0];
ChartEx clusteredBarChart = slide.Shapes.AddChart(ChartTypeEx.ClusteredBar, 10, 10, 400, 400);

clusteredBarChart.CategoryAxis.IsPlotOrderReversed = true;
clusteredBarChart.HasLegend = false;
clusteredBarChart.GapWidth = 20;
clusteredBarChart.ChartData.Series.Clear();
clusteredBarChart.ChartData.Categories.Clear();

clusteredBarChart.ValueAxis.IsVisible = false;
clusteredBarChart.CategoryAxis.TickLabelPosition = TickLabelPositionType.Low;

ChartDataCellFactory fact = clusteredBarChart.ChartData.ChartDataCellFactory;
clusteredBarChart.ChartData.Series.Add(fact.GetCell(0, 0, 1, “Series 1”), clusteredBarChart.Type);
ChartSeriesEx series = clusteredBarChart.ChartData.Series[0];

clusteredBarChart.ChartData.Categories.Add(fact.GetCell(0, 1, 0, “C1”));
series.Values.Add(fact.GetCell(0, 1, 1, 24));
clusteredBarChart.ChartData.Categories.Add(fact.GetCell(0, 2, 0, “C2”));
series.Values.Add(fact.GetCell(0, 2, 1, 23));
clusteredBarChart.ChartData.Categories.Add(fact.GetCell(0, 3, 0, “C3”));
series.Values.Add(fact.GetCell(0, 3, 1, -10));
clusteredBarChart.ChartData.Categories.Add(fact.GetCell(0, 4, 0, “C4”));
series.Values.Add(fact.GetCell(0, 4, 1, null));
series.Labels.TextProperties.Paragraphs[0].ParagraphFormat.DefaultPortionFormat.FillFormat.FillType = FillTypeEx.Solid;
series.Labels.TextProperties.Paragraphs[0].ParagraphFormat.DefaultPortionFormat.FontHeight = 12;
series.Labels.ShowValue = true;
}

In “ClusteredBar before edit.png” screenshot, you can realist that setting a null value for any bar leads in removing the bar completely from the chart (bar + Category Axis)(C4 does not show in the Axis). But when I click “Edit Data” in the chart, the value of the bar appears in the Axis and still the bar is hidden, as shows “ClusteredBar after edit.png” screenshot (now C4 shows in the Axis).

Is there any way I could do to have the result in “ClusteredBar after edit.png” screenshot without the need to click on “Edit Data”.

Thank you in advance,
Sami Simon

#2

Hi Sami Simon,


I have observed the requirements shared by you. Please use the following sample code to serve the purpose. Please share, if I may help you further in this regard.

PresentationEx pres = new PresentationEx();
SlideEx slide = pres.Slides[0];
ChartEx clusteredBarChart = slide.Shapes.AddChart(ChartTypeEx.ClusteredBar, 10, 10, 400, 400);

clusteredBarChart.CategoryAxis.IsPlotOrderReversed = true;
clusteredBarChart.HasLegend = false;
clusteredBarChart.GapWidth = 20;
clusteredBarChart.ChartData.Series.Clear();
clusteredBarChart.ChartData.Categories.Clear();

clusteredBarChart.ValueAxis.IsVisible = false;
clusteredBarChart.CategoryAxis.TickLabelPosition = TickLabelPositionType.Low;

ChartDataCellFactory fact = clusteredBarChart.ChartData.ChartDataCellFactory;
clusteredBarChart.ChartData.Series.Add(fact.GetCell(0, 0, 1, “Series 1”), clusteredBarChart.Type);
ChartSeriesEx series = clusteredBarChart.ChartData.Series[0];

clusteredBarChart.ChartData.Categories.Add(fact.GetCell(0, 1, 0, “C1”));
series.Values.Add(fact.GetCell(0, 1, 1, 24));
clusteredBarChart.ChartData.Categories.Add(fact.GetCell(0, 2, 0, “C2”));
series.Values.Add(fact.GetCell(0, 2, 1, 23));
clusteredBarChart.ChartData.Categories.Add(fact.GetCell(0, 3, 0, “C3”));
series.Values.Add(fact.GetCell(0, 3, 1, -10));
clusteredBarChart.ChartData.Categories.Add(fact.GetCell(0, 4, 0, “C4”));
series.Values.Add(fact.GetCell(0, 4, 1, null));
series.Labels.TextProperties.Paragraphs[0].ParagraphFormat.DefaultPortionFormat.FillFormat.FillType = FillTypeEx.Solid;
series.Labels.TextProperties.Paragraphs[0].ParagraphFormat.DefaultPortionFormat.FontHeight = 12;
series.Labels.ShowValue = true;
clusteredBarChart.DisplayBlanksAs = DisplayBlanksAsTypeEx.Gap;
series.InvertIfNegative = false ;
pres.Write(“D:\Aspose Data\TestScatter.pptx”);

Many Thanks,

#3

Dear Mudassir,


I tried the code posted in your previous message and regret to share that it did not work. I’m still facing the same problem:
- When generating the presentation, C4 value in the chart does not show.
- When I click “Edit Data” , C4 value shows.

Thank you in advance,
Sami Simon

#4

Dear Mudassir,


I tried the code posted in your previous message and regret to share that it did not work. I’m still facing the same problem:
- When generating the presentation, C4 value in the chart does not show.
- When I click “Edit Data” , C4 value shows.

PS: I am using PowerPoint 2007

Thank you in advance,
Sami Simon

#5

Dear Sami Simon,


I have observed the issue specified and have been able to reproduce the issue. I have created an issue with ID SLIDESNET-34258 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,

#6

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