糾正我,如果我錯了,但我猜你正在使用微軟圖表控件.Net框架,這不是你的問題很清楚。
無論如何,您可以使用工具提示來顯示鼠標懸停點的數值。
Chart1.Series("Series1").ToolTip = "#VALX - #VALY"
這將在您懸停的點的工具提示中顯示X值和Y值。
代碼示例(視覺鹼性):
' 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
Chart1.Series.Add(series1)
' 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"