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 + 10; br.X = tl.X; br.Y = bounds.Bottom - 100; LinearAxis a = new LinearAxis (0, 10); a.Draw (ctx, tl, br, out boundingBox); a.Reversed = true; a.Draw (ctx, new Point (60,10), new Point (60, 200), out boundingBox); a.SmallTickSize = 0; a.Draw (ctx, new Point(90,10), new Point(90, 200), out boundingBox); a.LargeTickStep = 2.5; a.Draw (ctx, new Point(120,10), new Point(120,200), out boundingBox); a.NumberOfSmallTicks = 5; a.SmallTickSize = 2; a.Draw (ctx, new Point(150,10), new Point(150,200), out boundingBox); a.LineColor = Colors.DarkBlue; a.Draw (ctx, new Point(180,10), new Point(180,200), out boundingBox); a.TickTextColor= Colors.DarkBlue; a.Draw (ctx, new Point(210,10), new Point(210,200), out boundingBox); a.TickTextColor = Colors.Black; a.Draw (ctx, new Point(240,10), new Point(300,200), out boundingBox); a.WorldMax = 100000; a.WorldMin = -3; a.LargeTickStep = double.NaN; a.Draw (ctx, new Point(330,10), new Point(330,200), out boundingBox); a.NumberFormat = "{0:0.0E+0}"; a.Draw (ctx, new Point(380,10), new Point(380,200), out boundingBox); // Test for default TicksAngle (+90) on positive X-axis, ie Ticks below X-axis LinearAxis aX = new LinearAxis (0, 10); tl.X = bounds.Left + 30; tl.Y = bounds.Bottom - 60; br.X = bounds.Right - 20; br.Y = bounds.Bottom - 60; aX.Draw (ctx, tl, br, out boundingBox); // Set TicksAngle to -45 anti-clockwise from positive X-axis direction aX.TicksAngle = Math.PI / 4.0; tl.Y += 50; br.Y += 50; aX.Draw (ctx, tl, br, out boundingBox); }
/// <summary> /// Helper method for Clone. /// </summary> protected void DoClone( LinearAxis b, LinearAxis a ) { Axis.DoClone( b, a ); a.numberSmallTicks_ = b.numberSmallTicks_; a.largeTickValue_ = b.largeTickValue_; a.largeTickStep_ = b.largeTickStep_; a.offset_ = b.offset_; a.scale_ = b.scale_; }
/// <summary> /// Deep copy of LinearAxis. /// </summary> /// <returns>A copy of the LinearAxis Class</returns> public override object Clone() { LinearAxis a = new LinearAxis(); // 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!" ); } this.DoClone( this, a ); return a; }
public PlotWavelet() { infoText = ""; infoText += "Wavelet Example. Demonstrates - \n"; infoText += " * Reversing axes, setting number of tick marks on axis explicitly."; plotSurface.Clear(); // Create a new line plot from array data via the ArrayAdapter class. LinePlot lp = new LinePlot(); lp.DataSource = makeDaub(256); lp.Color = Color.Green; lp.Label = "Daubechies Wavelet"; // no legend, but still useful for copy data to clipboard. Grid myGrid = new Grid(); myGrid.VerticalGridType = Grid.GridType.Fine; myGrid.HorizontalGridType = Grid.GridType.Coarse; plotSurface.Add(myGrid); // And add it to the plot surface plotSurface.Add( lp ); plotSurface.Title = "Reversed / Upside down Daubechies Wavelet"; // Ok, the above will produce a decent default plot, but we would like to change // some of the Y Axis details. First, we'd like lots of small ticks (10) between // large tick values. Secondly, we'd like to draw a grid for the Y values. To do // this, we create a new LinearAxis (we could also use Label, Log etc). Rather than // starting from scratch, we use the constructor that takes an existing axis and // clones it (values in the superclass Axis only are cloned). PlotSurface2D // automatically determines a suitable axis when we add plots to it (merging // current requirements with old requirements), and we use this as our starting // point. Because we didn't specify which Y Axis we are using when we added the // above line plot (there is one on the left - YAxis1 and one on the right - YAxis2) // PlotSurface2D.Add assumed we were using YAxis1. So, we create a new axis based on // YAxis1, update the details we want, then set the YAxis1 to be our updated one. LinearAxis myAxis = new LinearAxis( plotSurface.YAxis1 ); myAxis.NumberOfSmallTicks = 2; plotSurface.YAxis1 = myAxis; // We would also like to modify the way in which the X Axis is printed. This time, // we'll just modify the relevant PlotSurface2D Axis directly. plotSurface.XAxis1.WorldMax = 100.0f; plotSurface.PlotBackColor = Color.OldLace; plotSurface.XAxis1.Reversed = true; plotSurface.YAxis1.Reversed = true; // Force a re-draw of the control. plotSurface.Refresh(); }
public PlotLogLin() { infoText = ""; infoText += "LogLin Example. Demonstrates - \n"; infoText += " * How to chart data against log axes and linear axes at the same time."; plotSurface.Clear(); // draw a fine grid. Grid fineGrid = new Grid(); fineGrid.VerticalGridType = Grid.GridType.Fine; fineGrid.HorizontalGridType = Grid.GridType.Fine; plotSurface.Add( fineGrid ); const int npt = 101; float[] x = new float[npt]; float[] y = new float[npt]; float step = 0.1f; for (int i=0; i<npt; ++i) { x[i] = i*step - 5.0f; y[i] = (float)Math.Pow( 10.0, x[i] ); } float xmin = x[0]; float xmax = x[npt-1]; float ymin = (float)Math.Pow( 10.0, xmin ); float ymax = (float)Math.Pow( 10.0, xmax ); LinePlot lp = new LinePlot(); lp.OrdinateData = y; lp.AbscissaData = x; lp.Pen = new Pen( Color.Red ); plotSurface.Add( lp ); LogAxis loga = new LogAxis( plotSurface.YAxis1 ); loga.WorldMin = ymin; loga.WorldMax = ymax; loga.AxisColor = Color.Red; loga.LabelColor = Color.Red; loga.TickTextColor = Color.Red; loga.LargeTickStep = 1.0f; loga.Label = "10^x"; plotSurface.YAxis1 = loga; LinePlot lp1 = new LinePlot(); lp1.OrdinateData = y; lp1.AbscissaData = x; lp1.Pen = new Pen( Color.Blue ); plotSurface.Add( lp1, XAxisPosition.Bottom, YAxisPosition.Right ); LinearAxis lin = new LinearAxis( plotSurface.YAxis2 ); lin.WorldMin = ymin; lin.WorldMax = ymax; lin.AxisColor = Color.Blue; lin.LabelColor = Color.Blue; lin.TickTextColor = Color.Blue; lin.Label = "10^x"; plotSurface.YAxis2 = lin; LinearAxis lx = (LinearAxis)plotSurface.XAxis1; lx.WorldMin = xmin; lx.WorldMax = xmax; lx.Label = "x"; //((LogAxis)plotSurface.YAxis1).LargeTickStep = 2; plotSurface.Title = "Mixed Linear/Log Axes"; //plotSurface.XAxis1.LabelOffset = 20.0f; plotSurface.Refresh(); }
/// <summary> /// Returns a y-axis that is suitable for drawing the data. /// </summary> /// <returns>A suitable y-axis.</returns> public Axis SuggestYAxis() { double min_l; double max_l; double min_h; double max_h; if (this.rows_ == null) { Utils.ArrayMinMax((System.Collections.IList)lowData_, out min_l, out max_l); Utils.ArrayMinMax((System.Collections.IList)highData_, out min_h, out max_h); } else { Utils.RowArrayMinMax(this.rows_, out min_l, out max_l, (string)this.lowData_); Utils.RowArrayMinMax(this.rows_, out min_h, out max_h, (string)this.highData_); } Axis a = new LinearAxis( min_l, max_h ); a.IncreaseRange( 0.08 ); return a; }
/// <summary> /// Returns a y-axis that is suitable for drawing this plot. /// </summary> /// <returns>A suitable y-axis.</returns> public Axis SuggestYAxis() { if ( this.isStacked_ ) { double tmpMax = 0.0f; ArrayList adapterList = new ArrayList(); HistogramPlot currentPlot = this; do { adapterList.Add( new SequenceAdapter( currentPlot.DataSource, currentPlot.DataMember, currentPlot.OrdinateData, currentPlot.AbscissaData ) ); } while ((currentPlot = currentPlot.stackedTo_) != null); SequenceAdapter[] adapters = (SequenceAdapter[])adapterList.ToArray(typeof(SequenceAdapter)); for (int i=0; i<adapters[0].Count; ++i) { double tmpHeight = 0.0f; for (int j=0; j<adapters.Length; ++j) { tmpHeight += adapters[j][i].Y; } tmpMax = Math.Max(tmpMax, tmpHeight); } Axis a = new LinearAxis(0.0f,tmpMax); // TODO make 0.08 a parameter. a.IncreaseRange( 0.08 ); return a; } else { SequenceAdapter data = new SequenceAdapter( this.DataSource, this.DataMember, this.OrdinateData, this.AbscissaData ); return data.SuggestYAxis(); } }
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>(); }
private void Tests_Paint(object sender, PaintEventArgs e) { System.Drawing.Rectangle boundingBox; NPlot.LinearAxis a = new LinearAxis(0, 10); a.Draw( e.Graphics, new Point(10,10), new Point(10, 200), out boundingBox ); a.Reversed = true; a.Draw( e.Graphics, new Point(40,10), new Point(40, 200), out boundingBox ); a.SmallTickSize = 0; a.Draw( e.Graphics, new Point(70,10), new Point(70, 200), out boundingBox ); a.LargeTickStep = 2.5; a.Draw( e.Graphics, new Point(100,10), new Point(100,200), out boundingBox ); a.NumberOfSmallTicks = 5; a.SmallTickSize = 2; a.Draw( e.Graphics, new Point(130,10), new Point(130,200), out boundingBox ); a.AxisColor = Color.Cyan; a.Draw( e.Graphics, new Point(160,10), new Point(160,200), out boundingBox ); a.TickTextColor= Color.Cyan; a.Draw( e.Graphics, new Point(190,10), new Point(190,200), out boundingBox ); a.TickTextBrush = Brushes.Black; a.AxisPen = Pens.Black; a.Draw( e.Graphics, new Point(220,10), new Point(280,200), out boundingBox ); a.WorldMax = 100000; a.WorldMin = -3; a.LargeTickStep = double.NaN; a.Draw( e.Graphics, new Point(310,10), new Point(310,200), out boundingBox ); a.NumberFormat = "{0:0.0E+0}"; a.Draw( e.Graphics, new Point(360,10), new Point(360,200), 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 Draw() { this.plot.Clear(); Grid testGrid = new Grid(); testGrid.VerticalGridType = Grid.GridType.Coarse; testGrid.HorizontalGridType = Grid.GridType.Coarse; testGrid.MajorGridPen = new Pen(Color.LightGray, 1f); this.plot.Add(testGrid); int tickstep = 1; int xmax = ((long[])splits[winner]).Length / nsplits; if (xmax <= 30) tickstep = 1; else if (xmax > 30 && xmax <= 60) tickstep = 2; else if (xmax > 60) tickstep = 3; LinearAxis lx1 = new LinearAxis(); lx1.NumberOfSmallTicks = 0; lx1.LargeTickStep = tickstep; lx1.HideTickText = true; lx1.WorldMin = 1; lx1.WorldMax = xmax; this.plot.XAxis1 = lx1; LinearAxis lx2 = new LinearAxis(lx1); lx2.Label = Settings.RaceProgressGraphXAxisLabel; lx2.NumberOfSmallTicks = 0; lx2.LargeTickStep = tickstep; lx2.WorldMin = 1; lx2.WorldMax = xmax; lx2.HideTickText = false; lx2.LabelFont = Settings.commonFont; this.plot.XAxis2 = lx2; LinearAxis ly1 = new LinearAxis(); ly1.NumberOfSmallTicks = 0; ly1.Reversed = true; ly1.LargeTickStep = 10; ly1.WorldMin = -5; ly1.WorldMax = 5; ly1.LabelFont = Settings.commonFont; ly1.HideTickText = true; this.plot.YAxis1 = ly1; this.plot.Title = Settings.RaceProgressGraphTitle; this.plot.TitleFont = Settings.titleFont; Legend lg = new Legend(); lg.Font = Settings.commonFont; lg.BorderStyle = Settings.legendBorderType; lg.XOffset = 60; this.plot.Legend = lg; this.plot.PlotBackColor = Color.White; this.plot.BackColor = Color.White; this.plot.Add(new HorizontalLine(0.0, Color.Black)); for (int p = 0; p < players.Count; ++p) if (((long[])splits[p]).Length >= nsplits) { double[] x = new double[((long[])splits[p]).Length - nsplits + 2]; double[] y = new double[((long[])splits[p]).Length - nsplits + 2]; x[0] = 1; y[0] = 0; int l = 1; int i = 0; int split = 0; double lap; while (i < ((long[])splits[p]).Length - nsplits + 1) { double prop = 0; for (int pr = 0; pr < split; ++pr) prop += winner_avgsplitsproportions[pr + 1]; lap = (double)l + prop; x[i + 1] = lap; long splitsum = 0; for (int sps = 0; sps <= split; ++sps) splitsum += winner_avgsplits[sps]; long real = ((long[])splits[p])[i + nsplits - 1]; long avg = (winner_avgtime * (l) + splitsum); long difference = real - avg; y[i + 1] = difference; y[i + 1] /= 10000; if (y[i + 1] > Settings.graphMinMax) y[i + 1] = Settings.graphMinMax; ++split; if (split == nsplits) { split = 0; ++l; } ++i; } LinePlot lp = new LinePlot(); lp.AbscissaData = x; lp.OrdinateData = y; lp.Pen = new Pen(Colors.GetColor(p), 1f); lp.Label = String.Format("{0}", players[p].ToString()); this.plot.Add(lp); LinearAxis ly2 = new LinearAxis(plot.YAxis1); ly2.Label = ""; ly2.Label = Settings.RaceProgressGraphYAxisLabel; ly2.NumberOfSmallTicks = ly1.NumberOfSmallTicks; ly2.LargeTickStep = ly1.LargeTickStep; ly2.TickTextNextToAxis = false; ly2.LabelFont = Settings.commonFont; ly2.HideTickText = false; this.plot.YAxis2 = ly2; if (this.plot.YAxis1.WorldMin < 400) { } this.plot.Refresh(); } }
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; }
/// <summary> /// Helper method for Clone. /// </summary> protected void DoClone(LinearAxis src, LinearAxis dest) { Axis.DoClone (src, dest); dest.numberSmallTicks_ = src.numberSmallTicks_; dest.largeTickValue_ = src.largeTickValue_; dest.largeTickStep_ = src.largeTickStep_; dest.offset_ = src.offset_; dest.scale_ = src.scale_; }
public void Draw() { this.plot.Clear(); Grid testGrid = new Grid(); testGrid.VerticalGridType = Grid.GridType.Coarse; testGrid.HorizontalGridType = Grid.GridType.Coarse; testGrid.MajorGridPen = new Pen(Color.LightGray, 1f); this.plot.Add(testGrid); xmax = ((long[])splits[winner]).Length / nsplits; int tickstep = 1; if (xmax <= 30) tickstep = 1; else if (xmax > 30 && xmax <= 60) tickstep = 2; else if (xmax > 60) tickstep = 3; LinearAxis lx1 = new LinearAxis(); /* if (tickstep > 1) lx1.NumberOfSmallTicks = 0; else lx1.NumberOfSmallTicks = nsplits -1; */ lx1.NumberOfSmallTicks = 0; lx1.LargeTickStep = tickstep; lx1.HideTickText = true; lx1.WorldMin = 0; lx1.WorldMax = xmax; lx1.TicksCrossAxis = true; this.plot.XAxis1 = lx1; LinearAxis lx2 = new LinearAxis(this.plot.XAxis1); lx2.Label = Settings.LapByLapGraphXAxisLabel; lx2.NumberOfSmallTicks = 0; lx2.LargeTickStep = tickstep; lx2.WorldMin = 0; lx2.WorldMax = xmax; lx2.HideTickText = false; lx2.LabelFont = Settings.commonFont; this.plot.XAxis2 = lx2; this.plot.XAxis1.LargeTickSize = 0; LinearAxis ly1 = new LinearAxis(); ly1.Label = Settings.LapByLapGraphYAxisLabel; ly1.NumberOfSmallTicks = 0; ly1.Reversed = true; ly1.LargeTickStep = 1; ly1.WorldMin = 0.5f; ly1.WorldMax = players.Count + 0.5f; ly1.LabelFont = Settings.commonFont; ly1.TicksCrossAxis = true; this.plot.YAxis1 = ly1; LinearAxis ly2 = new LinearAxis(); ly2.NumberOfSmallTicks = 0; ly2.Reversed = true; ly2.LargeTickStep = 1; ly2.WorldMin = 0.5f; ly2.WorldMax = players.Count + 0.5f; ly2.LabelFont = Settings.commonFont; ly2.TickTextNextToAxis = false; ly2.Label = ""; ly2.TicksCrossAxis = true; this.plot.YAxis2 = ly2; this.plot.Title = Settings.LapByLapGraphTitle; this.plot.TitleFont = Settings.titleFont; Legend lg = new Legend(); lg.Font = Settings.commonFont; lg.XOffset = 30; lg.BorderStyle = Settings.legendBorderType; this.plot.Legend = lg; this.plot.PlotBackColor = Color.White; this.plot.BackColor = Color.White; // double minx = 0; for (int i = 0; i < players.Count; ++i) // for (int i=winner; i<= winner; ++i) { int[] positions = new int[((long[])splits[i]).Length]; double[] laps = new double[((long[])splits[i]).Length]; int splitN = 0; int l = 0; for (int split = 0; split < ((long[])splits[winner]).Length; ++split) { if (split < positions.Length) { double prop = 0; for (int pr = 0; pr < splitN; ++pr) prop += winner_avgsplitsproportions[pr + 1]; laps[split] = (double)l + prop; } int pos = 1; for (int p = 0; p < players.Count; ++p) if (p != i && ((long[])(splits[i])).Length > split && ((long[])(splits[p])).Length > split && ((long[])(splits[p]))[split] < ((long[])(splits[i]))[split]) ++pos; if (split < positions.Length) positions[split] = pos; ++splitN; if (splitN == nsplits) { splitN = 0; ++l; } } LinePlot lp = new LinePlot(); // lp.DataSource = positions; lp.AbscissaData = laps; lp.OrdinateData = positions; lp.Pen = new Pen(Colors.GetColor(i), 2.0f); int start = i + 1; int end = start; if (positions.Length - 1 >= 0) end = positions[positions.Length - 1]; if (Settings.LapByLapGraphDisplayPositions) lp.Label = String.Format("{0:00}-{1:00} {2:g}", start, end, players[i].ToString()); else lp.Label = String.Format("{0:g}", players[i].ToString()); this.plot.Add(lp); this.plot.YAxis1.WorldMin = 0; this.plot.YAxis2.WorldMin = 0; /* Marker mk = new Marker(); mk.Color = System.Drawing.Color.Red; // mk.Type = Marker.MarkerType.FlagUp; mk.Type = Marker.MarkerType.FlagUp; mk.Size = 15; int[] abs = {1,2,3,4,5,6,7,8,9,10}; int[] ord = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; abs.Add PointPlot pp = new PointPlot(mk); pp.ShowInLegend = false; pp.AbscissaData = abs; pp.OrdinateData = ord; this.plot.Add(pp); */ this.plot.XAxis1.WorldMax = xmax; this.plot.XAxis2.WorldMax = xmax; } this.plot.YAxis1.WorldMax = players.Count + 0.5f; lx1.WorldMin = 0; lx1.WorldMax = xmax; lx2.WorldMin = 0; lx2.WorldMax = xmax; this.plot.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; } } } }