Spire.XLS is a professional Excel API that enables developers to create, manage, manipulate, convert and print Excel worksheets. Get free and professional technical support for Spire.XLS for .NET, Java, Android, C++, Python.

Wed May 29, 2019 9:59 am

Hello,

I'm creating a Spire.Xls.ExcelChartType.ColumnClustered chart, but the labels overlap.
The chart has two series, so there are two columns per each PrimaryCategoryAxix value.

I tryed the following:
1- Increasing columns width (I can't find how, if it's possible)
2- Positioning the serie1 labels above his column and the serie2 below his column with the method:
cs1.DataPoints.DefaultDataPoint.DataLabels.Position = Spire.Xls.DataLabelPositionType.Above
cs2.DataPoints.DefaultDataPoint.DataLabels.Position = Spire.Xls.DataLabelPositionType.Below
but it does nothing in my chart.

I upload the image of the chart.

Any help would be apreciated.

Thanks,

Luis.
Attachments
GraficaAsigNetas.jpg
GraficaAsigNetas.jpg (59 KiB) Viewed 945 times

lgomez
 
Posts: 6
Joined: Tue Oct 23, 2018 6:39 am

Thu May 30, 2019 4:20 am

Hello,

Thanks for your inquiry and below are my answers to your questions.
1. As for the "labels overlap" issue, I did an initial test with the latest Spire.XLS Pack(Hotfix) Version:9.5.11 but didn't reproduce your issue. Thus, I suggest you try again with the latest version, you also can try with the following code to set a smaller size font or specify a position for the series labels. If your issue still occurs after trying, to help further look into it, please share us with your full testing code, you input file (if any) as well as your generated excel file. You could send them to us via email (support@e-iceblue.com).
Code: Select all
......
//set a smaller size font
cs1.DataPoints.DefaultDataPoint.DataLabels.Font.Size = 8;
//specify a position
cs1.DataPoints.DefaultDataPoint.DataLabels.X = 150;
cs1.DataPoints.DefaultDataPoint.DataLabels.Y = 50;
......

2. You can refer to the following code snippet to increase columns width.
Code: Select all
......
cs1.Format.Options.GapWidth = 20;
......

3. Since our Spire.XLS is based on MS Excel, when positioning the series labels of ColumnClustered chart, the DataLabelPositionType should follow as the same types in MS Excel. The attached screenshot shows that there are four position types for series labels of ColumnClustered chart in MS Excel. Therefore, Please try to test with the following code snippet. If this effect is not what you want, please provide your desired effect with us, then we will look into it and guide you accordingly.
Code: Select all
cs1.DataPoints.DefaultDataPoint.DataLabels.Position = Spire.Xls.DataLabelPositionType.Outside;
cs2.DataPoints.DefaultDataPoint.DataLabels.Position = Spire.Xls.DataLabelPositionType.OutsideBase;

Sincerely,
Lisa
E-icbelue support team
Attachments
labelPosition.zip
(30.43 KiB) Downloaded 449 times
User avatar

Lisa.Li
 
Posts: 1271
Joined: Wed Apr 25, 2018 3:20 am

Thu May 30, 2019 11:34 am

Increasing columns width and reducing the size of the font worked fine.

Thanks!

lgomez
 
Posts: 6
Joined: Tue Oct 23, 2018 6:39 am

Fri May 31, 2019 1:24 am

Hello,

Glad to hear that! If you encounter any issue related to our products in the future, just feel free to contact us.
Wish you all the best!

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1271
Joined: Wed Apr 25, 2018 3:20 am

Return to Spire.XLS