饼图点击事件
提示:一般用户可以忽略本节内容,因为Foxtable最新版已经改进了旧的图表功能,可以方便的设置样式去掉边框和背景,并且可以嵌入
到仪表控件中,且窗口也开始支持自动布局。所以如果嫌麻烦的话,可以直接嵌入图表里的饼图到卡片四的位置
,会方便很多,参考:饼形图 图表事件
自动布局
主要是点击饼图后,对应的扇形可以离开圆心。难点是计算扇形离开后的位置,这里主要涉及到三角函数以及向量坐标的计算,数学如果都还给老师的建议直接使用原来的图表做饼图,最新版本的Foxtable添加了对应的图表事件:http://www.foxtable.com/webhelp/topics/6014.htm 。
要想在点击饼图后可以让对应的扇形离开圆心,可以到ItemClick添加以下代码:
-
If e.Item.name.startswith("产业分布") Then
-
Dim gs As GaugeSector
-
For Each st As Object In e.Gauge.CoverShapes
-
If st.Name.EndsWith("_Cur") AndAlso st.Name <> e.Item.name Then
-
gs = st
-
gs.Name = gs.Name.Replace("_Cur", "")
-
-
gs.Viewport.X = 0
-
gs.Viewport.Y = 0
-
gs.CenterRadius = 0
-
gs.Visible = True
-
e.Sender.Gauges(5).CoverShapes(gs.Name & "_d").Visible = True
-
Exit For
-
End If
-
Next
-
gs = e.Item
-
Dim s As String = gs.Name.Replace("_Cur", "")
-
e.Sender.Gauges(5).CoverShapes(s & "_d").Visible = True
-
If gs.CenterRadius <> 0 Then
-
-
gs.Viewport.X = 0
-
gs.Viewport.Y = 0
-
gs.CenterRadius = 0
-
gs.Name = s
-
Else
-
Dim a As Double = gs.StartAngle + gs.SweepAngle / 2
-
-
If a <= 90 Then
-
a = 90 - a
-
Else
-
a = 360 - a + 90
-
End If
-
-
a = a * Math.PI / 180
-
-
gs.Viewport.X = 50 * Math.Cos(a)
-
gs.Viewport.Y = 50 * Math.Sin(a) * -1
-
gs.CenterRadius = 10
-
If gs.Name.EndsWith("_Cur") = False Then
-
gs.Name = gs.Name & "_Cur"
-
End If
-
End If
-
gs.Visible = True
-
End If
如果要想让点击后的扇形闪烁起来,可以到TimerTick事件写代码:
-
-
Dim gs As GaugeSector
-
Dim rg As RadialGauge = gg.Gauges(9)
-
For Each st As Object In rg.CoverShapes
-
If st.Name.EndsWith("_Cur") Then
-
gs = st
-
gs.Visible = Not gs.Visible
-
Dim s As String = gs.Name.Replace("_Cur", "")
-
gg.Gauges(5).CoverShapes(s & "_d").Visible = Not gg.Gauges(5).CoverShapes(s & "_d").Visible
-
Exit For
-
End If
-
Next