Hi, I have a requirement to draw a ClusteredColumn chart in PPT, where the x and y-axis values/labels are numbers. like 0, 1, 2, 3, 4…20.
I want to display the last number is ie 20 to 20+. on the x-axis.
For now, we have used the below code for this
chart.Axes.HorizontalAxis.MaxValue = 20;
chart.Axes.HorizontalAxis.MinValue = 0;
The programming language is c#. Please provide help.
Soc1 - Copy2.png (18.5 KB)
@s1pandey,
Thank you for the query. Unfortunately, Aspose.Slides has not such a feature. If you could create a PPTX file in PowerPoint with the desired view and send us, we would consider how to do it.
How to do with code or in pptx only manually. there is a restriction to upload pptx from my end
@s1pandey,
You can compress the files to a ZIP archive and upload it.
@s1pandey,
Unfortunately, the text “20+” is in the table, not in the chart. We need a PPTX example with the text “20+” on the chart axis. It seems impossible to do this in PowerPoint as well. Axis values are generated automatically by format.
I have attached dummy pppt how should it visibleSOC Histogram (2).zip (489.2 KB)
@s1pandey,
Could you describe how did you do that, please?
I have not done this… I got this as a requiremt.
@s1pandey,
It will take me a while to figure this out. I will answer you later.
Can you response early as I am working on it and we have a deadline for this?
@s1pandey,
I logged the issue in our tracking system with ID SLIDESNET-42604. Our development team will consider an ability to implement this feature.
@s1pandey,
Our development team investigated the issue. The chart categories data was updated manually in the “SOC Histogram (2).pptx” file. There is no formatting applied. The code snippet below shows the way to achieve the desired result:
using (Presentation pres = new Presentation())
{
IChart chart = pres.Slides[0].Shapes.AddChart(ChartType.ClusteredColumn, 100, 100, 400, 300);
IChartCategoryCollection categories = chart.ChartData.Categories;
if (categories.Count > 0)
{
for (int i = 0; i < categories.Count - 1; i++)
{
categories[i].AsCell.Value = i + 1;
}
categories[categories.Count - 1].AsCell.Value = categories.Count + "+";
}
pres.Save("output.pptx", SaveFormat.Pptx);
}
More examples: Create Chart
API Reference: IChartCategory Interface, IChartDataCell Interface
there is no categories here in my case ho its not updating text…
below are the code snippet of my chart
// Add chart with default data
IChart chart = pptSlide.Shapes.AddChart(ChartType.ClusteredColumn, x, y, width, height);
chart.HasTitle = false;
chart.HasLegend = false;
//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();
//Adding new series
chart.ChartData.Series.Add(fact.GetCell(defaultWorksheetIndex, 0, 1, 3), chart.Type);
//Take first chart series
IChartSeries series = chart.ChartData.Series[0];
//Now populating series data
series.ParentSeriesGroup.GapWidth = Constants.SocReportPowerPointOptions.GapWidth;
var socVisualization = (SoCHistogramReportData)visualizationData;
var chartData = socVisualization.PlotChart;
var soc = 0;
int index = 0;
foreach (var item in chartData)
{
soc = item.Key == 0 ? 1 : item.Key;
foreach (var value in item.Value)
{
series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, soc, 1, value));
// Bar Color
chart.ChartData.Series[0].DataPoints[soc - 1].Format.Fill.FillType = FillType.Solid;
chart.ChartData.Series[0].DataPoints[soc - 1].Format.Fill.SolidFillColor.Color = ConvertRgbToColor(socVisualization.Legends[index].Color);
soc++;
}
index++;
}
@s1pandey,
Unfortunately, I cannot use your code example containing an unknown symbol visualizationData
to help you. Please share a comprehensive code example generating the chart.