隐藏mscharts中标记点的标签

时间:2011-12-16 07:54:27

标签: c# vb.net visual-studio-2010 mschart

在mscharts中,我可以使用该功能为标记点添加标签 databindcrosstable 使用代码

Chart1.DataBindCrossTable(dr, "something", "anything", "a_data", "label=c_score")

现在我想隐藏标记点的c_score标签。

我在鼠标悬停时使用代码

显示工具提示中的标签
e.Text = result.Series.Points(result.PointIndex).YValues(0) & vbCr & result.Series.Points(result.PointIndex).Label

我在自定义事件中尝试此代码,该事件仍然显示标记标签

Private Sub Chart1_Customize(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Chart1.Customize
    For Each ser As Series In Chart1.Series
        For Each dp As DataPoint In ser.Points
            dp.IsValueShownAsLabel = False
        Next
    Next
End Sub

如果dp.labelvisible = false

之类的话

由于

1 个答案:

答案 0 :(得分:0)

在表单上使用databindcrosstable。

在表格载入中我添加了

For Each ser As Series In Chart1.Series
                    For Each dp As DataPoint In ser.Points
            dp.Tag = dp.Label
            dp.Label = ""
        Next
Next

并在我完成的chart1 tooltiptext事件中: -

Private Sub Chart1_GetToolTipText(ByVal sender As Object, ByVal e As System.Windows.Forms.DataVisualization.Charting.ToolTipEventArgs) Handles Chart1.GetToolTipText
    Dim result As HitTestResult
    Select Case e.HitTestResult.ChartElementType
        Case ChartElementType.DataPoint
            result = e.HitTestResult
            e.Text = "Overall Quality: " & result.Series.Points(result.PointIndex).YValues(0) & " " & result.Series.Points(result.PointIndex).Tag
    End Select
End Sub