Hello Erkin,
Thank you for writing back.
The provided detailed explanation is greatly appreciated.
RadChartView doesn't offer such functionality out of the box. However, I can suggest you the illustrated behavior in the attached gif file which is achieved by the following code snippet:
public
RadForm1()
{
InitializeComponent();
LineSeries lineSeries =
new
LineSeries();
lineSeries.ShowLabels =
true
;
lineSeries.PointSize =
new
SizeF(8, 8);
lineSeries.DataPoints.Add(
new
CategoricalDataPoint(20,
"Jan"
));
lineSeries.DataPoints.Add(
new
CategoricalDataPoint(22,
"Apr"
));
lineSeries.DataPoints.Add(
new
CategoricalDataPoint(12,
"Jul"
));
lineSeries.DataPoints.Add(
new
CategoricalDataPoint(19,
"Oct"
));
this
.radChartView1.Series.Add(lineSeries);
foreach
(CategoricalDataPoint p
in
lineSeries.DataPoints)
{
p.Label =
""
;
}
this
.radChartView1.ContextMenuOpening += radChartView1_ContextMenuOpening;
this
.radChartView1.LabelFormatting += radChartView1_LabelFormatting;
RadMenuItem item =
new
RadMenuItem(
"Annotate"
);
item.Click += item_Click;
menu.Items.Add(item);
}
private
void
item_Click(
object
sender, EventArgs e)
{
if
(lastClickedPoint !=
null
)
{
lastClickedPoint.Label = lastClickedPoint.Value.ToString();
lastClickedPoint =
null
;
}
}
private
void
radChartView1_LabelFormatting(
object
sender, ChartViewLabelFormattingEventArgs e)
{
CategoricalDataPoint dataPoint = e.LabelElement.DataPoint
as
CategoricalDataPoint;
e.LabelElement.Text = dataPoint.Value.ToString();
e.LabelElement.BackColor = Color.Transparent;
e.LabelElement.BorderColor = Color.Black;
}
RadContextMenu menu =
new
RadContextMenu();
CategoricalDataPoint lastClickedPoint =
null
;
private
void
radChartView1_ContextMenuOpening(
object
sender, ChartViewContextMenuOpeningEventArgs e)
{
Point mouseLocation = radChartView1.PointToClient(Cursor.Position);
CategoricalDataPoint dataPoint = radChartView1.View.Renderer.HitTest(mouseLocation.X, mouseLocation.Y)
as
CategoricalDataPoint;
if
(dataPoint !=
null
)
{
e.ContextMenu = menu;
lastClickedPoint = dataPoint;
}
}
I hope this information helps. If you have any additional questions, please let me know.
Regards,
Dess
Telerik by Progress