Profile Picture

Label shifts to the right side depending on label text length

Posted By Syrhey Karol' 12 Years Ago

Label shifts to the right side depending on label text length

Author
Message
Syrhey Karol'
Posted 12 Years Ago
View Quick Profile
Forum Member

Forum Member (27 reputation)Forum Member (27 reputation)Forum Member (27 reputation)Forum Member (27 reputation)Forum Member (27 reputation)Forum Member (27 reputation)Forum Member (27 reputation)Forum Member (27 reputation)Forum Member (27 reputation)

Group: Forum Members
Last Active: Last Year
Posts: 21, Visits: 74
Hi!

It seems that it is an issue.
I’ve added a label into chart. I’ve also set ContentAlignment and Location for the label.
Here is the code:

//string title = "dddd";
string title = "ddddgfhiljklfdgjklgdfjogfdejkgfdljkgdfjlkgalkjgfdljkgligalihgahegihler";

NLabel label = nChartControl1.Labels.AddHeader(title);
label.ContentAlignment = ContentAlignment.BottomRight;
label.Location = new NPointL(new NLength(0), new NLength(0));




If my label contains few symbols then all is fine (image 1.png). But if my label contains big amount of symbols it shifts to the right side (image 2.png).
Empirically way I calculated that if I divide text length on 7 I’ll get amount of pixel that label shifts. So I can Shift it back
What do you think? Maybe I am doing something wrong?

Best Regards,
Zonder


Attachments
1.png (82 views, 3.00 KB)
2.png (68 views, 24.00 KB)
Nevron Support
Posted 12 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: Yesterday @ 8:46 AM
Posts: 3,054, Visits: 4,012

Hi Zonder,

This is generally a GDI+ problem - the text measurement does not produce correct results due to the effects of hinting applied on the text. To correct the issue you may use BoundsMode.None - it does not calculate the label size and will therefore display the label exactly at the top:

string title = "ddddgfhiljklfdgjklgdfjogfdejkgfdljkgdfjlkgalkjgfdljkgligalihgahegihler";
NLabel label = nChartControl1.Labels.AddHeader(title);
label.ContentAlignment =
ContentAlignment.BottomRight;
label.BoundsMode =
BoundsMode.None;
label.Location =
new NPointL(new NLength(0), new NLength(0));

Let us know if you meet any problems...



Best Regards,
Nevron Support Team



Syrhey Karol'
Posted 12 Years Ago
View Quick Profile
Forum Member

Forum Member (27 reputation)Forum Member (27 reputation)Forum Member (27 reputation)Forum Member (27 reputation)Forum Member (27 reputation)Forum Member (27 reputation)Forum Member (27 reputation)Forum Member (27 reputation)Forum Member (27 reputation)

Group: Forum Members
Last Active: Last Year
Posts: 21, Visits: 74
Hi!

Thank you! It works fine.

Best Regards,
Zonder



Similar Topics


Reading This Topic