public void Clear() { isClear = true; canvas.Clear(); canvas.Refresh(); SetGraphDefaults(canvas, title); }
public void InitPS(NPlot.Windows.PlotSurface2D PlotSurface2D) { PlotSurface2D.AutoScaleAutoGeneratedAxes = true; PlotSurface2D.AutoScaleTitle = false; PlotSurface2D.DateTimeToolTip = true; PlotSurface2D.Legend = null; PlotSurface2D.LegendZOrder = -1; //PS.Location = new System.Drawing.Point(0, 0); PlotSurface2D.Name = "costPS"; PlotSurface2D.RightMenu = null; PlotSurface2D.Padding = 1; //滑鼠tooltips 時間+價格 PlotSurface2D.ShowCoordinates = true; PlotSurface2D.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.Default; PlotSurface2D.TabIndex = 2; PlotSurface2D.Title = "123"; PlotSurface2D.TitleFont = new System.Drawing.Font("Arial", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); PlotSurface2D.Clear(); Grid mygrid = new Grid(); mygrid.HorizontalGridType = Grid.GridType.Fine; mygrid.VerticalGridType = Grid.GridType.Fine; PlotSurface2D.Add(mygrid); }
public void RefreshPlots(NPlot.Windows.PlotSurface2D graphSurface) { graphSurface.Clear(); if (_plots.Count == 0) { graphSurface.Hide(); return; } foreach (var plot in _plots) { var lp = new LinePlot { Color = plot.PlotColour, AbscissaData = plot.XData, OrdinateData = plot.YData, Label = plot.PlotName }; graphSurface.Add(lp); } graphSurface.Title = "Pilot Trends"; var grid = new Grid { VerticalGridType = Grid.GridType.Fine, HorizontalGridType = Grid.GridType.Fine, MajorGridPen = new Pen(Color.LightGray, 0.5f) }; graphSurface.Add(grid); graphSurface.Refresh(); var leg = new Legend { HorizontalEdgePlacement = Legend.Placement.Inside, VerticalEdgePlacement = Legend.Placement.Outside, XOffset = 10, YOffset = 10 }; leg.AttachTo(PlotSurface2D.XAxisPosition.Top, PlotSurface2D.YAxisPosition.Right); graphSurface.Legend = leg; graphSurface.LegendZOrder = 10; graphSurface.YAxis1.WorldMin = 0; graphSurface.XAxis1.Label = "Tour Number"; graphSurface.XAxis1.WorldMin -= 1; graphSurface.XAxis1.WorldMax += 1; graphSurface.Show(); graphSurface.Refresh(); }
public void ClearAllData() { _base.XAxis1.WorldMax = 0; _base.XAxis1.WorldMin = 0; _base.YAxis1.WorldMax = 0; _base.YAxis1.WorldMin = 0; _base.Clear(); _lines.Clear(); }
private void DrawPointPlot(DataTable dt) { #region 1.初始化 volumePS this.volumePS = new NPlot.Windows.PlotSurface2D(); // // volumePS // this.volumePS.AutoScaleAutoGeneratedAxes = false; this.volumePS.AutoScaleTitle = false; this.volumePS.BackColor = System.Drawing.SystemColors.ControlLightLight; this.volumePS.DateTimeToolTip = false; this.volumePS.Legend = null; this.volumePS.LegendZOrder = -1; //this.volumePS.Location = new System.Drawing.Point(70, 636); this.volumePS.Dock = DockStyle.Fill; this.volumePS.Name = "volumePS"; this.volumePS.RightMenu = null; this.volumePS.ShowCoordinates = false; this.volumePS.Size = new System.Drawing.Size(1053, 139); this.volumePS.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.None; this.volumePS.TabIndex = 3; this.volumePS.Title = ""; this.volumePS.TitleFont = new System.Drawing.Font("Arial", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); this.volumePS.XAxis1 = null; this.volumePS.XAxis2 = null; this.volumePS.YAxis1 = null; this.volumePS.YAxis2 = null; #endregion /*--============================================volumePS-PointPlot========================================================--*/ #region 3.1 创建PointPlot【pp】. PointPlot pp = new PointPlot(); pp.Marker = new Marker(Marker.MarkerType.Square, 0); pp.Marker.Pen = new Pen(Color.Red, 5.0f); pp.Marker.DropLine = true; pp.DataSource = dt; pp.AbscissaData = "Date"; pp.OrdinateData = "Volume"; #endregion #region 3.2 添加pp到volumePS volumePS.Clear(); volumePS.Add(pp); volumePS.YAxis1.Label = "Volume"; volumePS.YAxis1.LabelOffsetAbsolute = true; volumePS.YAxis1.LabelOffset = 40; volumePS.AddAxesConstraint(new AxesConstraint.AxisPosition(PlotSurface2D.YAxisPosition.Left, 60)); volumePS.AddInteraction(new NPlot.Windows.PlotSurface2D.Interactions.AxisDrag(false)); volumePS.AddInteraction(new NPlot.Windows.PlotSurface2D.Interactions.HorizontalDrag()); volumePS.InteractionOccured += new NPlot.Windows.PlotSurface2D.InteractionHandler(volumePS_InteractionOccured); volumePS.PreRefresh += new NPlot.Windows.PlotSurface2D.PreRefreshHandler(volumePS_PreRefresh); #endregion }
private void PlotChart(QueryResultsEventArgs e, PlotSurface2D plot, List <KeyValuePair <int, Guid> > signals, bool cacheAxis) { if (cacheAxis) { double minX, maxX, minY, maxY; plot.Title = m_plotTitle; maxX = plot.XAxis1.WorldMax; minX = plot.XAxis1.WorldMin; maxY = plot.YAxis1.WorldMax; minY = plot.YAxis1.WorldMin; foreach (IDrawable drawing in plot.Drawables.ToArray()) { plot.Remove(drawing, false); } foreach (KeyValuePair <int, Guid> freq in signals) { SignalDataBase data = e.Results[freq.Value]; List <double> y = new List <double>(data.Count); List <double> x = new List <double>(data.Count); for (int i = 0; i < data.Count; i++) { ulong time; double value; data.GetData(i, out time, out value); x.Add(time); y.Add(value * m_scalingFactor); } LinePlot lines = new LinePlot(y, x); lines.Pen = m_colorWheel.TryGetPen(freq.Key); plot.Add(lines); } plot.XAxis1.WorldMax = maxX; plot.XAxis1.WorldMin = minX; plot.YAxis1.WorldMax = maxY; plot.YAxis1.WorldMin = minY; plot.Refresh(); } else { plot.Clear(); plot.Title = m_plotTitle; AddInteractions(); foreach (KeyValuePair <int, Guid> freq in signals) { SignalDataBase data = e.Results[freq.Value]; List <double> y = new List <double>(data.Count); List <double> x = new List <double>(data.Count); for (int i = 0; i < data.Count; i++) { ulong time; double value; data.GetData(i, out time, out value); x.Add(time); y.Add(value * m_scalingFactor); } LinePlot lines = new LinePlot(y, x); lines.Pen = m_colorWheel.TryGetPen(freq.Key); plot.Add(lines); } if (plot.XAxis1 != null) { plot.XAxis1.WorldMax = e.EndTime.Ticks; plot.XAxis1.WorldMin = e.StartTime.Ticks; } plot.Refresh(); } }
public void OnLoadingFinished(Dictionary <ChannelInfo, DataTable> tables) { graph.Clear(); Grid myGrid = new Grid(); myGrid.VerticalGridType = Grid.GridType.Fine; myGrid.HorizontalGridType = Grid.GridType.Coarse; graph.Add(myGrid); Color[] availableColors = new Color[] { Color.Blue, Color.Red, Color.Violet, Color.Black, Color.Cyan, Color.Brown, Color.Yellow }; int trendNum = 0; foreach (ChannelInfo channelInfo in tables.Keys) { int valueColumnIndex = tables[channelInfo].Columns.IndexOf("Value"); int timeColumnIndex = tables[channelInfo].Columns.IndexOf("Time"); int valueCount = tables[channelInfo].Rows.Count; double[] values = new double[valueCount]; DateTime[] labels = new DateTime[valueCount]; for (int i = 0; i < valueCount; i++) { double.TryParse(tables[channelInfo].Rows[i].ItemArray[valueColumnIndex].ToString(), out values[i]); DateTime.TryParse(tables[channelInfo].Rows[i].ItemArray[timeColumnIndex].ToString(), out labels[i]); } LinePlot lp = new LinePlot(); lp.DataSource = values; lp.AbscissaData = labels; lp.Color = availableColors[trendNum % availableColors.Length]; lp.Label = channelInfo.ChannelName; graph.Add(lp); trendNum++; } Legend legend = new Legend(); legend.AttachTo(PlotSurface2D.XAxisPosition.Top, PlotSurface2D.YAxisPosition.Right); legend.HorizontalEdgePlacement = Legend.Placement.Inside; legend.VerticalEdgePlacement = Legend.Placement.Outside; legend.XOffset = 10; legend.YOffset = -10; graph.Legend = legend; graph.LegendZOrder = 1; graph.Visible = true; label1.Visible = false; Cursor = Cursors.Default; }
private void DrawCandlePlot(DataTable dt) { #region 1.初始化costPS this.costPS = new NPlot.Windows.PlotSurface2D(); this.costPS.AutoScaleAutoGeneratedAxes = false; this.costPS.AutoScaleTitle = false; this.costPS.BackColor = System.Drawing.SystemColors.ControlLightLight; this.costPS.DateTimeToolTip = false; this.costPS.Legend = null; this.costPS.LegendZOrder = -1; //this.costPS.Location = new System.Drawing.Point(70, 52); this.costPS.Dock = DockStyle.Fill; this.costPS.Size = new System.Drawing.Size(1053, 557); this.costPS.Name = "costPS"; this.costPS.RightMenu = null; this.costPS.ShowCoordinates = false; this.costPS.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.None; this.costPS.TabIndex = 2; this.costPS.Title = ""; this.costPS.TitleFont = new System.Drawing.Font("Arial", 14F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel); this.costPS.XAxis1 = null; this.costPS.XAxis2 = null; this.costPS.YAxis1 = null; this.costPS.YAxis2 = null; #endregion /*--===========================================costPS-CandlePlot=========================================================--*/ #region 2.1 创建 CandlePlot【cp】. CandlePlot cp = new CandlePlot(); cp.DataSource = dt; cp.AbscissaData = "Date"; cp.OpenData = "Open"; cp.LowData = "Low"; cp.HighData = "High"; cp.CloseData = "Close"; cp.BearishColor = Color.White; //方框颜色 cp.BullishColor = Color.Green; //方框颜色 cp.Style = CandlePlot.Styles.Filled; #endregion #region 2.2 添加cp到costPS costPS.Clear(); costPS.DateTimeToolTip = true; costPS.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; costPS.Add(new Grid()); costPS.Add(cp); // costPS.Title = "AU:JBH";//标题 // costPS.YAxis1.Label = "Price [$]"; //左侧标题 costPS.YAxis1.LabelOffset = 40; costPS.YAxis1.LabelOffsetAbsolute = true; costPS.XAxis1.HideTickText = true; costPS.YAxis1.HideTickText = true;//是否隐藏垂直刻度线标尺 costPS.AddInteraction(new NPlot.Windows.PlotSurface2D.Interactions.HorizontalDrag()); costPS.AddInteraction(new NPlot.Windows.PlotSurface2D.Interactions.VerticalDrag()); costPS.AddInteraction(new NPlot.Windows.PlotSurface2D.Interactions.AxisDrag(false)); costPS.InteractionOccured += new NPlot.Windows.PlotSurface2D.InteractionHandler(costPS_InteractionOccured); costPS.AddAxesConstraint(new AxesConstraint.AxisPosition(PlotSurface2D.YAxisPosition.Left, 60)); this.costPS.RightMenu = new ReducedContextMenu(); #endregion }
private void PlotChart(QueryResultsEventArgs e, PlotSurface2D plot, List <Guid> signals, bool cacheAxis) { if (cacheAxis) { maxX = plot.XAxis1.WorldMax; minX = plot.XAxis1.WorldMin; maxY = plot.YAxis1.WorldMax; minY = plot.YAxis1.WorldMin; foreach (IDrawable drawing in plot.Drawables.ToArray()) { plot.Remove(drawing, false); } ColorWheel.Reset(); foreach (Guid freq in signals) { SignalDataBase data = e.Results[freq]; List <double> y = new List <double>(data.Count); List <double> x = new List <double>(data.Count); for (int i = 0; i < data.Count; i++) { data.GetData(i, out ulong time, out double value); x.Add(time); y.Add(value); } LinePlot lines = new LinePlot(y, x); lines.Pen = ColorWheel.GetPen(); plot.Add(lines); } plot.XAxis1.WorldMax = maxX; plot.XAxis1.WorldMin = minX; plot.YAxis1.WorldMax = maxY; plot.YAxis1.WorldMin = minY; plot.Refresh(); } else { plot.Clear(); plot.AddInteraction(new PlotSurface2D.Interactions.HorizontalDrag()); plot.AddInteraction(new PlotSurface2D.Interactions.VerticalDrag()); plot.AddInteraction(new PlotSurface2D.Interactions.AxisDrag(false)); ColorWheel.Reset(); foreach (Guid freq in signals) { SignalDataBase data = e.Results[freq]; List <double> y = new List <double>(data.Count); List <double> x = new List <double>(data.Count); for (int i = 0; i < data.Count; i++) { data.GetData(i, out ulong time, out double value); x.Add(time); y.Add(value); } LinePlot lines = new LinePlot(y, x); lines.Pen = ColorWheel.GetPen(); plot.Add(lines); } plot.Refresh(); } }
public void InitSystemPlot() { try { plotSurface.Clear(); this.plotSurface.RightMenu = PlotSurface2D.DefaultContextMenu; plotSurface.Add(lineAvail); plotSurface.Add(lineUsage); plotSurface.PlotBackColor = plotSurface.BackColor; plotSurface.SmoothingMode = SmoothingMode.AntiAlias; plotSurface.Title = "CPU Power - Availability & Usage"; //plotSurface.TitleFont = new Font(new FontFamily("Microsoft Sans Serif" ), 9.75f, FontStyle.Bold); plotSurface.XAxis1.WorldMin = -60.0f; plotSurface.XAxis1.WorldMax = 0.0f; plotSurface.XAxis1.Label = "Seconds"; //plotSurface.XAxis1.LabelFont = new Font(new FontFamily("Microsoft Sans Serif" ), 9.75f, FontStyle.Bold); //plotSurface.XAxis1.TickTextFont = new Font(new FontFamily("Microsoft Sans Serif" ), 9.75f, FontStyle.Bold); plotSurface.YAxis1.WorldMin = 0.0; plotSurface.YAxis1.WorldMax = 100.0; plotSurface.YAxis1.Label = "Power [%]"; //plotSurface.YAxis1.LabelFont = new Font(new FontFamily("Microsoft Sans Serif" ), 9.75f, FontStyle.Bold); //plotSurface.YAxis1.TickTextFont = new Font(new FontFamily("Microsoft Sans Serif" ), 9.75f, FontStyle.Bold); Grid gridPlotSurface = new Grid(); gridPlotSurface.HorizontalGridType = Grid.GridType.None; gridPlotSurface.VerticalGridType = Grid.GridType.Fine; gridPlotSurface.MajorGridPen.Color = Color.DarkGray; plotSurface.Add(gridPlotSurface); plotSurface.Legend = new Legend(); plotSurface.Legend.NeverShiftAxes = false; plotSurface.Legend.AttachTo(NPlot.PlotSurface2D.XAxisPosition.Bottom, NPlot.PlotSurface2D.YAxisPosition.Left); plotSurface.Legend.HorizontalEdgePlacement = Legend.Placement.Inside; plotSurface.Legend.VerticalEdgePlacement = Legend.Placement.Inside; lineAvail.Label = "usage"; lineAvail.Pen = new Pen(Color.Crimson, 2.0f); lineUsage.Label = "avail"; lineUsage.Pen = new Pen(Color.SteelBlue, 2.0f); plotSurface.AddInteraction(new PlotSurface2D.Interactions.HorizontalDrag()); plotSurface.AddInteraction(new PlotSurface2D.Interactions.VerticalDrag()); plotSurface.AddInteraction(new PlotSurface2D.Interactions.AxisDrag(true)); plotSurface.PlotBackColor = Color.White; plotSurface.BackColor = SystemColors.Control; plotSurface.XAxis1.Color = Color.Black; plotSurface.YAxis1.Color = Color.Black; plotSurface.Refresh(); } catch (Exception ex) { MessageBox.Show("Couldnot initialize graph. Error: " + ex.Message, "Console Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public FinancialDemo() { // // Required for Windows Form Designer support // InitializeComponent(); costPS.Clear(); costPS.DateTimeToolTip = true; // obtain stock information from xml file DataSet ds = new DataSet(); System.IO.Stream file = Assembly.GetExecutingAssembly().GetManifestResourceStream("NPlotDemo.resources.asx_jbh.xml"); ds.ReadXml(file, System.Data.XmlReadMode.ReadSchema); DataTable dt = ds.Tables[0]; DataView dv = new DataView(dt); // create CandlePlot. CandlePlot cp = new CandlePlot(); cp.DataSource = dt; cp.AbscissaData = "Date"; cp.OpenData = "Open"; cp.LowData = "Low"; cp.HighData = "High"; cp.CloseData = "Close"; cp.BearishColor = Color.Red; cp.BullishColor = Color.Green; cp.Style = CandlePlot.Styles.Filled; costPS.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; costPS.Add(new Grid()); costPS.Add(cp); costPS.Title = "AU:JBH"; costPS.YAxis1.Label = "Price [$]"; costPS.YAxis1.LabelOffset = 40; costPS.YAxis1.LabelOffsetAbsolute = true; costPS.XAxis1.HideTickText = true; costPS.AddInteraction(new NPlot.Windows.PlotSurface2D.Interactions.HorizontalDrag()); costPS.AddInteraction(new NPlot.Windows.PlotSurface2D.Interactions.VerticalDrag()); costPS.AddInteraction(new NPlot.Windows.PlotSurface2D.Interactions.AxisDrag(false)); costPS.InteractionOccured += new NPlot.Windows.PlotSurface2D.InteractionHandler(costPS_InteractionOccured); costPS.AddAxesConstraint(new AxesConstraint.AxisPosition(PlotSurface2D.YAxisPosition.Left, 60)); PointPlot pp = new PointPlot(); pp.Marker = new Marker(Marker.MarkerType.Square, 0); pp.Marker.Pen = new Pen(Color.Red, 5.0f); pp.Marker.DropLine = true; pp.DataSource = dt; pp.AbscissaData = "Date"; pp.OrdinateData = "Volume"; volumePS.Add(pp); volumePS.YAxis1.Label = "Volume"; volumePS.YAxis1.LabelOffsetAbsolute = true; volumePS.YAxis1.LabelOffset = 40; volumePS.AddAxesConstraint(new AxesConstraint.AxisPosition(PlotSurface2D.YAxisPosition.Left, 60)); volumePS.AddInteraction(new NPlot.Windows.PlotSurface2D.Interactions.AxisDrag(false)); volumePS.AddInteraction(new NPlot.Windows.PlotSurface2D.Interactions.HorizontalDrag()); volumePS.InteractionOccured += new NPlot.Windows.PlotSurface2D.InteractionHandler(volumePS_InteractionOccured); volumePS.PreRefresh += new NPlot.Windows.PlotSurface2D.PreRefreshHandler(volumePS_PreRefresh); this.costPS.RightMenu = new ReducedContextMenu(); }
/////////K线图绘制////////// public void PlotCandle(CandlePlot cp, List <DateTime> dates, trader.KLine.TimeFrame timeframe) { try { myPlot.Clear(); // --- Grid Code --- Grid mygrid = new Grid(); mygrid.HorizontalGridType = Grid.GridType.Fine; mygrid.VerticalGridType = Grid.GridType.Fine; myPlot.Add(mygrid); cp.BullishColor = Color.Red; //cp.Color = Color.Black; cp.Centered = false; cp.BearishColor = Color.Green; cp.Style = CandlePlot.Styles.Filled; this.myPlot.Add(cp); //////这里需要先添加图形后设置坐标轴 /////字符坐标轴加入后会隐藏原来的x坐标轴 LabelAxis la1 = new LabelAxis(this.myPlot.XAxis1); for (int i = 0; i < dates.Count; i++) { switch (timeframe) { case trader.KLine.TimeFrame.M1: if (Math.IEEERemainder(i, 30) == 0) { la1.AddLabel(dates[i].ToShortTimeString() + @" " + dates[i].ToShortDateString(), i); } break; case trader.KLine.TimeFrame.M5: if (Math.IEEERemainder(i, 12) == 0) { la1.AddLabel(dates[i].ToShortTimeString() + @" " + dates[i].ToShortDateString(), i + 00); } break; default: if (Math.IEEERemainder(i, 5) == 0) { la1.AddLabel(dates[i].ToShortTimeString() + @" " + dates[i].ToShortDateString(), i + 00); } break; } } //la1.Label = "时间"; la1.TickTextFont = new Font("Courier New", 8); la1.TicksBetweenText = false; this.myPlot.XAxis1 = la1; //////让日期斜45度。 //myPlot.XAxis1.TicksLabelAngle = 45; myPlot.Refresh(); } catch (Exception e) { //Console.WriteLine("{0} Exception caught.", e); //MessageBox.Show(e.ToString()); } }
/// <summary> /// 利用雅虎接口获取日K线图 /// </summary> /// <param name="stockNo"></param> /// <returns></returns> public static void GetStockMapDay(string stockNo, NPlot.Windows.PlotSurface2D myPlot) { DataTable dt = CommonFunction.GetStockHistoryInfo(stockNo); for (int i = 0; i < dt.Rows.Count; i++) { if (int.Parse(dt.Rows[i]["Volume"].ToString()) == 0) { dt.Rows.RemoveAt(i); i = 0; } } dt.DefaultView.Sort = " Date asc"; dt = dt.DefaultView.ToTable(); dt.Columns.Add("Date2", typeof(DateTime)); foreach (DataRow dr in dt.Rows) { dr["Date2"] = DateTime.Parse(dr["Date"].ToString()); } myPlot.Clear(); List <double> listOpen = new List <double>(); List <double> listLow = new List <double>(); List <double> listHigh = new List <double>(); List <double> listClose = new List <double>(); ArrayList dates = new ArrayList(); ArrayList closes = new ArrayList(); List <string> listText = new List <string>(); List <int> listCount = new List <int>(); int n = 0; foreach (DataRow dr in dt.Rows) { n++; listCount.Add(n); //if (n == 24) break; listOpen.Add(double.Parse(dr["Open"].ToString())); dates.Add(DateTime.Parse(dr["Date"].ToString())); listHigh.Add(double.Parse(dr["High"].ToString())); listLow.Add(double.Parse(dr["Low"].ToString())); listClose.Add(double.Parse(dr["Adj Close"].ToString())); closes.Add(double.Parse(dr["Adj Close"].ToString())); listText.Add(Math.Round(double.Parse(dr["Adj Close"].ToString()), 2, MidpointRounding.AwayFromZero).ToString()); } ////////网格////////// Grid mygrid = new Grid(); myPlot.Add(mygrid); ///////蜡烛图/////////// CandlePlot cp = new CandlePlot(); cp.DataSource = dt; cp.AbscissaData = "Date2"; cp.OpenData = "Open"; cp.LowData = "Low"; cp.HighData = "High"; cp.CloseData = "Adj Close"; cp.BullishColor = Color.Red; cp.BearishColor = Color.Green; cp.Centered = false; //cp.StickWidth = 3; //cp.Color = Color.DarkBlue; myPlot.Add(cp); LabelPointPlot lp = new LabelPointPlot(); lp.AbscissaData = dates; lp.OrdinateData = listHigh.ToArray(); lp.TextData = listText.ToArray(); lp.LabelTextPosition = LabelPointPlot.LabelPositions.Above; lp.Marker = new Marker(Marker.MarkerType.None, 10); myPlot.Add(lp); myPlot.AddInteraction(new NPlot.Windows.PlotSurface2D.Interactions.MouseWheelZoom()); 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.Title = string.Format("Stcok {0}", stockNo); myPlot.XAxis1.Label = "Date / Time"; myPlot.YAxis1.Label = "Price [$]"; //myPlot.AddAxesConstraint(new AxesConstraint.AxisPosition(PlotSurface2D.XAxisPosition.Bottom, 100)); //////画箭头////////// //ArrowItem a = new ArrowItem(new PointD(2016, 10), 0, "Arrow"); //a.HeadOffset = 0; //a.ArrowColor = Color.Red; //a.TextColor = Color.Purple; //myPlot.Add(a); myPlot.Refresh(); }
private void PlotChart(QueryResultsEventArgs e, PlotSurface2D plot, List<KeyValuePair<int, Guid>> signals, bool cacheAxis) { if (cacheAxis) { double minX, maxX, minY, maxY; plot.Title = m_plotTitle; maxX = plot.XAxis1.WorldMax; minX = plot.XAxis1.WorldMin; maxY = plot.YAxis1.WorldMax; minY = plot.YAxis1.WorldMin; foreach (IDrawable drawing in plot.Drawables.ToArray()) plot.Remove(drawing, false); foreach (KeyValuePair<int, Guid> freq in signals) { SignalDataBase data = e.Results[freq.Value]; List<double> y = new List<double>(data.Count); List<double> x = new List<double>(data.Count); for (int i = 0; i < data.Count; i++) { ulong time; double value; data.GetData(i, out time, out value); x.Add(time); y.Add(value * m_scalingFactor); } LinePlot lines = new LinePlot(y, x); lines.Pen = m_colorWheel.TryGetPen(freq.Key); plot.Add(lines); } plot.XAxis1.WorldMax = maxX; plot.XAxis1.WorldMin = minX; plot.YAxis1.WorldMax = maxY; plot.YAxis1.WorldMin = minY; plot.Refresh(); } else { plot.Clear(); plot.Title = m_plotTitle; AddInteractions(); foreach (KeyValuePair<int, Guid> freq in signals) { SignalDataBase data = e.Results[freq.Value]; List<double> y = new List<double>(data.Count); List<double> x = new List<double>(data.Count); for (int i = 0; i < data.Count; i++) { ulong time; double value; data.GetData(i, out time, out value); x.Add(time); y.Add(value * m_scalingFactor); } LinePlot lines = new LinePlot(y, x); lines.Pen = m_colorWheel.TryGetPen(freq.Key); plot.Add(lines); } if (plot.XAxis1 != null) { plot.XAxis1.WorldMax = e.EndTime.Ticks; plot.XAxis1.WorldMin = e.StartTime.Ticks; } plot.Refresh(); } }