Custom datalabel on the scatter chart

Technical support for Spire.XLS

Moderators: iceblue support, Flash, Manager

Custom datalabel on the scatter chart

Postby srajguru » Mon Aug 14, 2017 8:54 am

Hello,

I am evaluating the spire.xls library to check whether it fits our purpose.
I am trying to create a graph which looks like below.


However I am not able to create my custom datalabel with my custom text.
I am using following code to set the text for the datalabel.

Code: Select all
 chartSeries.DataPoints.DefaultDataPoint.DataLabels.HasValue = false;
 chartSeries.DataPoints.DefaultDataPoint.DataLabels.HasCategoryName = false;
 chartSeries.DataPoints.DefaultDataPoint.DataLabels.HasLegendKey = false;
 chartSeries.DataPoints.DefaultDataPoint.DataLabels.HasSeriesName = false;
 chartSeries.DataPoints.DefaultDataPoint.DataLabels.HasBubbleSize = false;
chartSeries.DataPoints.DefaultDataPoint.DataLabels.Text = sLabelText;


But in resulting excel file I don't see my custom datalabel.
Is setting up custom data label is supported ?
Is there anything wrong with the above code ?

Thanks
Last edited by srajguru on Mon Aug 14, 2017 12:39 pm, edited 1 time in total.
srajguru
 
Posts: 7
Joined: Tue Aug 08, 2017 10:06 am

Re: Custom datalabel on the scatter chart

Postby Jane.Bai » Mon Aug 14, 2017 10:33 am

Hello,

Thanks for your inquiry.
Below is my testing code which works well on my scatter chart. You can have a try.
Code: Select all
 Workbook book = new Workbook();
            book.LoadFromFile(@"C:\Users\Administrator\Desktop\11357.xlsx");
            Worksheet sheet = book.Worksheets[0];
            Chart chart = sheet.Charts[0];
            var chartSeries = chart.Series[0];
            for (int i = 0; i < 9.; i++)
            {
                chartSeries.DataPoints[i].DataLabels.Text = "123";
            }
            book.SaveToFile("111111.xlsx");


If it doesn't make sense on your end, please share your sample file and then we will look into it.

Sincerely,
Jane
E-iceblue support team
User avatar
Jane.Bai
 
Posts: 348
Joined: Tue Nov 29, 2016 1:47 am

Re: Custom datalabel on the scatter chart

Postby srajguru » Wed Aug 16, 2017 5:38 am

Thank you very much the quick response.
That works for me.

Is there any way to set the datalabel shadow ?
I am trying to set shadow via below code

Code: Select all
chartSeries.DataPoints[1].DataLabels.FrameFormat.Shadow.Color = System.Drawing.Color.Black;
chartSeries.DataPoints[1].DataLabels.FrameFormat.Shadow.Transparency = 0;
chartSeries.DataPoints[1].DataLabels.FrameFormat.Shadow.Blur = 0;
chartSeries.DataPoints[1].DataLabels.FrameFormat.Shadow.Angle = 45;
chartSeries.DataPoints[1].DataLabels.TextArea.FrameFormat.Shadow.Distance = 3;


Thanks
Last edited by srajguru on Wed Aug 16, 2017 7:12 am, edited 1 time in total.
srajguru
 
Posts: 7
Joined: Tue Aug 08, 2017 10:06 am

Re: Custom datalabel on the scatter chart

Postby Jane.Bai » Wed Aug 16, 2017 6:41 am

Hello,

Thanks for your feedback.
Please use the code below to set the fill color of the datalabel.
Code: Select all
chartSeries.DataPoints[i].DataLabels.FrameFormat.Fill.FillType = ShapeFillType.SolidColor;
                chartSeries.DataPoints[i].DataLabels.FrameFormat.Fill.ForeColor = Color.Pink;

As for te border color, sorry there seems no way to set it. I have referred the feature to our dev team, once there's any update, I will let you know.

Sincerely,
Jane
E-iceblue support team
User avatar
Jane.Bai
 
Posts: 348
Joined: Tue Nov 29, 2016 1:47 am

Re: Custom datalabel on the scatter chart

Postby srajguru » Wed Aug 16, 2017 7:13 am

Thanks.
That works.

Is there any way to set the datalabel shadow ?
I am trying to set shadow via below code but shadow is not setting up

Code: Select all
chartSeries.DataPoints[1].DataLabels.FrameFormat.Shadow.Color = System.Drawing.Color.Black;
chartSeries.DataPoints[1].DataLabels.FrameFormat.Shadow.Transparency = 0;
chartSeries.DataPoints[1].DataLabels.FrameFormat.Shadow.Blur = 0;
chartSeries.DataPoints[1].DataLabels.FrameFormat.Shadow.Angle = 45;
chartSeries.DataPoints[1].DataLabels.TextArea.FrameFormat.Shadow.Distance = 3;
srajguru
 
Posts: 7
Joined: Tue Aug 08, 2017 10:06 am

Re: Custom datalabel on the scatter chart

Postby Jane.Bai » Wed Aug 16, 2017 7:56 am

Hello,

Sorry for my previous mistake, after a further investigation, I found the way to set the border.
Code: Select all
chartSeries.DataPoints[1].DataLabels.FrameFormat.Border.Pattern = ChartLinePatternType.Solid;
                chartSeries.DataPoints[1].DataLabels.FrameFormat.Border.Color = Color.Red;

Also attch the code for the shadow setting.
Code: Select all
// First set the shadow type
chartSeries.DataPoints[1].DataLabels.FrameFormat.Shadow.ShadowOuterType = XLSXChartShadowOuterType.OffsetDiagonalBottomLeft;
                chartSeries.DataPoints[1].DataLabels.FrameFormat.Shadow.Color = System.Drawing.Color.Black;
                chartSeries.DataPoints[1].DataLabels.FrameFormat.Shadow.Transparency = 0;
                chartSeries.DataPoints[1].DataLabels.FrameFormat.Shadow.Blur = 0;
                chartSeries.DataPoints[1].DataLabels.FrameFormat.Shadow.Angle = 45;
                chartSeries.DataPoints[1].DataLabels.TextArea.FrameFormat.Shadow.Distance = 5;


Sincerely,
Jane
E-iceblue support team
User avatar
Jane.Bai
 
Posts: 348
Joined: Tue Nov 29, 2016 1:47 am

Re: Custom datalabel on the scatter chart

Postby srajguru » Wed Aug 16, 2017 8:52 am

Thanks you very much for you support.
srajguru
 
Posts: 7
Joined: Tue Aug 08, 2017 10:06 am

Re: Custom datalabel on the scatter chart

Postby Jane.Bai » Wed Aug 16, 2017 9:13 am

Hello,

Thank you for the quick response.
Please feel free to contact us if you need any assistance.
Wish you all the best!

Sincerely,
Jane
E-iceblue support team
User avatar
Jane.Bai
 
Posts: 348
Joined: Tue Nov 29, 2016 1:47 am

Re: Custom datalabel on the scatter chart

Postby srajguru » Wed Aug 16, 2017 10:24 am

Hi,

I am trying to set the chart axis format but it is not getting set.
I have wrote below code for the same.

Code: Select all
 chart.PrimaryValueAxis.NumberFormat = "0.000";
srajguru
 
Posts: 7
Joined: Tue Aug 08, 2017 10:06 am

Re: Custom datalabel on the scatter chart

Postby Jane.Bai » Thu Aug 17, 2017 1:58 am

Hello,

Thanks for your inquiry.
Kindly note the number format is controlled by both the "IsSourceLinked" property and the format you set. Please refer to the code below:
Code: Select all
chart.PrimaryValueAxis.IsSourceLinked = false;
chart.PrimaryValueAxis.NumberFormat = "0.000";


Sincerely,
Jane
E-iceblue support team
User avatar
Jane.Bai
 
Posts: 348
Joined: Tue Nov 29, 2016 1:47 am

Re: Custom datalabel on the scatter chart

Postby srajguru » Thu Aug 17, 2017 7:12 am

Hello,

Thanks for the response.

I am running into few problems related to chart export.
Since I am exporting chart to image using "SaveChartAsImage" function.

I have noticed that exported image doesn't look good as excel however it is missing few properties which is visible in Excel App but doesn't work when I export image via "SaveChartAsImage"

Following are the few issues that I noticed

    Data Label fill color is ignored
    Data Label border and shadow is ignored
    Data Label font does not seem to match with the excel one
    Chart Line thickness does not match with the excel one
srajguru
 
Posts: 7
Joined: Tue Aug 08, 2017 10:06 am

Re: Custom datalabel on the scatter chart

Postby Jane.Bai » Thu Aug 17, 2017 9:52 am

Hello,

we suggest you first using the latest version(Spire.XLS Pack Hotfix Version:7.12.69)to have a try.
If the issues still exist, please send your sample file to us via email(support@e-iceblue.com) for a better investigation.

Sincerely,
Jane
E-iceblue support team
User avatar
Jane.Bai
 
Posts: 348
Joined: Tue Nov 29, 2016 1:47 am

Re: Custom datalabel on the scatter chart

Postby srajguru » Thu Aug 17, 2017 10:59 am

Thank you
I have the same version.
I have forwarded the email to support mentioning the same.
srajguru
 
Posts: 7
Joined: Tue Aug 08, 2017 10:06 am

Re: Custom datalabel on the scatter chart

Postby Jane.Bai » Fri Aug 18, 2017 3:09 am

Hello,

Thanks for sharing your files via email.
I have noticed the issues and referred them to our dev team.Once there's any update, I will let you know.
Sorry for the inconvenience caused.

Sincerely,
Jane
E-iceblue support team
User avatar
Jane.Bai
 
Posts: 348
Joined: Tue Nov 29, 2016 1:47 am


Return to Spire.XLS

Who is online

Users browsing this forum: No registered users and 1 guest