winform teechart甘特图、等高线图、热力图示例

发布时间 2023-07-05 15:37:40作者: 户的博客

teechart收费,这里用测试的。(一开始不知道收费的,在nuget里搜索有就安装了,结果页面上有购买提示)

新建一个winform .net framework项目,nuget程序包中安装teechart

 添加一个teechart控件

 添加完以后这样的(页面上 This is an EVALUATION version of TeeChart for Windows Forms. Please order a FULL version from http://www.steema.com/buy 对应网页是购买的)

 属性-chart-add

 选择gantt

添加完以后

 这时候启动没有数据

 需要在后台加一个:gantt1.FillSampleValues(); // 填充示例数据

public Form1()
{
    InitializeComponent();
    gantt1.FillSampleValues(); // 填充示例数据
}

再次启动后看到和预览页面一样了

 有在后端直接添加的方法

using Steema.TeeChart;
using Steema.TeeChart.Styles;

namespace TeechartTest
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();

            TChart chart1 = new TChart();
            chart1.Dock = DockStyle.Fill;
            this.tabPage1.Controls.Add(chart1);//这里用了标签页,如果没有可以替换为this.Controls.Add(chart1);
            Gantt gantt = new Gantt(chart1.Chart);
            gantt.Add(DateTime.Now, DateTime.Now.AddDays(2),1, "test1");
            gantt.Add(DateTime.Now.AddDays(3), DateTime.Now.AddDays(5), 2, "test2");
            gantt.Add(DateTime.Now.AddDays(4), DateTime.Now.AddDays(5), 3, "test3");
            gantt.Add(DateTime.Now.AddDays(6), DateTime.Now.AddDays(8), 4, "test4");
            gantt.Add(DateTime.Now.AddDays(9), DateTime.Now.AddDays(10), 5, "test5");
        }
    }
}

在网上找的甘特图的类GanttSeries这里用的Gantt,可能dll和购买的不一样;等高线图和网上一样用了Contour;热力图网上的是HeatMap这里没找到,找了一个类似的IsoSurface。手动添加数据Contour和HeatMap一样都是3D里的,添加数据都可以用

//contour.Add(0, 4, 0);
//contour.Add(1, 3, 0);
//contour.Add(2, 2, 0);
//contour.Add(0, 11, 1);
//contour.Add(1, 2, 1);
//contour.Add(2, 5, 1);
//contour.Add(0, 6, 2);
//contour.Add(1, 8, 2);
//contour.Add(2, 2, 2);
//
double[] x = {0,1,2,0,1,2,0,1,2 };
double[] y = {4,3,2,11,2,5,6,8,2 };
double[] z = {0,0,0,1,1,1,2,2,2 };
contour.Add(x,y,z);

 

官网:https://www.steema.com/product/net

文档地址:https://www.steema.com/docs/TeeChartNET/ (路径:首页-support-documentation-teechart-teechart .net-Download general tutorials and reference files in chm format)