myPlot.Clear();
//加入网格
Grid mygrid = new Grid();
myPlot.Add(mygrid);
myPlot.Title = "测试";
LinePlot lp = new LinePlot();
double[] a = new double[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 };
string[] b = new string[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", };
double[] ab = new double[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
ArrayList dates = new ArrayList();
dates.Add(Convert.ToDateTime("2007-01-01"));
dates.Add(Convert.ToDateTime("2008-01-02 "));
dates.Add(Convert.ToDateTime("2008-01-03 "));
dates.Add(Convert.ToDateTime("2008-01-04 "));
dates.Add(Convert.ToDateTime("2008-01-05 "));
dates.Add(Convert.ToDateTime("2008-01-06 "));
dates.Add(Convert.ToDateTime("2008-01-07 "));
dates.Add(Convert.ToDateTime("2008-01-08 "));
dates.Add(Convert.ToDateTime("2008-01-09 "));
dates.Add(Convert.ToDateTime("2008-01-10 "));
dates.Add(Convert.ToDateTime("2008-01-11 "));
dates.Add(Convert.ToDateTime("2008-02-12 "));
lp.AbscissaData = dates;
//柱状
BarPlot storeGrowth = new BarPlot();
storeGrowth.AbscissaData = dates;
storeGrowth.OrdinateDataTop = a;
storeGrowth.OrdinateDataBottom = ab;
storeGrowth.FillBrush = NPlot.RectangleBrushes.Solid.Red;
//storeGrowth.BorderPen = new Pen( Color.Black, 2.0f );
myPlot.Add(storeGrowth);
//标签
LabelPointPlot tp1 = new LabelPointPlot();
tp1.AbscissaData = dates;
tp1.OrdinateData = a;
tp1.TextData = b;
tp1.LabelTextPosition = LabelPointPlot.LabelPositions.Above;
tp1.Marker = new Marker(Marker.MarkerType.None, 10);
myPlot.Add(tp1);
//lp.
lp.DataSource = a;
lp.Pen = new Pen(Color.Blue, 3.0f);
lp.Label = "Gaussian Function";
myPlot.Add(lp);
myPlot.XAxis1.Label = "时间";
myPlot.YAxis1.Label = "次数";
//myPlot.XAxis1.WorldLength = 60 * 60 * 24;
//设置网格距离
//myPlot.XAxis1.WorldMin += myPlot.XAxis1.WorldLength/ 12;//WorldLength=n*24*60*60;
//myPlot.XAxis1.WorldMax -= myPlot.XAxis1.WorldLength / 2;
//myPlot.XAxis1.
//myPlot.XAxis1.WorldLength = 10;
//myPlot.
//让日期斜45度。
myPlot.XAxis1.TicksLabelAngle = 45;
//下面代码可让窗体移动begin;
myPlot.AddInteraction(new NPlot.Windows.PlotSurface2D.Interactions.HorizontalDrag());
//myPlot.AddInteraction(new NPlot.Windows.PlotSurface2D.Interactions.VerticalDrag());
myPlot.AddInteraction(new NPlot.Windows.PlotSurface2D.Interactions.AxisDrag(true));
myPlot.Refresh();