【TeeChart .NET教程】(十五)3D图表

上一篇:【TeeChart .NET教程】(十四)打印图表

【下载TeeChart.Net最新版本】

图表显示模式

1.1 (3D)图表编辑器页面

在设计时使用图表编辑器定义主要的2D/3D显示选项。

teecahrt

1.2 2D图表

可以使用图表编辑器在设计时选择2D图表,取消选中“Editor编辑器”页面上的3D复选框可将图表置于2D模式,在运行时,您可以随时将图表更改为2D:

[C#.Net]

tChart1.Aspect.View3D = false;

[VB.Net]

TChart1.Aspect.View3D = False

使用2D图表不会出现任何特殊问题,所有对象坐标都是相对于图表面板或图表矩形的位置,不需要对3D偏移进行任何限制。

1.3 3D正交图

3D正交模式是获得3D“effect”的默认方式。TeeChart根据TChart1.Aspect.Chart3DPercent属性设置(在图表编辑器页面上的设计时也可用)以正交角度绘制深度效果。无法旋转3D正交图表,底部轴始终是水平的, 使用3D正交图表时,您需要在自定义绘制到画布时考虑Width3D和Height3D 3D偏移。如果希望绘制的项目与图表后墙齐平,则应添加偏移量。请参阅以下示例(此示例在图表中绘制一条对角线,刷新到图表的前面):

[C#.Net]

private void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g) { 
        Point p1 = new Point(tChart1.Axes.Left.Position, tChart1.Axes.Top.Position); 
        Point p2 = new Point(tChart1.Axes.Right.Position, tChart1.Axes.Bottom.Position); 
        g.MoveTo(p1); 
        g.LineTo(p2, 0); 
}

[VB.Net]

Private Sub TChart1_AfterDraw(ByVal sender As Object, ByVal g As Steema.TeeChart.Drawing.Graphics3D) Handles TChart1.AfterDraw 
        Dim P1 As New Point(TChart1.Axes.Left.Position, TChart1.Axes.Top.Position) 
        Dim P2 As New Point(TChart1.Axes.Right.Position, TChart1.Axes.Bottom.Position) 
        g.MoveTo(P1) 
        g.LineTo(P2, 0) 
End Sub

此示例在图表中绘制一条对角线,并刷新到图表的背面

[C#.Net]

        int width3D = tChart1.Aspect.Width3D; 
        Point p1 = new Point(tChart1.Axes.Left.Position, tChart1.Axes.Top.Position); 
        Point p2 = new Point(tChart1.Axes.Right.Position, tChart1.Axes.Bottom.Position); 
        g.MoveTo(p1, width3D); 
        g.LineTo(p2, width3D); 
}

[VB.Net]

Private Sub TChart1_AfterDraw(ByVal sender As Object, ByVal g As Steema.TeeChart.Drawing.Graphics3D) Handles TChart1.AfterDraw 
        Dim Width3D As Integer = TChart1.Aspect.Width3D 
        Dim P1 As New Point(TChart1.Axes.Left.Position, TChart1.Axes.Top.Position) 
        Dim P2 As New Point(TChart1.Axes.Right.Position, TChart1.Axes.Bottom.Position) 
        g.MoveTo(P1, Width3D) 
        g.LineTo(P2, Width3D) 
End Sub

在运行时使用3D图表的显示属性时使用Aspect界面(*注意:并非所有选项都可用于正交图表)。

1.4 3D“原生”Windows图表

原生Windows模式3D提供图表旋转和高度90°,您可以放大和缩小整个图表。通过取消选择3D Editor页面上的Orthogonal复选框,在设计时为TeeChart选择Native Windows mode 3D。

[C#.Net]

tChart1.Aspect.Orthogonal = false;

[VB.Net]

TChart1.Aspect.Orthogonal = False

在图表编辑器中,取消激活“Orthogonal正交”将同时激活“Elevation”和“Rotation”的滑动条,从而允许更改这些显示属性的设计时间。

猜你喜欢

转载自blog.csdn.net/xiaochuachua/article/details/81668827