We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

X axis labels on graph using Syncfusion.XlsIO

Hi,
I have the following code to add a graph to an Excel object created with Syncfusion.XlsIO. But I don't see any labels on the Horizontal(X) axis. How do I control the labels on the axis? 

Many thx!

      var chart = _worksheet.Charts.Add();
      chart.TopRow = toprow;
      chart.BottomRow = toprow + 25;
      chart.RightColumn = 15;
      chart.ChartTitle = "Project cash-flow";
      chart.ChartType = ExcelChartType.Line;

      var productA = chart.Series.Add("Cumulatief grond cash-flow");
      productA.Values = _worksheet.Range[row, 2, row, column];
      productA.CategoryLabels = _worksheet.Range[1, 2, 1, column];
      productA.SerieFormat.LineProperties.LineColor = Color.DarkBlue;

      //Set second serie
      var productB = chart.Series.Add("Cumulatief opstal cash-flow");
      productB.Values = _worksheet.Range[++row, 2, row, column];
      productB.CategoryLabels = _worksheet.Range[1, 2, 1, column];
      productB.SerieFormat.LineProperties.LineColor = Color.Red;

      //total
      var productC = chart.Series.Add("Totaal");
      productC.Values = _worksheet.Range[++row, 2, row, column];
      productC.CategoryLabels = _worksheet.Range[1, 2, 1, column];
      productC.SerieFormat.LineProperties.LineColor = Color.Green;

3 Replies

MM Mathu Mohan Vijayakumar Syncfusion Team June 30, 2017 08:38 AM UTC

Hi Robert, 
 
We are unable to reproduce the reported issue from our side. We suspect that axis labels are hidden due to the TickLabelPosition of category axis set to none (or) Empty string values has been set for category axis. We have prepared the simple sample to demonstrate the possible chances for hidden Axis labels and this sample can be downloaded from the following link.  
 
We have shared below the code example to change the axis labels visibility by the TickLabelPosition  property. 
 
//Chart category axis tick label position 
chart.PrimaryCategoryAxis.TickLabelPosition = ExcelTickLabelPosition.TickLabelPosition_NextToAxis; 
 
 
Sample link:   
  
If your issue is different from these scenarios, kindly modify the sample to reproduce the issue and share us the modified sample along with the issue reproducing input files which will be helpful for us to give you a prompt solution at the earliest. 
  
Regards, 
Mathu Mohan V A 



RP Robert Pouleijn June 30, 2017 09:33 AM UTC

Hi Mathu,

U are so right, the series was pointing to empty cell values :(

Sorry to have bothered u!


thx!



SS Sridhar Sukumar Syncfusion Team July 3, 2017 09:12 AM UTC

Hi Robert, 
 
Thank you for updating us. 
 
We are glad that the issue is resolved at your end. Please let us know if you need any further assistance. 
 
Regards, 
Sridhar. 


Loader.
Up arrow icon