首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >.netcharting不起作用的示例

.netcharting不起作用的示例
EN

Stack Overflow用户
提问于 2011-03-07 23:02:52
回答 1查看 1.1K关注 0票数 0

我很乐意使用.netcharting作为一种图表工具,它提供的示例代码是这样的

代码语言:javascript
复制
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using dotnetCHARTING.WinForms;

namespace dotnetChartingSamples
{

    /// Summary description for a01.

    public class M01
    {



        public void CreateChart(ref Chart Chart1)
        {

            Chart1.TempDirectory = "temp";
            Chart1.Debug = true;

            Chart1.Type = ChartType.Organizational;
            Chart1.Size = new Size(750,430);
            Chart1.ChartArea.Padding = 20;

            Chart1.DefaultElement.Annotation = new Annotation("<block hAlign='right' fStyle='bold' fSize='11'>%Name<row><img:images/Org%image.png>%position");
            Chart1.DefaultElement.Annotation.Padding = 5;
            Chart1.DefaultElement.Annotation.Size = new Size(150, 100);
            Chart1.DefaultElement.Annotation.Background.Color = Color.FromArgb(79, 189, 28);

            Chart1.DefaultSeries.Line.Width = 3;
            Chart1.DefaultSeries.Line.Color = Color.Gray;


            // *DYNAMIC DATA NOTE* 
            // This sample uses random data to populate the Chart1. To populate 
            // a chart with database data see the following resources:
            // - Use the getLiveData() method using the dataEngine to query a database.
            // - Help File > Getting Started > Data Tutorials
            // - DataEngine Class in the help file      
            // - Sample: features/DataEngine.aspx

            SeriesCollection mySC = getData();

            // Add the random data.
            Chart1.SeriesCollection.Add(mySC);
        }

        SeriesCollection getData()
        {

            Element e1 = new Element("Margret Swanson");
            Element e2 = new Element("Mark Hudson");
            Element e3 = new Element("Chris Lysek");
            Element e4 = new Element("Karyn Borbas");
            Element e5 = new Element("Chris Rup");
            Element e6 = new Element("Jenny Powers");
            Element e7 = new Element("Katie Swift");

            e1.CustomAttributes.Add("position", "President");
            e2.CustomAttributes.Add("position", "Vice President Marketing");
            e3.CustomAttributes.Add("position", "Vice President Sales");
            e4.CustomAttributes.Add("position", "Marketing Manager");
            e5.CustomAttributes.Add("position", "Marketing Manager");
            e6.CustomAttributes.Add("position", "Sales Manager");
            e7.CustomAttributes.Add("position", "Sales Manager");

            e1.CustomAttributes.Add("image", "7");
            e2.CustomAttributes.Add("image", "1");
            e3.CustomAttributes.Add("image", "2");
            e4.CustomAttributes.Add("image", "4");
            e5.CustomAttributes.Add("image", "6");
            e6.CustomAttributes.Add("image", "8");
            e7.CustomAttributes.Add("image", "9");

            e2.Parent = e1;
            e3.Parent = e1;
            e4.Parent = e2;
            e5.Parent = e2;
            e6.Parent = e3;
            e7.Parent = e3;

            return new SeriesCollection(new Series("", e1, e2, e3, e4, e5, e6, e7));

        }

我把它放在它自己的类里,然后试着这样叫它;

代码语言:javascript
复制
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using dotnetCHARTING.WinForms;

namespace dotnetcharting
{
    static class Program
    {
        static void Main(string[] args)
        {
            Chart chart = new Chart();

            test t = new test();
            t.CreateChart(ref chart);

            System.Threading.Thread.Sleep(50000);
        }
    }
}

表单就是看不出来,有没有人知道做这件事的过程,比如我需要调用t.show还是别的什么?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-03-07 23:07:31

为了显示来自Main()方法的表单,您需要调用Application.Run(someForm)

这将显示表单并运行消息循环,直到表单关闭。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5221186

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档