private void TrackPartitionControl_Load(object sender, EventArgs e) { _labelDescription.Text = string.Format("From: {0:00} To: {1:00} Count: {2} ", _partition.MinFigure, _partition.MaxFigure, _partition.TotalNumberOfFigures); _graph.Clear(); var sp = new LinePlot(); // var sp = new BarPlot(); DataSet ds = _partition.CreateFrequenciesDataSet(); sp.DataSource = ds; sp.AbscissaData = "Track"; sp.OrdinateData = "Frequency"; sp.Color = Color.Red; sp.Label = "Signal Frequency"; _graph.Add(sp); var la = new LabelAxis(_graph.XAxis1); foreach (DataRow row in ds.Tables[0].Rows) { la.AddLabel((string)row["TrackName"], (double)row["Track"]); } la.TicksLabelAngle = (float)90.0f; la.TicksBetweenText = true; _graph.XAxis1 = la; _graph.Invalidate(); }
/// <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(LabelAxis b, LabelAxis a) { Axis.DoClone(b, a); a.labels_ = new List <string>(b.labels_); a.numbers_ = new List <double>(b.numbers_); a.TicksBetweenText = b.TicksBetweenText; a.SortDataIfNecessary = b.SortDataIfNecessary; }
/// <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(LabelAxis b, LabelAxis a) { Axis.DoClone(b, a); a.labels_ = (ArrayList)b.labels_.Clone(); a.numbers_ = (ArrayList)b.numbers_.Clone(); a.ticksBetweenText_ = b.ticksBetweenText_; a.sortDataIfNecessary_ = b.sortDataIfNecessary_; }
/// <summary> /// Deep copy of LabelAxis. /// </summary> /// <returns>A copy of the LinearAxis Class.</returns> public override object Clone() { LabelAxis a = new LabelAxis(); // 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( "Error. Clone method is not defined in derived type." ); } DoClone( this, a ); return a; }
/// <summary> /// Deep copy of LabelAxis. /// </summary> /// <returns>A copy of the LinearAxis Class.</returns> public override object Clone() { LabelAxis a = new LabelAxis(); // ensure that this isn't being called on a derived type. If it is, then oh no! if (GetType() != a.GetType()) { throw new NPlotException("Error. Clone method is not defined in derived type."); } DoClone(this, a); return(a); }
public PlotQE() { infoText = ""; infoText += "Cs2Te Photocathode QE evolution Example. Demonstrates - \n"; infoText += " * LabelPointPlot (allows text to be associated with points) \n"; infoText += " * PointPlot droplines \n"; infoText += " * LabelAxis \n"; infoText += " * PhysicalSpacingMin property of LabelAxis \n"; infoText += "You cannot interact with this chart"; qeExampleTimerEnabled = true; plotSurface.Clear(); int len = 24; string[] s = new string[len]; PlotQEExampleValues = new double[len]; PlotQEExampleTextValues = new string[len]; Random r = new Random(); for (int i=0; i<len;i++) { PlotQEExampleValues[i] = 8.0f + 12.0f * (double)r.Next(10000) / 10000.0f; if (PlotQEExampleValues[i] > 18.0f) { PlotQEExampleTextValues[i] = "KCsTe"; } else { PlotQEExampleTextValues[i] = ""; } s[i] = i.ToString("00") + ".1"; } PointPlot pp = new PointPlot(); pp.DataSource = PlotQEExampleValues; pp.Marker = new Marker( Marker.MarkerType.Square, 10 ); pp.Marker.DropLine = true; pp.Marker.Pen = Pens.CornflowerBlue; pp.Marker.Filled = false; plotSurface.Add( pp ); LabelPointPlot tp1 = new LabelPointPlot(); tp1.DataSource = PlotQEExampleValues; tp1.TextData = PlotQEExampleTextValues; tp1.LabelTextPosition = LabelPointPlot.LabelPositions.Above; tp1.Marker = new Marker( Marker.MarkerType.None, 10 ); plotSurface.Add( tp1 ); LabelAxis la = new LabelAxis( plotSurface.XAxis1 ); for (int i=0; i<len; ++i) { la.AddLabel( s[i], i ); } FontFamily ff = new FontFamily( "Verdana" ); la.TickTextFont = new Font( ff, 7 ); la.PhysicalSpacingMin = 25; plotSurface.XAxis1 = la; plotSurface.Title = "Cs2Te Photocathode QE evolution"; plotSurface.TitleFont = new Font(ff,15); plotSurface.XAxis1.WorldMin = -1.0f; plotSurface.XAxis1.WorldMax = len; plotSurface.XAxis1.LabelFont = new Font( ff, 10 ); plotSurface.XAxis1.Label = "Cathode ID"; plotSurface.YAxis1.Label = "QE [%]"; plotSurface.YAxis1.LabelFont = new Font( ff, 10 ); plotSurface.YAxis1.TickTextFont = new Font( ff, 10 ); plotSurface.YAxis1.WorldMin = 0.0; plotSurface.YAxis1.WorldMax= 25.0; plotSurface.XAxis1.TicksLabelAngle = 60.0f; plotSurface.Refresh(); // Add timer into Gtk loop for data updates GLib.Timeout.Add( 500, new GLib.TimeoutHandler(qeExampleTimer_Tick) ); }
public PlotLabelAxis() { infoText = ""; infoText += "Internet Usage Example. Demonstrates - \n"; infoText += " * Label Axis with angled text. \n"; infoText += " * RectangleBrushes."; plotSurface.Clear(); Grid mygrid = new Grid(); mygrid.VerticalGridType = Grid.GridType.Coarse; Pen majorGridPen = new Pen( Color.LightGray ); float[] pattern = { 1.0f, 2.0f }; majorGridPen.DashPattern = pattern; mygrid.MajorGridPen = majorGridPen; plotSurface.Add( mygrid ); float[] xs = {20.0f, 31.0f, 27.0f, 38.0f, 24.0f, 3.0f, 2.0f }; float[] xs2 = {7.0f, 10.0f, 42.0f, 9.0f, 2.0f, 79.0f, 70.0f }; float[] xs3 = {1.0f, 20.0f, 20.0f, 25.0f, 10.0f, 30.0f, 30.0f }; HistogramPlot hp = new HistogramPlot(); hp.DataSource = xs; hp.BaseWidth = 0.6f; hp.RectangleBrush = new RectangleBrushes.HorizontalCenterFade( Color.FromArgb(255,255,200), Color.White ); hp.Filled = true; hp.Label = "Developer Work"; HistogramPlot hp2 = new HistogramPlot(); hp2.DataSource = xs2; hp2.Label = "Web Browsing"; hp2.RectangleBrush = RectangleBrushes.Horizontal.FaintGreenFade; hp2.Filled = true; hp2.StackedTo( hp ); HistogramPlot hp3 = new HistogramPlot(); hp3.DataSource = xs3; hp3.Label = "P2P Downloads"; hp3.RectangleBrush = RectangleBrushes.Vertical.FaintBlueFade; hp3.Filled = true; hp3.StackedTo( hp2 ); plotSurface.Add( hp ); plotSurface.Add( hp2 ); plotSurface.Add( hp3 ); plotSurface.Legend = new Legend(); LabelAxis la = new LabelAxis( plotSurface.XAxis1 ); la.AddLabel( "Monday", 0.0f ); la.AddLabel( "Tuesday", 1.0f ); la.AddLabel( "Wednesday", 2.0f ); la.AddLabel( "Thursday", 3.0f ); la.AddLabel( "Friday", 4.0f ); la.AddLabel( "Saturday", 5.0f ); la.AddLabel( "Sunday", 6.0f ); la.Label = "Days"; la.TickTextFont = new Font( "Courier New", 8 ); la.TicksBetweenText = true; plotSurface.XAxis1 = la; plotSurface.YAxis1.WorldMin = 0.0; plotSurface.YAxis1.Label = "MBytes"; ((LinearAxis)plotSurface.YAxis1).NumberOfSmallTicks = 1; plotSurface.Title = "Internet useage for user:\n johnc 09/01/03 - 09/07/03"; plotSurface.XAxis1.TicksLabelAngle = 30.0f; plotSurface.PlotBackBrush = RectangleBrushes.Vertical.FaintRedFade; plotSurface.Refresh(); }
/// <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( LabelAxis b, LabelAxis a ) { Axis.DoClone( b, a ); a.labels_ = (ArrayList)b.labels_.Clone(); a.numbers_ = (ArrayList)b.numbers_.Clone(); a.ticksBetweenText_ = b.ticksBetweenText_; a.sortDataIfNecessary_ = b.sortDataIfNecessary_; }
public PlotMockup() { infoText = ""; infoText += "THE TEST (can your charting library handle this?) - \n"; infoText += "NPlot demonstrates it can handle real world charting requirements."; // first of all, generate some mockup data. DataTable info = new DataTable( "Store Information" ); info.Columns.Add( "Index", typeof(int) ); info.Columns.Add( "IndexOffsetLeft", typeof(float) ); info.Columns.Add( "IndexOffsetRight", typeof(float) ); info.Columns.Add( "StoreName", typeof(string) ); info.Columns.Add( "BarBase", typeof(float) ); info.Columns.Add( "StoreGrowth", typeof(float) ); info.Columns.Add( "AverageGrowth", typeof(float) ); info.Columns.Add( "ProjectedSales", typeof(float) ); float barBase = 185.0f; Random r = new Random(); for (int i=0; i<18; ++i) { DataRow row = info.NewRow(); row["Index"] = i; row["IndexOffsetLeft"] = (float)i - 0.1f; row["IndexOffsetRight"] = (float)i + 0.1f; row["StoreName"] = "Store " + (i+1).ToString(); row["BarBase"] = barBase; row["StoreGrowth"] = barBase + ( (r.NextDouble() - 0.1) * 20.0f ); row["AverageGrowth"] = barBase + ( (r.NextDouble() - 0.1) * 15.0f ); row["ProjectedSales"] = barBase + ( r.NextDouble() * 15.0f ); info.Rows.Add( row ); barBase += (float)r.NextDouble() * 4.0f; } plotSurface.Clear(); plotSurface.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; // generate the grid Grid grid = new Grid(); grid.VerticalGridType = Grid.GridType.Coarse; grid.HorizontalGridType = Grid.GridType.None; grid.MajorGridPen = new Pen( Color.Black, 1.0f ); plotSurface.Add( grid ); // generate the trendline LinePlot trendline = new LinePlot(); trendline.DataSource = info; trendline.AbscissaData = "Index"; trendline.OrdinateData = "BarBase"; trendline.Pen = new Pen( Color.Black, 3.0f ); trendline.Label = "Trendline"; plotSurface.Add( trendline ); // draw store growth bars BarPlot storeGrowth = new BarPlot(); storeGrowth.DataSource = info; storeGrowth.AbscissaData = "IndexOffsetLeft"; storeGrowth.OrdinateDataTop = "StoreGrowth"; storeGrowth.OrdinateDataBottom = "BarBase"; storeGrowth.Label = "Store Growth"; storeGrowth.FillBrush = NPlot.RectangleBrushes.Solid.Black; //storeGrowth.BorderPen = new Pen( Color.Black, 2.0f ); plotSurface.Add( storeGrowth ); // draw average growth bars BarPlot averageGrowth = new BarPlot(); averageGrowth.DataSource = info; averageGrowth.AbscissaData = "IndexOffsetRight"; averageGrowth.OrdinateDataBottom = "BarBase"; averageGrowth.OrdinateDataTop = "AverageGrowth"; averageGrowth.Label = "Average Growth"; averageGrowth.FillBrush = NPlot.RectangleBrushes.Solid.Gray; //averageGrowth.BorderPen = new Pen( Color.Black, 2.0f ); plotSurface.Add( averageGrowth ); // generate the projected sales step line. StepPlot projected = new StepPlot(); projected.DataSource = info; projected.AbscissaData = "Index"; projected.OrdinateData = "ProjectedSales"; projected.Pen = new Pen( Color.Orange, 3.0f ); projected.HideVerticalSegments = true; projected.Center = true; projected.Label = "Projected Sales"; projected.WidthScale = 0.7f; plotSurface.Add( projected ); // generate the minimum target line. HorizontalLine minimumTargetLine = new HorizontalLine( 218, new Pen( Color.Green, 3.5f ) ); minimumTargetLine.Label = "Minimum Target"; minimumTargetLine.LengthScale = 0.98f; minimumTargetLine.ShowInLegend = true; // off by default for lines. plotSurface.Add( minimumTargetLine ); // generate the preferred target line. HorizontalLine preferredTargetLine = new HorizontalLine( 228, new Pen( Color.Blue, 3.5f ) ); preferredTargetLine.Label = "Preferred Target"; preferredTargetLine.LengthScale = 0.98f; preferredTargetLine.ShowInLegend = true; // off by default for lines. plotSurface.Add( preferredTargetLine ); // make some modifications so that chart matches requirements. // y axis. plotSurface.YAxis1.TicksIndependentOfPhysicalExtent = true; plotSurface.YAxis1.TickTextNextToAxis = false; //plotSurface.YAxis1.TicksAngle = 3.0f * (float)Math.PI / 2.0f; // Not required if TicksAngle bug #2000693 fixed ((LinearAxis)plotSurface.YAxis1).LargeTickStep = 10.0; ((LinearAxis)plotSurface.YAxis1).NumberOfSmallTicks = 0; // x axis plotSurface.XAxis1.TicksIndependentOfPhysicalExtent = true; plotSurface.XAxis1.TickTextNextToAxis = false; //plotSurface.XAxis1.TicksAngle = (float)Math.PI / 2.0f; // Not required if TicksAngle bug #2000693 fixed LabelAxis la = new LabelAxis( plotSurface.XAxis1 ); for (int i=0; i<info.Rows.Count; ++i) { la.AddLabel( (string)info.Rows[i]["StoreName"], Convert.ToInt32(info.Rows[i]["Index"]) ); } la.TicksLabelAngle = (float)90.0f; la.TicksBetweenText = true; plotSurface.XAxis1 = la; plotSurface.XAxis2 = (Axis)plotSurface.XAxis1.Clone(); plotSurface.XAxis2.HideTickText = true; plotSurface.XAxis2.LargeTickSize = 0; Legend l = new Legend(); l.NumberItemsVertically = 2; l.AttachTo( XAxisPosition.Bottom, YAxisPosition.Left ); l.HorizontalEdgePlacement = NPlot.Legend.Placement.Outside; l.VerticalEdgePlacement = NPlot.Legend.Placement.Inside; l.XOffset = 5; l.YOffset = 50; l.BorderStyle = NPlot.LegendBase.BorderType.Line; plotSurface.Legend = l; plotSurface.Title = "Sales Growth Compared to\n" + "Average Sales Growth by Store Size - Rank Order Low to High"; plotSurface.Refresh(); }
public void Draw() { this.plot.PlotBackColor = Color.White; this.plot.BackColor = Color.White; ArrayList xs1 = new ArrayList(); ArrayList times = new ArrayList(); int split = 1; long lap = 0; float max = 0; float min = 32767 * 32767; long nlaps = 0; long totaltime = 0; this.plot.Clear(); if (((long[])splits[winner]).Length < nsplits) return; for (int i = nsplits; i < ((long[])splits[winner]).Length; ++i) { lap += ((long[])splits[winner])[i]; if (i != 0) lap -= ((long[])splits[winner])[i - 1]; if (split == nsplits) { //times.Add(" " + timetostr(lap)); string time = " " + timetostr(lap, true) + " : "; for (int s = nsplits - 1; s >= 0; --s) { if (i == nsplits && s == nsplits) time += timetostr(((long[])splits[winner])[i - s], false); else time += timetostr(((long[])splits[winner])[i - s] - ((long[])splits[winner])[i - 1 - s], false); if (s != 0) time += " , "; } time += " "; times.Add(time); totaltime += lap; ++nlaps; if (max < lap) max = lap; if (min > lap) min = lap; xs1.Add((double)lap); split = 1; lap = 0; } else split++; } if (nlaps != 0) this.winner_avgtime = totaltime / nlaps; if (nlaps == 0) return; Grid mygrid = new Grid(); mygrid.VerticalGridType = Grid.GridType.Coarse; mygrid.HorizontalGridType = Grid.GridType.Coarse; mygrid.MajorGridPen = new Pen(Color.LightGray, 1f); this.plot.Add(mygrid); for (int i = 0; i < xs1.Count; ++i) { double[] abscissa = { 0 }; double[] ordinate = { 0 }; if ((double)xs1[i] < winner_avgtime) { abscissa[0] = (i); ordinate[0] = ((double)xs1[i]) / 10000.0; HistogramPlot hp = new HistogramPlot(); hp.OrdinateData = ordinate; hp.AbscissaData = abscissa; hp.RectangleBrush = new RectangleBrushes.Horizontal(Color.FromArgb(106, 205, 84), Color.FromArgb(235, 255, 213)); hp.Pen.Color = Color.FromArgb(0, 150, 0); hp.Filled = true; hp.ShowInLegend = false; this.plot.Add(hp); } if ((double)xs1[i] >= winner_avgtime) { abscissa[0] = i; if (Settings.LimitLapTimes && (((double)xs1[i] - winner_avgtime) > (winner_avgtime - min) * Settings.LimitMultiplier)) ordinate[0] = (winner_avgtime + (winner_avgtime - min) * Settings.LimitMultiplier) / 10000.0; else ordinate[0] = ((double)xs1[i]) / 10000.0; HistogramPlot hp = new HistogramPlot(); hp.OrdinateData = ordinate; hp.AbscissaData = abscissa; if (Settings.LimitLapTimes && (((double)xs1[i] - winner_avgtime) > (winner_avgtime - min) * Settings.LimitMultiplier)) { hp.RectangleBrush = new RectangleBrushes.Horizontal(Color.FromArgb(190, 39, 92), Color.FromArgb(235, 124, 177)); } else { hp.RectangleBrush = new RectangleBrushes.Horizontal(Color.FromArgb(235, 84, 137), Color.FromArgb(255, 230, 210)); } hp.Pen.Color = Color.FromArgb(150, 0, 0); hp.Filled = true; hp.ShowInLegend = false; this.plot.Add(hp); } } //int xmax = ((long[])splits[winner]).Length / nsplits; LabelAxis la = new LabelAxis(this.plot.XAxis1); la.TicksBetweenText = false; la.TicksCrossAxis = false; la.LargeTickSize = 0; la.TickTextFont = Settings.lapTimesFont; for (int i = 0; i < times.Count; ++i) la.AddLabel((string)times[i], i); la.TicksLabelAngle = -90.0f; this.plot.XAxis1 = la; la = new LabelAxis((LabelAxis)la.Clone()); la.TicksBetweenText = false; la.TicksCrossAxis = true; la.LargeTickSize = 2; la.TicksLabelAngle = -90.0f; la.TickTextNextToAxis = false; la.TickTextFont = Settings.commonFont; for (int i = 0; i < times.Count; ++i) { la.AddLabel(System.Convert.ToString(i + 2), i); } la.LabelFont = Settings.commonFont; this.plot.XAxis2 = la; this.plot.YAxis1.TicksCrossAxis = true; this.plot.YAxis1.Label = ((string)this.players[this.player]); this.plot.YAxis1.LabelFont = Settings.titleFont; this.plot.YAxis1.LabelOffset = 20; this.plot.YAxis1.NumberFormat = ""; this.plot.YAxis1.TicksCrossAxis = false; if (Settings.LimitToGlobalBestLap) this.plot.YAxis1.WorldMin = (double)this.bestlap / 10000.0; ((LinearAxis)this.plot.YAxis1).NumberOfSmallTicks = 4; ((LinearAxis)this.plot.YAxis1).LargeTickStep = 1; ((LinearAxis)this.plot.YAxis1).TicksLabelAngle = -90f; HorizontalLine hl = new HorizontalLine((float)winner_avgtime / 10000, Color.Gray); hl.Pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot; this.plot.Add(hl); this.laps = (int)nlaps; // this.plot.YAxis1.WorldMax += 1; if (this.plot.YAxis1.WorldMax - this.plot.YAxis1.WorldMin <= 0.1) this.plot.YAxis1.WorldMax += 1; this.plot.Refresh(); // System.Console.WriteLine(System.Convert.ToString(this.plot.YAxis1.WorldMin) + " " + System.Convert.ToString(this.plot.YAxis1.WorldMax)); }
public void PlotQE() { plotSurface.Clear(); int len = 24; string[] s = new string[len]; PlotQEExampleValues = new double[len]; PlotQEExampleTextValues = new string[len]; Random r = new Random(); for (int i=0; i<len;i++) { PlotQEExampleValues[i] = 8.0f + 12.0f * (double)r.Next(10000) / 10000.0f; if (PlotQEExampleValues[i] > 18.0f) { PlotQEExampleTextValues[i] = "KCsTe"; } else { PlotQEExampleTextValues[i] = ""; } s[i] = i.ToString("00") + ".1"; } PointPlot pp = new PointPlot(); pp.DataSource = PlotQEExampleValues; pp.Marker = new Marker( Marker.MarkerType.Square, 10 ); pp.Marker.DropLine = true; pp.Marker.Pen = Pens.CornflowerBlue; pp.Marker.Filled = false; plotSurface.Add( pp ); LabelPointPlot tp1 = new LabelPointPlot(); tp1.DataSource = PlotQEExampleValues; tp1.TextData = PlotQEExampleTextValues; tp1.LabelTextPosition = LabelPointPlot.LabelPositions.Above; tp1.Marker = new Marker( Marker.MarkerType.None, 10 ); plotSurface.Add( tp1 ); LabelAxis la = new LabelAxis( plotSurface.XAxis1 ); for (int i=0; i<len; ++i) { la.AddLabel( s[i], i ); } FontFamily ff = new FontFamily( "Verdana" ); la.TickTextFont = new Font( ff, 7 ); plotSurface.XAxis1 = la; plotSurface.Title = "Cs2Te Photocathode QE evolution"; plotSurface.TitleFont = new Font(ff,15); plotSurface.XAxis1.WorldMin = -1.0f; plotSurface.XAxis1.WorldMax = len; plotSurface.XAxis1.LabelFont = new Font( ff, 10 ); plotSurface.XAxis1.Label = "Cathode ID"; plotSurface.YAxis1.Label = "QE [%]"; plotSurface.YAxis1.LabelFont = new Font( ff, 10 ); plotSurface.YAxis1.TickTextFont = new Font( ff, 10 ); plotSurface.YAxis1.WorldMin = 0.0; plotSurface.YAxis1.WorldMax= 25.0; plotSurface.XAxis1.TicksLabelAngle = 60.0f; plotSurface.Refresh(); }