我正在使用.netcharting作为图表工具的一种形式,它提供的示例代码就是这个
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));
}
我把它放在自己的班级中然后试着这样称呼它;
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或其他什么?