As can bee seen blow that I have a chart i was wondering how i would be able to change the label “per” pro-grammatically though code./
Hi Jim,
I have observed that you need to change the category name “per” instead of labels. Please use following code snippet to change the category axis text.
public static void ModifyChart(){//Instantiate PresentationEx class that represents PPTX filePresentationEx pres = new PresentationEx(“D:\Aspose Data\AsposeChart.pptx”);//Access first slideSlideEx sld = pres.Slides[0];// Add chart with default dataChartEx chart = (ChartEx)sld.Shapes[0];//Setting the index of chart data sheetint defaultWorksheetIndex = 0;//Getting the chart data worksheetChartDataCellFactory fact = chart.ChartData.ChartDataCellFactory;//Changing Category Namefact.GetCell(defaultWorksheetIndex, 1, 0, “per”);fact.GetCell(defaultWorksheetIndex, 2, 0, “gent”);//Take first chart seriesChartSeriesEx series = chart.ChartData.Series[0];//Now updating series datafact.GetCell(defaultWorksheetIndex, 0, 1, “New_Series1”);//modifying series namefor (int i = 0; i < series.Values.Count; i++){if(i==0)series.Values[i].Value = 90;else if(i==1)series.Values[i].Value = 123;else if(i==2)series.Values[i].Value = 44;}//Take Second chart seriesseries = chart.ChartData.Series[1];//Now updating series datafact.GetCell(defaultWorksheetIndex, 0, 2, “New_Series2”);//modifying series namefor (int i = 0; i < series.Values.Count; i++){if (i == 0)series.Values[i].Value = 23;else if (i == 1)series.Values[i].Value = 67;else if (i == 2)series.Values[i].Value = 99;}//Now, Adding a new serieschart.ChartData.Series.Add(fact.GetCell(defaultWorksheetIndex, 0, 3, “Series 3”), chart.Type);//Take 3rd chart seriesseries = chart.ChartData.Series[2];//Now populating series dataseries.Values.Add(fact.GetCell(defaultWorksheetIndex, 1, 3, 20));series.Values.Add(fact.GetCell(defaultWorksheetIndex, 2, 3, 50));series.Values.Add(fact.GetCell(defaultWorksheetIndex, 3, 3, 30));// chart.Type = ChartTypeEx.ClusteredCylinder;// Save presentation with chartpres.Write(@“D:\Aspose Data\AsposeChartMoodified.pptx”);}
Many Thanks,
hi,
i was wondering would it be possible for me to change the values using a for loop with data form an array as when im doing so i make an error
Hi Jim,
Yes you can set the values using arrays. Kindly share the complete sample application used on your end along with issue details. I will try to reproduce the issue and help you out. Please also highlight the code section whereby you are having issue.
Many Thanks,