w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Show point cursor and its value on cursor hover in MS line chart

Correct me if I'm wrong but I guess you are using Microsoft Chart Controls for .Net Framework, it's not very clear in your question.

Anyway, you can use a tooltip to show the values of the point where your mouse is hovering on.
Chart1.Series("Series1").ToolTip = "#VALX - #VALY"
This will show the X Value and the Y Value in a tooltip of the point you are hovering over.

Code example (visual basic):

' Creating the series
Dim series1 As New Series("Series1")

' Setting the Chart Type
series1.ChartType = SeriesChartType.Line

' Adding some points
series1.Points.AddXY(0, 10)
series1.Points.AddXY(1, 15)
series1.Points.AddXY(2, 13)
series1.Points.AddXY(3, 21)
series1.Points.AddXY(4, 9)
series1.Points.AddXY(5, 17)

' Add the series to the chart

' Set the chart's height and width
Chart1.Width = 600
Chart1.Height = 600

' Set the chart's visuals
series1.Color = Drawing.Color.Red
series1.IsXValueIndexed = True

' Setting the X Axis
Chart1.ChartAreas("ChartArea1").AxisX.IsMarginVisible = True
Chart1.ChartAreas("ChartArea1").AxisX.Interval = 1
Chart1.ChartAreas("ChartArea1").AxisX.Maximum = [Double].NaN
Chart1.ChartAreas("ChartArea1").AxisX.Title = "x"
Chart1.ChartAreas("ChartArea1").AxisX.TitleFont = New Font("Sans Serif",
10, FontStyle.Bold)

' Setting the Y Axis
Chart1.ChartAreas("ChartArea1").AxisY.Interval = 2
Chart1.ChartAreas("ChartArea1").AxisY.Maximum = [Double].NaN
Chart1.ChartAreas("ChartArea1").AxisY.Title = "y"
Chart1.ChartAreas("ChartArea1").AxisY.TitleFont = New Font("Sans Serif",
10, FontStyle.Bold)

' Setting the mouse hover (tooltip)
series1.ToolTip = "#VALX - #VALY"

© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.