【发布时间】:2017-07-27 20:09:05
【问题描述】:
VB2010 使用 MS Chart:我添加了一个系列作为点图。有时有超过 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()
【问题讨论】:
标签: charts labels series mschart points