Profile Picture

How to set the position of label

Posted By shweta jain 5 Years Ago
Author
Message
shweta jain
Posted 5 Years Ago
View Quick Profile
Junior Member

Junior Member (21 reputation)Junior Member (21 reputation)Junior Member (21 reputation)Junior Member (21 reputation)Junior Member (21 reputation)Junior Member (21 reputation)Junior Member (21 reputation)Junior Member (21 reputation)Junior Member (21 reputation)

Group: Forum Members
Last Active: 3 Years Ago
Posts: 16, Visits: 192
Hi
I want to set the position of label in the middle of the line. I have attached image of my chart where label name "label 2" is at the top of line, How can I set the position of that label in middle of the line.
https://www.nevron.com/forum/uploads/images/eff5af95-2d94-4b26-9221-f3ea.png 

Nevron Support
Posted 5 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)

Group: Forum Members
Last Active: Last Year
Posts: 3,039, Visits: 3,746
Hi Shweta,

How do you add that label to chart? In general you simply need to calculate the center point of the line which is very simple:
C.X  = (A.X + B.X) / 2
C.Y  = (A.Y + B.Y) / 2
where A and B are the begin/end points and C is the center.

Best Regards,
Nevron Support Team



shweta jain
Posted 5 Years Ago
View Quick Profile
Junior Member

Junior Member (21 reputation)Junior Member (21 reputation)Junior Member (21 reputation)Junior Member (21 reputation)Junior Member (21 reputation)Junior Member (21 reputation)Junior Member (21 reputation)Junior Member (21 reputation)Junior Member (21 reputation)

Group: Forum Members
Last Active: 3 Years Ago
Posts: 16, Visits: 192
Thank you for reply,
After calculating center point of the line then how can we set that point in label position.

shweta jain
Posted 5 Years Ago
View Quick Profile
Junior Member

Junior Member (21 reputation)Junior Member (21 reputation)Junior Member (21 reputation)Junior Member (21 reputation)Junior Member (21 reputation)Junior Member (21 reputation)Junior Member (21 reputation)Junior Member (21 reputation)Junior Member (21 reputation)

Group: Forum Members
Last Active: 3 Years Ago
Posts: 16, Visits: 192
Hi
Thank you for reply,
but I don't understand after finding center point of line, how to set that point in label for change the position of label.

Nevron Support
Posted 5 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)Supreme Being (4,329 reputation)

Group: Forum Members
Last Active: Last Year
Posts: 3,039, Visits: 3,746
Hi Shweta,

You can use a point series in XY scatter mode for this purpose:

   NCartesianChart chart = (NCartesianChart)nChartControl1.Charts[0];

    NPointSeries point = new NPointSeries();
    point.Size = new NLength(0);
    chart.Series.Add(point);
    point.DataLabelStyle.Visible = true;
    point.DataLabelStyle.TextStyle.StringFormatStyle.HorzAlign = Nevron.HorzAlign.Center;
    point.DataLabelStyle.TextStyle.StringFormatStyle.VertAlign = Nevron.VertAlign.Center;
    point.DataLabelStyle.VertAlign = Nevron.VertAlign.Center;
    point.DataLabelStyle.Format = "<label>";
    point.UseXValues = true;
    point.Values.Add(10);
    point.XValues.Add(10);
    point.Labels.Add("Some Label");

This will display a centered label at [10,10] - you can also display labels using annotations - check out example All Examples \ Panels \ Annotations for more information... Let us know if you meet any problems.



Best Regards,
Nevron Support Team





Similar Topics


Reading This Topic