Design Chart Annotations in C# and VB.Net in Windows Application

Last Reply 10 months ago By dharmendr

Posted 10 months ago

How do i design Annotation in

I have this code that I use to show information from the data chart.

What I want now is to be able to design the annotation by inputting titles for each column and showing information inside the box instead of just information around the charts and then be able to modify the forecolor, to be able to make the background as visible or not visible and so on. So what I want is to make the design of annotation lit bit more compact.

this is the code : 

    Private Sub Chart1_MouseMove(ByVal sender As Object, ByVal e As MouseEventArgs) Handles Chart1.MouseMove
        Dim result As HitTestResult = Chart1.HitTest(e.X, e.Y)
        If result.ChartElementType = ChartElementType.DataPoint Then
            Dim department As String = result.Series.Name
            Dim year As String = result.Series.Points(result.PointIndex).AxisLabel
            Dim total As Double = result.Series.Points(result.PointIndex).YValues(0)
            Dim thisPt As PointF = New PointF(Convert.ToSingle(result.Series.Points(result.PointIndex).XValue),
            Dim ca As CalloutAnnotation = New CalloutAnnotation With {
                .AnchorDataPoint = result.Series.Points(result.PointIndex),
                .X = thisPt.X + 1,
                .Y = thisPt.Y + 1,
                .CalloutStyle = CalloutStyle.SimpleLine,
                .ForeColor = Color.MediumSeaGreen,
                .Font = New Font("Tahoma", 8, FontStyle.Bold),
                .Name = department,
                .LineWidth = 2,
                .Text = GetDetails(year, department)
            Chart1.Annotations(department) = ca
        End If

Thank you a lot,  Elvis

This question does not have replies that have been liked.