彩票走势图

TeeChart Pro .NET使用教程(2022):图表面板上的自定义绘图(下)

翻译|使用教程|编辑:凌霄汉|2022-04-07 17:18:01.753|阅读 115 次

概述:此次文章为大家TeeChart Pro .NET使用教程中的图表面板上的自定义绘图。

# 慧都年终大促·界面/图表报表/文档/IDE等千款热门软控件火热促销中 >>

相关链接:

TeeChart Pro 将自动为您定义所有 Axis 标签,并提供足够的灵活性来定制您可能有的任何特定要求。 TeeChart Pro 提供真正的多轴。 这些在设计或运行时可用,并为 Axis 定义提供了无数的可能性和灵活性。



帆布笔和画笔

上面的 Line 是使用为绘制 Line 之前绘制的最后一个对象定义的 Pen 和 Brush 绘制的。 那可能是也可能不是您想要的笔。 相应地更改钢笔:

[C#] 
private void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g) { 
        Point p5 = new Point(line1.CalcXPos(5), line1.CalcYPos(5)); 
        Point p15 = new Point(line1.CalcXPos(15), line1.CalcYPos(15)); 
        g.Pen.DashCap = System.Drawing.Drawing2D.DashCap.Triangle; 
        g.Pen.EndCap = System.Drawing.Drawing2D.LineCap.DiamondAnchor; 
        g.Pen.Style = System.Drawing.Drawing2D.DashStyle.DashDotDot; 
        g.Pen.Transparency = 70; 
        g.Pen.Width = 3; 
        g.Pen.Color = Color.BlueViolet; 
        g.MoveTo(p5); 
        g.LineTo(p15, 0); 
} 
 
[VB.Net] 
Private Sub TChart1_AfterDraw(ByVal sender As Object, ByVal g As Steema.TeeChart.Drawing.Graphics3D) Handles TChart1.AfterDraw 
        Dim P5 As New Point(Line1.CalcXPos(5), Line1.CalcYPos(5)) 
        Dim P15 As New Point(Line1.CalcXPos(15), Line1.CalcYPos(15)) 
        g.Pen.DashCap = System.Drawing.Drawing2D.DashCap.Triangle 
        g.Pen.EndCap = System.Drawing.Drawing2D.LineCap.DiamondAnchor 
        g.Pen.Style = System.Drawing.Drawing2D.DashStyle.DashDotDot 
        g.Pen.Transparency = 70 
        g.Pen.Width = 3 
        g.Pen.Color = Color.BlueViolet 
        g.MoveTo(P5) 
        g.LineTo(P15, 0) 
End Sub 
添加 2D 形状

以与 Canvas Lines 类似的方式添加 Canvas Shapes。 以下示例在图表区域的中心添加一个矩形:

  • 二维图表
  • 2D 图表仅支持 2D 形状。

[C#] 
private void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g) { 
        Size s = new Size(100,100); 
        Point l = new Point(g.ChartXCenter - (s.Width / 2), g.ChartYCenter - (s.Height / 2)); 
        Rectangle r = new Rectangle(l,s); 
        g.Pen.Color = Color.Aquamarine; 
        g.Brush.Color = Color.Blue; 
        g.Rectangle(r); 
} 
 
[VB.Net] 
Private Sub TChart1_AfterDraw(ByVal sender As Object, ByVal g As Steema.TeeChart.Drawing.Graphics3D) Handles TChart1.AfterDraw 
        Dim S As New Size(100, 100) 
        Dim L As New Point(g.ChartXCenter - (S.Width / 2), g.ChartYCenter - (S.Height / 2)) 
        Dim R As New Rectangle(L, S) 
        g.Pen.Color = Color.Aquamarine 
        g.Brush.Color = Color.Blue 
        g.Rectangle(R) 
End Sub 

  • 3D 图表
  • 在 3D 图表上,您也可以在 Z 平面中移动矩形。此示例将矩形放置在左墙上,但将其移向图表后部的一半(朝向后墙)。

[C#] 
private void Form1_Load(object sender, System.EventArgs e) { 
        point3DSeries1.LinePen.Visible = false; 
        point3DSeries1.FillSampleValues(20); 
        point3DSeries1.VertAxis = VerticalAxis.Both; 
        point3DSeries1.HorizAxis = HorizontalAxis.Both; 
        tChart1.Aspect.Chart3DPercent = 50; 
        tChart1.Axes.Depth.Visible = true; 
} 
 
private void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g) { 
        Size s = new Size(100,100); 
        Point l = new Point(tChart1.Axes.Left.Position, g.ChartYCenter - (s.Height / 2)); 
        Rectangle r = new Rectangle(l,s); 
        g.Pen.Color = Color.Aquamarine; 
        g.Brush.Color = Color.Blue; 
        g.Rectangle(r, tChart1.Aspect.Width3D/2); 
} 
 
[VB.Net] 
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 
        Point3DSeries1.LinePen.Visible = False 
        Point3DSeries1.FillSampleValues(20) 
        Point3DSeries1.VertAxis = Steema.TeeChart.VerticalAxis.Both 
        Point3DSeries1.HorizAxis = Steema.TeeChart.HorizontalAxis.Both 
        TChart1.Aspect.Chart3DPercent = 50 
        TChart1.Axes.Depth.Visible = True 
End Sub 
 
Private Sub TChart1_AfterDraw(ByVal sender As Object, ByVal g As Steema.TeeChart.Drawing.Graphics3D) Handles TChart1.AfterDraw 
        Dim S As New Size(100, 100) 
        Dim L As New Point(TChart1.Axes.Left.Position, g.ChartYCenter - (S.Height / 2)) 
        Dim R As New Rectangle(L, S) 
        g.Pen.Color = Color.Aquamarine 
        g.Brush.Color = Color.Blue 
        g.Rectangle(R, TChart1.Aspect.Width3D / 2) 
End Sub 
添加 3D 形状

您可以将 3D 形状添加到 3D 图表。 此示例在 Chart 矩形的中间绘制一个 Cube:

[C#] 
private void Form1_Load(object sender, System.EventArgs e) { 
        point3DSeries1.LinePen.Visible = false; 
        point3DSeries1.FillSampleValues(20); 
        tChart1.Aspect.Chart3DPercent = 50; 
        tChart1.Legend.Visible = false; 
        tChart1.Axes.Depth.Visible = true; 
} 
 
private void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g) { 
        Size s = new Size(50,50); 
        Point p = new Point(g.ChartXCenter - (s.Width/2), g.ChartYCenter - (s.Height/2)); 
        Rectangle r = new Rectangle(p,s); 
        g.Cube(r, 0, 20, true); 
} 
 
[VB.Net] 
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 
        Point3DSeries1.LinePen.Visible = False 
        Point3DSeries1.FillSampleValues(20) 
        TChart1.Aspect.Chart3DPercent = 50 
        TChart1.Legend.Visible = False 
        TChart1.Axes.Depth.Visible = True 
End Sub 
 
Private Sub TChart1_AfterDraw(ByVal sender As Object, ByVal g As Steema.TeeChart.Drawing.Graphics3D) Handles TChart1.AfterDraw 
        Dim S As New Size(50, 50) 
        Dim P As New Point(g.ChartXCenter - (S.Width / 2), g.ChartYCenter - (S.Height / 2)) 
        Dim R As New Rectangle(P, S) 
        g.Cube(R, 0, 20, True) 
End Sub 

如果您想了解TeeChart for .NET正版价格,欢迎咨询

TeeChart Pro .NET使用教程(2022):如何进行ADO 数据库访问

标签:

本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,如果存在内容上的异议请邮件反馈至chenjj@pclwef.cn


为你推荐

  • 推荐视频
  • 推荐活动
  • 推荐产品
  • 推荐文章
  • 慧都慧问
扫码咨询


添加微信 立即咨询

电话咨询

客服热线
023-68661681

TOP