开发者

example from .netcharting not working

I am tyring to use .netcharting as a form of charting tool, an example piece of code it provides is this

using System;
using System.Drawing;
using System.Collections;
using Sy开发者_StackOverflowstem.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));

        }

I put that in its own class and then tried to call it as such;

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);
        }
    }
}

The form just doesnt appaear, does anyone know the process for doing this, for example do i need to call t.show or something ?


In order to show a form from the Main() method, you need to call Application.Run(someForm).
This will show the form and run a message loop until the form is closed.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜