public void LoadPriceBars(Bookmark <IPriceBar> priceBars) { int maxIndex = priceBars.Count; double[] opens = new double[maxIndex]; double[] highs = new double[maxIndex]; double[] lows = new double[maxIndex]; double[] closes = new double[maxIndex]; double[] times = new double[maxIndex]; for (int i = 0; i < maxIndex; i++) { IPriceBar priceBar = priceBars[i]; opens[i] = priceBar.Open; highs[i] = priceBar.High; lows[i] = priceBar.Low; closes[i] = priceBar.Close; times[i] = i; } CandlePlot cp = new CandlePlot(); cp.OpenData = opens; cp.HighData = highs; cp.LowData = lows; cp.CloseData = closes; cp.AbscissaData = times; plotSurface.Clear(); plotSurface.Add(cp); plotSurface.Refresh(); }
public PriceAction() { plotSurface = new NPlot.Bitmap.PlotSurface2D(700, 500); string infoText = ""; infoText += "Simple CandlePlot example. Demonstrates - \n"; infoText += " * Setting candle plot datapoints using arrays \n"; infoText += " * Plot Zoom interaction using MouseWheel "; plotSurface.Clear(); FilledRegion fr = new FilledRegion( new VerticalLine(1.2), new VerticalLine(2.4)); fr.Brush = Brushes.BlanchedAlmond; plotSurface.Add(fr); // note that arrays can be of any type you like. int[] opens = { 1, 2, 1, 2, 1, 3 }; double[] closes = { 2, 2, 2, 1, 2, 1 }; float[] lows = { 0, 1, 1, 1, 0, 0 }; System.Int64[] highs = { 3, 2, 3, 3, 3, 4 }; int[] times = { 0, 1, 2, 3, 4, 5 }; CandlePlot cp = new CandlePlot(); cp.CloseData = closes; cp.OpenData = opens; cp.LowData = lows; cp.HighData = highs; cp.AbscissaData = times; plotSurface.Add(cp); HorizontalLine line = new HorizontalLine(1.2); line.LengthScale = 0.89f; plotSurface.Add(line, -10); VerticalLine line2 = new VerticalLine(1.2); line2.LengthScale = 0.89f; plotSurface.Add(line2); plotSurface.AddInteraction(new PlotZoom()); plotSurface.Title = "Line in the Title Number 1\nFollowed by another title line\n and another"; plotSurface.Refresh(); }
private void InitPlot(out NPlot.Bitmap.PlotSurface2D npSurface, out Font AxisFont, out Font TickFont, out NPlot.Grid p, int width, int height) { npSurface = new NPlot.Bitmap.PlotSurface2D(width, height); npSurface.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; //Font definitions: AxisFont = new Font("Arial", 10); TickFont = new Font("Arial", 8); //Prepare PlotSurface: npSurface.Clear(); npSurface.Title = this.Title; npSurface.BackColor = System.Drawing.Color.White; //Left Y axis grid: p = new Grid(); npSurface.Add(p, NPlot.PlotSurface2D.XAxisPosition.Bottom, NPlot.PlotSurface2D.YAxisPosition.Left); }
static void Main(string[] args) { //string file = File.ReadAllText(@"C:\Users\abradu\Desktop\Personal\Flights\284F4A90C57F3FA3E04E364FE6ACB925.json"); string file = File.ReadAllText(@"C:\Users\abradu\Desktop\Personal\Flights\20056AD50DEFACE5A912E9076752BA70.json"); Blackbox bb = new JavaScriptSerializer().Deserialize <Blackbox>(file); bb.ConvertToNatives(); bb.SVT(); for (int i = 0; i < bb.altitude.Count; i++) { bb.altitude[i] = bb.altitude[i] / 1000; } NPlot.Bitmap.PlotSurface2D npSurface = new NPlot.Bitmap.PlotSurface2D(10000, 1000); NPlot.LinePlot npPlot1 = new LinePlot(); NPlot.LinePlot npPlot2 = new LinePlot(); NPlot.LinePlot npPlot3 = new LinePlot(); NPlot.LinePlot npPlot4 = new LinePlot(); NPlot.LinePlot npPlot5 = new LinePlot(); npSurface.Clear(); npSurface.Title = "Line Graph"; npSurface.BackColor = System.Drawing.Color.White; //Left Y axis grid: NPlot.Grid p = new Grid(); NPlot.HistogramPlot h = new HistogramPlot(); npSurface.Add(p, NPlot.PlotSurface2D.XAxisPosition.Bottom, NPlot.PlotSurface2D.YAxisPosition.Left); //Phi: npPlot1.AbscissaData = bb.time; npPlot1.DataSource = bb.angle_phi; npPlot1.Label = "Phi"; npPlot1.Color = System.Drawing.Color.Blue; npSurface.Add(npPlot1, NPlot.PlotSurface2D.XAxisPosition.Bottom, NPlot.PlotSurface2D.YAxisPosition.Left); //Phi: npPlot2.AbscissaData = bb.time; npPlot2.DataSource = bb.angle_psi; npPlot2.Label = "Psi"; npPlot2.Color = System.Drawing.Color.Red; npSurface.Add(npPlot2, NPlot.PlotSurface2D.XAxisPosition.Bottom, NPlot.PlotSurface2D.YAxisPosition.Left); //Theta: npPlot3.AbscissaData = bb.time; npPlot3.DataSource = bb.angle_theta; npPlot3.Label = "Theta"; npPlot3.Color = System.Drawing.Color.Green; npSurface.Add(npPlot3, NPlot.PlotSurface2D.XAxisPosition.Bottom, NPlot.PlotSurface2D.YAxisPosition.Left); //Speed: npPlot4.AbscissaData = bb.time; npPlot4.DataSource = bb.SpeedVsTheta; npPlot4.Label = "Speed"; npPlot4.Color = System.Drawing.Color.Black; npSurface.Add(npPlot4, NPlot.PlotSurface2D.XAxisPosition.Bottom, NPlot.PlotSurface2D.YAxisPosition.Left); ////Alti: //npPlot5.AbscissaData = bb.time; //npPlot5.DataSource = bb.altitude; //npPlot5.Label = "Alt"; //npPlot5.Color = System.Drawing.Color.Orange; //npSurface.Add(npPlot5, NPlot.PlotSurface2D.XAxisPosition.Bottom, // NPlot.PlotSurface2D.YAxisPosition.Left); npSurface.Refresh(); MemoryStream memStream = new MemoryStream(); npSurface.Bitmap.Save(memStream, System.Drawing.Imaging.ImageFormat.Gif); FileStream fs = new FileStream(@"D:\file.gif", FileMode.Create); memStream.WriteTo(fs); //Console.WriteLine("Done"); //Console.ReadLine(); }