By shweta jain - 5 Years Ago
|
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.
|
By Nevron Support - 5 Years Ago
|
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.
|
By shweta jain - 5 Years Ago
|
Thank you for reply, After calculating center point of the line then how can we set that point in label position.
|
By shweta jain - 5 Years Ago
|
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.
|
By Nevron Support - 5 Years Ago
|
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.
|