如何隐藏图表线。 [英] how to hide chart line.
本文介绍了如何隐藏图表线。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在点击btn1时隐藏line2 show line1
如何在点击btn2时隐藏line1 show line
私有 Sub Button1_Click( ByVal sender As System。 Object , ByVal e As System.EventArgs)句柄 Button1.Click
对于 每个行作为 String 在 IO.File.ReadAllLines( C:\ TestTolder1 \\\ 03.txt)
Dim points()作为 Double = Array.ConvertAll(line.Split( , c),函数(s) CDbl (s))
Chart1.Series( 能量)。Points.AddXY(点数( 2 ),点数( 0 ))
下一步
结束 Sub
私有 Sub Button2_Click( ByVal sender As System。对象, ByVal e As System.EventArgs)句柄 Button2.Click
对于 每个 line 作为 字符串 在 IO中。 File.ReadAllLines( C:\ TestSolder1 \123.txt)
< span class =code-keyword> Dim points() As Double = Array。 ConvertAll(line.Split( , c),函数(s) CDbl (s))
Chart1.Series( Power)。Points.AddXY(points( 2 ),points( 1 ))
下一步
结束 Sub
解决方案
试试这个
私有 Sub Button1_Click_1(发件人 As System。 Object ,e As System.EventArgs)句柄 Button1.Click
' 添加此行
Chart1.Series( Power)。Points.Clear()
对于 每个行 As 字符串 在 IO.File.ReadAllLines( C:\ TestFolder \123.txt)
Dim points() 作为 Double = Array.ConvertAll(line.Split( , c),功能(s) CDbl (s))
Chart1.Series( 能量)。Points.AddXY(points( 0 ),points( 0 ))
下一步
结束 Sub
私有 Sub Button2_Click(发件人作为系统。对象,e 正如 System.EventArgs)句柄 Button2.Click
' 添加此行
Chart1.Series( Energy)。Points.Clear()
对于 每个 line 作为 字符串 在 IO.File.ReadAllLines( C:\ TestFolder\123.txt)
Dim points() As Double = Array.ConvertAll(line.Split( , c),功能(s) CDbl (s))
Chart1.Series( Power)。Points.AddXY(points( 1 ),points( 0 ))
下一步
结束 Sub
这不会删除系列,只是清除系列中的数据图表。
要切换图例,您可以将以下内容添加到相应的按钮事件中。
' 在Button1中单击事件添加
Chart1.Series( Power)。IsVisibleInLegend = False
Chart1.Series( 能量)。IsVisibleInLegend = True
< span class =code-comment>' 在按钮2中单击事件添加
Chart1.Series( 能量)。IsVisibleInLegend = False
Chart1.Series(< span class =code-string> P. ower)。IsVisibleInLegend = True
添加附加代码。
How to hide line2 show line1 when btn1 is clicked
how to hide line1 show line2 when btn2 is clicked
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
For Each line As String In IO.File.ReadAllLines("C:\TestFolder1\123.txt")
Dim points() As Double = Array.ConvertAll(line.Split(","c), Function(s) CDbl(s))
Chart1.Series("Energy").Points.AddXY(points(2), points(0))
Next
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
For Each line As String In IO.File.ReadAllLines("C:\TestFolder1\123.txt")
Dim points() As Double = Array.ConvertAll(line.Split(","c), Function(s) CDbl(s))
Chart1.Series("Power").Points.AddXY(points(2), points(1))
Next
End Sub
解决方案
Try this
Private Sub Button1_Click_1(sender As System.Object, e As System.EventArgs) Handles Button1.Click 'Add this line Chart1.Series("Power").Points.Clear() For Each line As String In IO.File.ReadAllLines("C:\TestFolder\123.txt") Dim points() As Double = Array.ConvertAll(line.Split(","c), Function(s) CDbl(s)) Chart1.Series("Energy").Points.AddXY(points(0), points(0)) Next End Sub Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click 'Add this Line Chart1.Series("Energy").Points.Clear() For Each line As String In IO.File.ReadAllLines("C:\TestFolder\123.txt") Dim points() As Double = Array.ConvertAll(line.Split(","c), Function(s) CDbl(s)) Chart1.Series("Power").Points.AddXY(points(1), points(0)) Next End Sub
This does not remove the series, but just clears the data from the chart.
To toggle the legends you can add the following to the respective button events.
'In Button1 Click event add Chart1.Series("Power").IsVisibleInLegend = False Chart1.Series("Energy").IsVisibleInLegend = True 'In button2 Click event add Chart1.Series("Energy").IsVisibleInLegend = False Chart1.Series("Power").IsVisibleInLegend = True
[Edit] Add addtional code.
这篇关于如何隐藏图表线。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文