Skip to main content Skip to footer

How to draw annotations behind the data points

If you want to draw the annotation points behind the data points in your FlexChart, you can utilize the Rendering event to make your data points cleaner and more presentable.

private void flexchart_Rendering(object sender, RenderEventArgs e)
{
    List<DataItem> collection = flexchart.ItemsSource as List<DataItem>;
    if(collection != null)
    {
        var pointInit = flexchart.DataToPoint(new Point(collection[2].ValX, collection[2].ValY));
        e.Engine.SetFill(Brushes.Aqua);
        e.Engine.SetStroke(Brushes.Red);
        e.Engine.DrawRect(pointInit.X - 40, pointInit.Y, 80, 50);
        e.Engine.SetFill(Brushes.Black);
        e.Engine.DrawString("Point: X="+ collection[2].ValX.ToString() + "\nY=" 
            + collection[2].ValY.ToString(), new C1.Chart._Point(pointInit.X - 35, pointInit.Y + 5));
    }
}