/// <summary> /// Deep copy of DateTimeAxis. /// </summary> /// <returns>A copy of the DateTimeAxis Class.</returns> public override object Clone() { DateTimeAxis a = new DateTimeAxis(); // ensure that this isn't being called on a derived type. If it is, then oh no! if (this.GetType() != a.GetType()) { throw new NPlotException( "Clone not defined in derived type. Help!" ); } DoClone( this, a ); return a; }
/// <summary> /// Helper method for Clone. /// </summary> /// <param name="a">The original object to clone.</param> /// <param name="b">The cloned object.</param> protected static void DoClone(DateTimeAxis b, DateTimeAxis a) { Axis.DoClone (b, a); }
/// <summary> /// When the volumePS chart has changed, this is called which updates the costPS chart. /// </summary> private void volumePS_InteractionOccurred(object sender) { DateTimeAxis axis = new DateTimeAxis(volumePS.XAxis1); axis.Label = ""; axis.HideTickText = true; this.costPS.XAxis1 = axis; this.costPS.Refresh(); }
/// <summary> /// When the costPS chart has changed, this is called which updates the volumePS chart. /// </summary> /// <param name="sender"></param> private void costPS_InteractionOccurred(object sender) { DateTimeAxis axis = new DateTimeAxis(costPS.XAxis1); axis.Label = "Date / Time"; axis.HideTickText = false; this.volumePS.XAxis1 = axis; this.volumePS.Refresh(); }
private void RefreshRetrievePlot() { _retrieveSpeedPlot.Clear(); PointPlot plot = new PointPlot(); List<DateTime> timePoints; List<double> retrieveMbPerSecond; ComputePlotAverage(out timePoints, out retrieveMbPerSecond); plot.AbscissaData = timePoints; plot.DataSource = retrieveMbPerSecond; Grid grid = new Grid(); grid.HorizontalGridType = Grid.GridType.Coarse; grid.VerticalGridType = Grid.GridType.Coarse; _retrieveSpeedPlot.Add(grid); _retrieveSpeedPlot.Add(plot); _retrieveSpeedPlot.ShowCoordinates = true; _retrieveSpeedPlot.YAxis1.Label = "Mb/sec"; _retrieveSpeedPlot.YAxis1.LabelOffsetAbsolute = true; _retrieveSpeedPlot.YAxis1.LabelOffset = 40; _retrieveSpeedPlot.Padding = 5; //Align percent plot axes. DateTimeAxis ax = new DateTimeAxis(_retrieveSpeedPlot.XAxis1); ax.HideTickText = false; _retrieveSpeedPlot.XAxis1 = ax; _retrieveSpeedPlot.Refresh(); }
private void UpdateAxes(bool recalculateAll) { int position = 0; // if we're not recalculating axes using all iplots then set // position to last one in list. if (!recalculateAll) { position = m_drawables.Count - 1; if (position < 0) position = 0; } if (recalculateAll) { m_xAxis1 = null; m_yAxis1 = null; m_xAxis2 = null; m_yAxis2 = null; } for (int i = position; i < m_drawables.Count; ++i) { // only update axes if this drawable is an IPlot. if (!(m_drawables[i] is IPlot)) continue; IPlot p = (IPlot)m_drawables[i]; if (m_xAxis1 == null) { m_xAxis1 = p.SuggestXAxis(); if (m_xAxis1 != null) { m_xAxis1.TicksAngle = -(float)Math.PI / 2.0f; } } else { m_xAxis1.LUB(p.SuggestXAxis()); } if (m_xAxis1 != null) { m_xAxis1.MinPhysicalLargeTickStep = 50; if (AutoScaleAutoGeneratedAxes) { m_xAxis1.AutoScaleText = true; m_xAxis1.AutoScaleTicks = true; m_xAxis1.TicksIndependentOfPhysicalExtent = true; } else { m_xAxis1.AutoScaleText = false; m_xAxis1.AutoScaleTicks = false; m_xAxis1.TicksIndependentOfPhysicalExtent = false; } } if (m_yAxis1 == null) { m_yAxis1 = p.SuggestYAxis(); if (m_yAxis1 != null) { m_yAxis1.TicksAngle = (float)Math.PI / 2.0f; } } else { m_yAxis1.LUB(p.SuggestYAxis()); } if (m_yAxis1 != null) { if (AutoScaleAutoGeneratedAxes) { m_yAxis1.AutoScaleText = true; m_yAxis1.AutoScaleTicks = true; m_yAxis1.TicksIndependentOfPhysicalExtent = true; } else { m_yAxis1.AutoScaleText = false; m_yAxis1.AutoScaleTicks = false; m_yAxis1.TicksIndependentOfPhysicalExtent = false; } } } }
private void Init() { m_drawables = new List<IDrawable>(); m_zPositions = new List<double>(); m_ordering = new SortedList<double, int>(); FontFamily fontFamily = new FontFamily("Arial"); TitleFont = new Font(fontFamily, 14, FontStyle.Regular, GraphicsUnit.Pixel); m_padding = 10; m_title = ""; m_autoScaleTitle = false; m_autoScaleAutoGeneratedAxes = false; m_xAxis1 = null; m_xAxis2 = null; m_yAxis1 = null; m_yAxis2 = null; m_pXAxis1Cache = null; m_pYAxis1Cache = null; m_pXAxis2Cache = null; m_pYAxis2Cache = null; m_titleBrush = new SolidBrush(Color.Black); m_plotBackColor = Color.White; m_smoothingMode = SmoothingMode.None; m_axesConstraints = new List<AxesConstraint>(); }
/// <summary> /// Helper method for Clone. /// </summary> /// <param name="a">The original object to clone.</param> /// <param name="b">The cloned object.</param> protected static void DoClone(DateTimeAxis b, DateTimeAxis a) { Axis.DoClone(b, a); }
private void DrawAxisTests(Context ctx, Rectangle bounds) { Rectangle boundingBox; Point tl = Point.Zero; Point br = Point.Zero;; tl.X = bounds.Left + 30; tl.Y = bounds.Top + 20; br.X = bounds.Right - 30; br.Y = bounds.Top + 20; DateTime timeMin = new DateTime (2013, 1, 1, 12, 30, 0); DateTime timeMax = new DateTime (2013, 2, 2, 12, 30, 0); DateTimeAxis dta = new DateTimeAxis (timeMin, timeMax); dta.Draw (ctx, tl, br, out boundingBox); timeMin = new DateTime (2013, 1, 1, 12, 30, 0); timeMax = new DateTime (2013, 1, 1, 12, 59, 30); dta.WorldMin = (double)timeMin.Ticks; dta.WorldMax = (double)timeMax.Ticks; tl.Y += 50; br.Y += 50; dta.Draw (ctx, tl, br, out boundingBox); }
// // The actual Axis tests // private void DrawAxisTests(Graphics g, Rectangle bounds ) { Rectangle boundingBox; Point tl = Point.Empty; Point br = Point.Empty; tl.X = bounds.Left + 20; tl.Y = bounds.Top + 10; br.X = bounds.Left + 20; br.Y = bounds.Bottom - 50; NPlot.LinearAxis a = new LinearAxis (0, 10); a.Draw (g, tl, br, out boundingBox ); a.Reversed = true; tl.X += 30; br.X += 30; a.Draw (g, tl, br, out boundingBox ); a.SmallTickSize = 0; a.Draw (g, new Point(90,10), new Point(90, 200), out boundingBox ); a.LargeTickStep = 2.5; a.Draw( g, new Point(120,10), new Point(120,200), out boundingBox ); a.NumberOfSmallTicks = 5; a.SmallTickSize = 2; a.Draw( g, new Point(150,10), new Point(150,200), out boundingBox ); a.AxisColor = Color.Cyan; a.Draw( g, new Point(180,10), new Point(180,200), out boundingBox ); a.TickTextColor= Color.Cyan; a.Draw( g, new Point(210,10), new Point(210,200), out boundingBox ); a.TickTextBrush = Brushes.Black; a.AxisPen = Pens.Black; a.Draw( g, new Point(240,10), new Point(300,200), out boundingBox ); a.WorldMax = 100000; a.WorldMin = -3; a.LargeTickStep = double.NaN; a.Draw( g, new Point(330,10), new Point(330,200), out boundingBox ); a.NumberFormat = "{0:0.0E+0}"; a.Draw( g, new Point(380,10), new Point(380,200), out boundingBox ); // Test for default TicksAngle on positive X-axis, ie Ticks below X-axis NPlot.LinearAxis aX = new LinearAxis(0, 10); tl.X = bounds.Left + 90; tl.Y = bounds.Bottom - 150; br.X = bounds.Right - 30; br.Y = bounds.Bottom - 150; aX.Draw (g, tl, br, out boundingBox ); // Set TicksAngle to PI/4 anti-clockwise from positive X-axis direction aX.TicksAngle = (float)Math.PI / 4.0f; tl.Y += 40; br.Y += 40; aX.Draw (g, tl, br, out boundingBox ); DateTime timeMin = new DateTime (2013, 1, 1, 12, 30, 0); DateTime timeMax = new DateTime (2013, 2, 2, 12, 30, 0); DateTimeAxis dta = new DateTimeAxis (timeMin, timeMax); tl.Y += 30; br.Y += 30; dta.Draw (g, tl, br, out boundingBox); timeMin = new DateTime (2013, 1, 1, 12, 30, 0); timeMax = new DateTime (2013, 1, 1, 12, 59, 30); dta.WorldMin = (double)timeMin.Ticks; dta.WorldMax = (double)timeMax.Ticks; tl.Y += 30; br.Y += 30; dta.Draw (g, tl, br, out boundingBox); }
public void plot_nplot(out NPlot.Gtk.PlotSurface2D graph ) { DateTime dt = DateTime.Now; int __width_factor = 45; int __graph_width = _c_device_logfile_entries.Count * __width_factor; NPlot.Gtk.PlotSurface2D _graph = new NPlot.Gtk.PlotSurface2D (); _graph.SetSizeRequest ( __graph_width, 500); _graph.ModifyBg (StateType.Normal, cutil.get_light_grey()); Bitmap _graphBitmap = new Bitmap (1000, 500); DateTimeAxis x = new DateTimeAxis (); LinearAxis y = new LinearAxis (-50, 0); x.SmallTickSize = 10; x.LargeTickStep = new TimeSpan (0, 30, 0); x.NumberFormat = "hh:mm"; _graph.PlotBackImage = _graphBitmap; _graph.YAxis1 = y; _graph.XAxis1 = x; _graph.XAxis1.Label = _XAxisLabel; _graph.XAxis1.AutoScaleTicks = false; _graph.YAxis1.Label = _YAxisLabel; _linePlot.AbscissaData = _ar_x_axis_data; _linePlot.OrdinateData = _ar_y_axis_data; _linePlot.Label = _title; _linePlot.ShowInLegend = true; _linePlot.Pen.Width = 2.5f; _linePlot.Color = Color.Orange; _linePlotLegend.AttachTo ( NPlot.PlotSurface2D.XAxisPosition.Top, NPlot.PlotSurface2D.YAxisPosition.Left); _linePlotLegend.VerticalEdgePlacement = NPlot.Legend.Placement.Inside; _linePlotLegend.HorizontalEdgePlacement = NPlot.Legend.Placement.Outside; _linePlotLegend.BorderStyle = LegendBase.BorderType.Shadow; _linePlotLegend.YOffset = -10; _linePlotLegend.XOffset = -5; _graph.Legend = _linePlotLegend; _graph.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; NPlot.Grid grid = new Grid (); grid.HorizontalGridType = Grid.GridType.Fine; grid.VerticalGridType = Grid.GridType.Fine; _graph.Add (grid, NPlot.PlotSurface2D.XAxisPosition.Bottom, NPlot.PlotSurface2D.YAxisPosition.Left); _graph.Add (_linePlot); _graph.QueueDraw (); graph = _graph; }
private void UpdateAxes(bool recalculateAll) { int position = 0; // if we're not recalculating axes using all iplots then set // position to last one in list. if (!recalculateAll) { position = m_drawables.Count - 1; if (position < 0) { position = 0; } } if (recalculateAll) { m_xAxis1 = null; m_yAxis1 = null; m_xAxis2 = null; m_yAxis2 = null; } for (int i = position; i < m_drawables.Count; ++i) { // only update axes if this drawable is an IPlot. if (!(m_drawables[i] is IPlot)) { continue; } IPlot p = (IPlot)m_drawables[i]; if (m_xAxis1 == null) { m_xAxis1 = p.SuggestXAxis(); if (m_xAxis1 != null) { m_xAxis1.TicksAngle = -(float)Math.PI / 2.0f; } } else { m_xAxis1.LUB(p.SuggestXAxis()); } if (m_xAxis1 != null) { m_xAxis1.MinPhysicalLargeTickStep = 50; if (AutoScaleAutoGeneratedAxes) { m_xAxis1.AutoScaleText = true; m_xAxis1.AutoScaleTicks = true; m_xAxis1.TicksIndependentOfPhysicalExtent = true; } else { m_xAxis1.AutoScaleText = false; m_xAxis1.AutoScaleTicks = false; m_xAxis1.TicksIndependentOfPhysicalExtent = false; } } if (m_yAxis1 == null) { m_yAxis1 = p.SuggestYAxis(); if (m_yAxis1 != null) { m_yAxis1.TicksAngle = (float)Math.PI / 2.0f; } } else { m_yAxis1.LUB(p.SuggestYAxis()); } if (m_yAxis1 != null) { if (AutoScaleAutoGeneratedAxes) { m_yAxis1.AutoScaleText = true; m_yAxis1.AutoScaleTicks = true; m_yAxis1.TicksIndependentOfPhysicalExtent = true; } else { m_yAxis1.AutoScaleText = false; m_yAxis1.AutoScaleTicks = false; m_yAxis1.TicksIndependentOfPhysicalExtent = false; } } } }