Charts 关闭.NET MS图表中的点标签

Charts 关闭.NET MS图表中的点标签,charts,labels,series,mschart,points,Charts,Labels,Series,Mschart,Points,VB2010使用MS图表:我添加了一个系列作为点图表。有时会有超过1000个点,点标签变得过于混乱。我有智能标签: cht.Series("srs").SmartLabelStyle.Enabled = True 但尽管如此,情况仍然很糟糕。所以我添加了一个上下文菜单来关闭标签。然后,用户可以放大到一个点,如果他们希望重新打开标签。我似乎想不出一种不循环所有数据点的方法来实现这一点 我可以完全隐藏的点和标签 cht.Series("srs").Enabled = False 但我只想隐藏标签

VB2010使用MS图表:我添加了一个系列作为点图表。有时会有超过1000个点,点标签变得过于混乱。我有智能标签:

cht.Series("srs").SmartLabelStyle.Enabled = True
但尽管如此,情况仍然很糟糕。所以我添加了一个上下文菜单来关闭标签。然后,用户可以放大到一个点,如果他们希望重新打开标签。我似乎想不出一种不循环所有数据点的方法来实现这一点

我可以完全隐藏的点和标签

cht.Series("srs").Enabled = False
但我只想隐藏标签,然后在用户选择后重新显示

谢谢你的帮助

编辑: 由于我还没有找到一个方法来关闭和打开标签与一个命令,我目前正在循环通过该系列的每个点

    Me.Cursor = Cursors.WaitCursor
    Application.DoEvents()

    'suspend updating UI
    cht.Series.SuspendUpdates()

    'cycle through all points in the series and set the label either to an empty string or whatever is cached in the Tag property.
    'todo: this is not efficient for large datasets but its the only thing we have.
    For Each pt As DataPoint In cht.Series("srs").Points
        If mnuDisplayLabels.Checked Then
            pt.Label = pt.Tag.ToString
        Else
            pt.Label = ""
        End If
    Next pt

    'resume updating UI
    cht.Series.ResumeUpdates()

    'force redraw of chart
    cht.Update()

我认为您必须循环,但您希望在完成所有点的更新之前暂停更新UI。尝试以下方法:

chart1.Series.SuspendUpdates();

foreach (Series s in chart1.Series)
{
    s.IsValueShownAsLabel = false;
}

chart1.Series.ResumeUpdates();

这正是我害怕的,但让我试一试。