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

Free Support Forum - aspose.com

Formatting line chart x-axis label

Hi,
I am trying to customize a line chart x-axis such that my x-axis labels read 1 2 3 4 5 10 20 30.

Basically, I only want to print the above labels and skip anything else. How do I do that? I am using aspose.slides .Net product. Any help is appreciated.

Thanks,
N

@naeem.gittham,

I have observed your comments and request you to please share the desired output chart that you want to generate using Aspose.Slides. We will investigate the requirement further on our end to help you.

image.png (7.4 KB)

I have attached an image in my previous post. This is on the website but I would like to generate the x-axis this way using aspose slides

@naeem.gittham,

I have observed your requirement image for hiding category axis values in a line chart. I like to mention that there is no option available even in PowerPoint to hide the category axis values. However, you can achieve this indirectly in a way that you add a category axis but give no name to that and it may give you illusion of what you are trying to achieve but this certainly not recommended. In that case, I suggest you to please try using following sample code.

     public static void TestLineChart()
     {
         Presentation pres = new Presentation();

         ISlide slide = pres.Slides[0];

         // Creating the default chart
         IChart chart = slide.Shapes.AddChart(ChartType.Line, 0, 0, 400, 400);

         // Getting the default chart data worksheet index
         int defaultWorksheetIndex = 0;

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

         // Delete demo Categories
         chart.ChartData.Categories.Clear();

         // Adding new categories
         chart.ChartData.Categories.Add(fact.GetCell(defaultWorksheetIndex, 1, 0, "1"));
         chart.ChartData.Categories.Add(fact.GetCell(defaultWorksheetIndex, 2, 0, "2"));
         chart.ChartData.Categories.Add(fact.GetCell(defaultWorksheetIndex, 3, 0, "3"));
         chart.ChartData.Categories.Add(fact.GetCell(defaultWorksheetIndex, 4, 0, String.Empty));
         chart.ChartData.Categories.Add(fact.GetCell(defaultWorksheetIndex, 5, 0, String.Empty));
         chart.ChartData.Categories.Add(fact.GetCell(defaultWorksheetIndex, 6, 0, String.Empty));
         chart.ChartData.Categories.Add(fact.GetCell(defaultWorksheetIndex, 7, 0, String.Empty));
         chart.ChartData.Categories.Add(fact.GetCell(defaultWorksheetIndex, 8, 0, String.Empty));
         chart.ChartData.Categories.Add(fact.GetCell(defaultWorksheetIndex, 9, 0, String.Empty));
         chart.ChartData.Categories.Add(fact.GetCell(defaultWorksheetIndex, 10, 0, "10"));
   
         // Delete demo series
         chart.ChartData.Series.Clear();

         // Add new series
         chart.ChartData.Series.Add(fact.GetCell(defaultWorksheetIndex, 1, 1, "Yield"), chart.Type);

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

         // Add First series point 
         series.DataPoints.AddDataPointForLineSeries(fact.GetCell(defaultWorksheetIndex, 1, 1, 1));
         // Add 2nw series point 
         series.DataPoints.AddDataPointForLineSeries(fact.GetCell(defaultWorksheetIndex, 2, 1, 5));
         // Add third series point 
         series.DataPoints.AddDataPointForLineSeries(fact.GetCell(defaultWorksheetIndex, 3, 1, 4));
         series.DataPoints.AddDataPointForLineSeries(fact.GetCell(defaultWorksheetIndex, 4, 1, 4));
         series.DataPoints.AddDataPointForLineSeries(fact.GetCell(defaultWorksheetIndex, 5, 1, 4));
         series.DataPoints.AddDataPointForLineSeries(fact.GetCell(defaultWorksheetIndex, 6, 1, 4));
         series.DataPoints.AddDataPointForLineSeries(fact.GetCell(defaultWorksheetIndex, 7, 1, 4));
         series.DataPoints.AddDataPointForLineSeries(fact.GetCell(defaultWorksheetIndex, 8, 1, 4));
         series.DataPoints.AddDataPointForLineSeries(fact.GetCell(defaultWorksheetIndex, 9, 1, 4));
         
         series.DataPoints.AddDataPointForLineSeries(fact.GetCell(defaultWorksheetIndex, 10, 1, 7));


         pres.Save("C:\\Aspose Data\\AsposeChart_out.pptx", Aspose.Slides.Export.SaveFormat.Pptx);
     }
1 Like

Hi Mudassir,
This solution works for me very well. Thank you so much for your help!!