public void ExecuteRecipe(Plot plt) { Random rand = new Random(0); double[] xs = DataGen.Random(rand, 50); double[] ys = DataGen.Random(rand, 50); var scatter = plt.AddScatterPoints(xs, ys, Color.Blue, 10); var vlines = new ScottPlot.Plottable.VLineVector(); vlines.Xs = new double[] { xs[1], xs[12], xs[35] }; vlines.Color = Color.Red; vlines.PositionLabel = true; vlines.PositionLabelBackground = vlines.Color; var hlines = new ScottPlot.Plottable.HLineVector(); hlines.Ys = new double[] { ys[1], ys[12], ys[35] }; hlines.Color = Color.DarkCyan; hlines.PositionLabel = true; hlines.PositionLabelBackground = hlines.Color; hlines.DragEnabled = true; plt.Add(scatter); plt.Add(vlines); plt.Add(hlines); }
public void ExecuteRecipe(Plot plt) { // display some sample data plt.AddSignal(DataGen.Sin(51)); plt.AddSignal(DataGen.Cos(51)); // display an image with 3 different alignments Bitmap monaLisa = DataGen.SampleImage(); var ip1 = new ScottPlot.Plottable.Image() { Bitmap = monaLisa, X = 10 }; var ip2 = new ScottPlot.Plottable.Image() { Bitmap = monaLisa, X = 25, Alignment = Alignment.MiddleCenter }; var ip3 = new ScottPlot.Plottable.Image() { Bitmap = monaLisa, X = 40, Alignment = Alignment.LowerRight }; plt.Add(ip1); plt.Add(ip2); plt.Add(ip3); plt.AddPoint(ip1.X, ip1.Y, Color.Magenta, size: 20); plt.AddPoint(ip2.X, ip2.Y, Color.Magenta, size: 20); plt.AddPoint(ip3.X, ip3.Y, Color.Magenta, size: 20); }
public void ExecuteRecipe(Plot plt) { //Generate a single signal containing 3 harmonic signals int sampleCount = 500; double[] signal1 = ScottPlot.DataGen.Sin(sampleCount, 10); double[] signal2 = ScottPlot.DataGen.Sin(sampleCount, 20); double[] signal3 = ScottPlot.DataGen.Sin(sampleCount, 30); double[] signal = new double[sampleCount]; for (int index = 0; index < sampleCount; index++) { signal[index] = signal1[index] + signal2[index] + signal3[index]; } // Plot the signal plt.AddSignal(signal); // Create a draggable RepeatingVLine with 5 lines spaced evenly by 50 X units, starting at position 0 // The first line will be thicker than the others ScottPlot.Plottable.RepeatingVLine vlines1 = new(); vlines1.DragEnabled = true; vlines1.count = 5; vlines1.shift = 50; vlines1.Color = System.Drawing.Color.Magenta; vlines1.LineWidth = 2; vlines1.LineStyle = LineStyle.Dash; vlines1.PositionLabel = true; vlines1.PositionLabelBackground = vlines1.Color; vlines1.relativeposition = false; plt.Add(vlines1); // Create a draggable RepeatingVLine with 5 lines spaced evenly by 50 X units, starting at position 0, with a -4 offset // The first line will be thicker than the others ScottPlot.Plottable.RepeatingVLine vlines2 = new(); vlines2.DragEnabled = true; vlines2.count = 3; vlines2.shift = 50; vlines2.offset = -1; vlines2.Color = System.Drawing.Color.DarkGreen; vlines2.LineWidth = 2; vlines2.LineStyle = LineStyle.Dot; vlines2.PositionLabel = true; vlines2.PositionLabelBackground = vlines2.Color; vlines2.relativeposition = false; plt.Add(vlines2); plt.SetAxisLimitsX(-100, 300); }
public GraphicsPage() { Title = "Graphics"; var physics = new Physics(); var points = new List <Vector2>(); var position = new Vector2(0, 0); for (int i = 0; i < 20; i++) { position = physics.Trajectory(position, i, 45f, 100f); points.Add(position); } var xValues = points.Select(x => x.X.ToDouble()).ToArray(); var yValues = points.Select(x => x.Y.ToDouble()).ToArray(); var signalPlot = new ScatterPlot(xValues, yValues) { }; var wpfPlot = new WpfPlot(); var plot = new Plot(); plot.Add(signalPlot); wpfPlot.Plot.Add(signalPlot); var view = new Grid(); view.Children.Add(wpfPlot); Content = view; }
public void ExecuteRecipe(Plot plt) { // plot sample data double[] xs = ScottPlot.DataGen.Consecutive(20); double[] ys = ScottPlot.DataGen.Sin(20); var scatter = new ScottPlot.Plottable.ScatterPlotListDraggable(); scatter.AddRange(xs, ys); scatter.MarkerSize = 5; plt.Add(scatter);
public void ExecuteRecipe(Plot plt) { double[] xs = ScottPlot.DataGen.Consecutive(51); double[] ys = ScottPlot.DataGen.Sin(51); var scatter = new ScottPlot.Plottable.ScatterPlotListDraggable(); scatter.AddRange(xs, ys); plt.Add(scatter); }
public void ExecuteRecipe(Plot plt) { double[] x = ScottPlot.DataGen.Consecutive(50); double[] y = ScottPlot.DataGen.Cos(50); var scatter = new ScottPlot.Plottable.ScatterPlotDraggable(x, y) { DragCursor = Cursor.Crosshair, DragEnabled = true, }; plt.Add(scatter); }
public void ExecuteRecipe(Plot plt) { double[] x = ScottPlot.DataGen.Consecutive(50); double[] y = ScottPlot.DataGen.Cos(50); var scatter = new ScottPlot.Plottable.ScatterPlotDraggable(x, y) { DragCursor = Cursor.Crosshair, DragEnabled = true, // controls whether anything can be dragged DragEnabledX = false, // controls whether points can be dragged horizontally DragEnabledY = true, // controls whether points can be dragged vertically }; plt.Add(scatter); }
private void AddValueToPlot(Plot plot, float val) { if (plot != null) { plot.Add(val); if (val > MaxY) { MaxY = val; } if (val < MinY) { MinY = val; } } }
public void ExecuteRecipe(Plot plt) { // display some sample data plt.AddSignal(DataGen.Sin(51)); plt.AddSignal(DataGen.Cos(51)); // place a rotated image on the plot Bitmap monaLisa = DataGen.SampleImage(); var ip1 = new ScottPlot.Plottable.Image() { Bitmap = monaLisa, X = 10, Y = .5, Rotation = 30 }; plt.Add(ip1); plt.AddPoint(ip1.X, ip1.Y, color: Color.Magenta, size: 20); }
public void ExecuteRecipe(Plot plt) { double[] xs = DataGen.Consecutive(51); double[] sin = DataGen.Sin(51); // instantiate a plottable var splt = new ScottPlot.Plottable.ScatterPlot(xs, sin); // customize its style or change its data as desired splt.Color = Color.Navy; splt.MarkerSize = 10; splt.MarkerShape = MarkerShape.filledDiamond; // add it to the plot plt.Add(splt); }
public void ExecuteRecipe(Plot plt) { // display some sample data plt.AddSignal(DataGen.Sin(51)); plt.AddSignal(DataGen.Cos(51)); // place an image on the plot plt.Add(new ScottPlot.Plottable.Image() { Bitmap = DataGen.SampleImage(), X = 10, Y = .5, Rotation = 30, BorderColor = Color.Magenta, BorderSize = 5, }); }
public void ExecuteRecipe(Plot plt) { // display some sample data plt.AddSignal(DataGen.Sin(51)); plt.AddSignal(DataGen.Cos(51)); // create the bitmap we want to display Bitmap monaLisa = DataGen.SampleImage(); // create the image plottable and add it to the plot var imagePlot = new ScottPlot.Plottable.Image() { Bitmap = monaLisa, X = 10, Y = .5 }; plt.Add(imagePlot); }
public void ExecuteRecipe(Plot plt) { plt.AddSignal(ScottPlot.DataGen.Sin(51)); plt.AddSignal(ScottPlot.DataGen.Cos(51)); var myDraggableMarker = new ScottPlot.Plottable.DraggableMarkerPlot() { X = 25, Y = .57, Color = Color.Magenta, MarkerShape = MarkerShape.filledDiamond, MarkerSize = 15, Text = "drag the point!", }; myDraggableMarker.TextFont.Size = 16; plt.Add(myDraggableMarker); }
public void ExecuteRecipe(Plot plt) { // create random data and display it with a scatter plot double[] xs = DataGen.Consecutive(50); double[] ys = DataGen.Random(new Random(0), 50); plt.AddScatter(xs, ys, label: "data"); // add a draggable marker that "snaps" to data values in that scatter plot var dmpv = new ScottPlot.Plottable.DraggableMarkerPlotInVector() { Xs = xs, Ys = ys, DragEnabled = true, IsVisible = true, MarkerSize = 15, MarkerShape = MarkerShape.filledDiamond, MarkerColor = Color.Magenta, Label = "marker", }; plt.Add(dmpv); plt.Legend(); }
public void Render(Plot plt) { // rather than call Plot.PlotText(), create the Plottable manually var customPlottable = new Plottable.Text() { text = "test", x = 2, y = 3, FontColor = System.Drawing.Color.Magenta, FontName = "arial", FontSize = 26, FontBold = true, alignment = Alignment.MiddleCenter, rotation = 0, frame = false, frameColor = System.Drawing.Color.Green }; // you can access properties which may not be exposed by a Plot method customPlottable.rotation = 45; // add the custom plottable to the list of plottables like this plt.Add(customPlottable); }
public void AddValue(float val) { plotObject.Add(val); UpdatePlotArea(); }
static async Task Main(string[] args) { IStockDataService yahooService = new YahooService(); _priceManager = new PriceManager(yahooService); var prices = CsvExtensions.ReadCsv( @"Data\\all_stocks_5yr.csv", new Dictionary <string, string> { { "date", "StartTime" }, { "open", "Open" }, { "close", "Close" }, { "high", "High" }, { "low", "Low" }, { "volume", "Volume" }, { "Name", "Symbol" } }); var aalPrice = prices.Where(c => c.Symbol.Equals("AAL")).SortByStartTime(); var open = aalPrice.Select(c => (double)c.Open).ToArray(); var high = aalPrice.Select(c => (double)c.High).ToArray(); var low = aalPrice.Select(c => (double)c.Low).ToArray(); var close = aalPrice.Select(c => (double)c.Close).ToArray(); var volume = aalPrice.Select(c => c.Volume).ToArray(); var lstm = new Lstm(open, high, low, close, volume); lstm.Print(); var scale = lstm.CalculateScale(); var min = lstm.CalculateMin(); var stochasticOsc = new StochasticOsc(); var sData = stochasticOsc.Run(GetData()); var plt = new Plot(600, 400); var slow = sData.Select(c => c.SlowValue).ToArray(); var vals = sData.Select(c => c.Value).ToArray(); //var xs = sData.Select(p => p.StartTime.ToOADate()).ToArray(); plt.PlotSignalXY(sData.Select(p => p.StartTime.ToOADate()).ToArray(), slow, label: "slow", color: Color.Red, lineWidth: 2, lineStyle: LineStyle.Solid, markerSize: 0); plt.PlotSignalXY(sData.Select(p => p.StartTime.ToOADate()).ToArray(), vals, label: "fast", color: Color.Black, lineWidth: 2, lineStyle: LineStyle.Solid); plt.Title("IBM Stochastic"); plt.YLabel("Stochastic Unit"); plt.XLabel("Date"); plt.Ticks(dateTimeX: true); //plt.Legend(); plt.AxisBounds(minY: 0, maxY: 100); plt.AxisAuto(verticalMargin: 0.01); plt.Add(new PlottableHLine(20, Color.Black, 1, "", false, 20, 20, LineStyle.Solid)); plt.Add(new PlottableHLine(80, Color.Black, 1, "", false, 80, 80, LineStyle.Solid)); plt.SaveFig("IBM Slow Stochastic Chart.png"); return; //var list = stochasticService.Run(sData); //await TargilAsync(); //var tickerManager = new TickerManager(yahooService, _priceManager); //var tickers = CsvExtensions.ReadConstituentsAsync("Data\\constituents.csv", new Dictionary<string, string> //{ // {"Symbol", "Symbol"}, // {"Name", "Name"}, // {"Sector", "Sector"}, //}).Result; //var msftTicker = tickerManager.GetTickerBySymbol(tickers, "MSFT"); //var prices = await _priceManager.GetPricesAsync( // msftTicker, // new DateTime(2020, 4, 13), // new DateTime(2020, 6, 26), // Interval.OneDay, // false); //var offsetPercent = 1; //var vals = stochasticService.Run(prices); //var plt = new ScottPlot.Plot(600, 400); //plt.PlotSignal(vals.Select(c => (double)c.Value).ToArray()); //plt.Title("Signal Plot Quickstart (5 million points)"); //plt.YLabel("Vertical Units"); //plt.XLabel("Horizontal Units"); //plt.SaveFig("Quickstart_Quickstart_Signal_5MillionPoints.png"); return; //var offsetPercent = 0.5; //var supportPoints = _priceManager.GetSupportExtremaGroups(prices, ExtremaType.Minimum, offsetPercent); //var p = prices.Last(); //Console.WriteLine($"Curret value: {p.Close}"); //Console.WriteLine("Support Points"); //supportPoints.Print(ExtremaType.Minimum); //Console.WriteLine(); //Console.WriteLine("Reject Points"); //rejectPoints.Print(ExtremaType.Maximum); //var daysMomentum = _priceManager.GetDaysMomentum(prices); //daysMomentum.Print(); }
static void Main() { //Random r = new Random(); //double[] array = new double[10000000]; //for (int i = 0; i < array.Length; i++) // array[i] = r.NextDouble() - 0.5; //Stopwatch sw = new Stopwatch(); //sw.Start(); ////var min = array.Where(e => e > 0).Min(); ////var max = array.Where(e => e > 0).Max(); //double min = double.MaxValue; //double max = double.MinValue; //for (int i = 0; i < array.Length; i++) //{ // if(array[i] > 0) // { // if (min > array[i]) min = array[i]; // if (max < array[i]) max = array[i]; // } //} //sw.Stop(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); double[] sin0 = new double[100]; double[] sin1 = new double[sin0.Length]; double[] sin2 = new double[sin0.Length]; for (int i = 0; i < sin0.Length; i++) { sin0[i] = Math.Sin(2 * Math.PI * i * 0.01); sin1[i] = Math.Sin(2 * Math.PI * (i + 5) * 0.01) + 0.1; sin2[i] = Math.Sin(2 * Math.PI * (i + 10) * 0.01) + 0.2; } double[] norm1 = new double[10]; double[] norm2 = new double[norm1.Length]; double sigma1 = 2; double sigma2 = 3; double avg1 = 5; double avg2 = 3; for (int i = 0; i < norm1.Length; i++) { norm1[i] = 1 / (sigma1 * Math.Sqrt(2 * Math.PI)) * Math.Exp(-1 * (i - avg1) * (i - avg1) / 2 / sigma1 / sigma1); norm2[i] = 1 / (sigma2 * Math.Sqrt(2 * Math.PI)) * Math.Exp(-1 * (i - avg2) * (i - avg2) / 2 / sigma2 / sigma2); } double[] freq = new double[] { 10000, 10232, 10471, 10715, 10964, 11220, 11481, 11748, 12022, 12302, 12589, 12882, 13182, 13489, 13803, 14125, 14454, 14791, 15135, 15488, 15848, 16218, 16595, 16982, 17378, 17782, 18197, 18620, 19054, 19498, 19952, 20417, 20892, 21379, 21877, 22387, 22908, 23442, 23988, 24547, 25118, 25703, 26302, 26915, 27542, 28183, 28840, 29512, 30199, 30902, 31622, 32359, 33113, 33884, 34673, 35481, 36307, 37153, 38018, 38904, 39810, 40738, 41686, 42657, 43651, 44668, 45708, 46773, 47863, 48977, 50118, 51286, 52480, 53703, 54954, 56234, 57543, 58884, 60255, 61659, 63095, 64565, 66069, 67608, 69183, 70794, 72443, 74131, 75857, 77624, 79432, 81283, 83176, 85113, 87096, 89125, 91201, 93325, 95499, 97723, 100000, 102329, 104712, 107151, 109647, 112201, 114815, 117489, 120226, 123026, 125892, 128824, 131825, 134896, 138038, 141253, 144543, 147910, 151356, 154881, 158489, 162181, 165958, 169824, 173780, 177827, 181970, 186208, 190546, 194984, 199526, 204173, 208929, 213796, 218776, 223872, 229086, 234422, 239883, 245470, 251188, 257039, 263026, 269153, 275422, 281838, 288403, 295120, 301995, 309029, 316227, 323593, 331131, 338844, 346736, 354813, 363078, 371535, 380189, 389045, 398107, 407380, 416869, 426579, 436515, 446683, 457088, 467735, 478630, 489778, 501187, 512861, 524807, 537031, 549540, 562341, 575439, 588843, 602559, 616595, 630957, 645654, 660693, 676082, 691830, 707945, 724435, 741310, 758577, 776247, 794328, 812830, 831763, 851138, 870963, 891250, 912010, 933254, 954992, 977237, 1000000 }; double[] fresp = new double[] { 0.034, 0.035, 0.037, 0.039, 0.041, 0.043, 0.045, 0.047, 0.049, 0.052, 0.054, 0.057, 0.059, 0.062, 0.065, 0.068, 0.071, 0.075, 0.078, 0.082, 0.086, 0.090, 0.094, 0.099, 0.104, 0.109, 0.114, 0.119, 0.125, 0.131, 0.137, 0.144, 0.150, 0.158, 0.165, 0.173, 0.181, 0.190, 0.199, 0.209, 0.219, 0.229, 0.240, 0.251, 0.264, 0.276, 0.289, 0.303, 0.318, 0.333, 0.349, 0.366, 0.384, 0.402, 0.422, 0.442, 0.464, 0.486, 0.510, 0.535, 0.561, 0.588, 0.617, 0.647, 0.679, 0.712, 0.747, 0.784, 0.823, 0.863, 0.906, 0.952, 0.999, 1.049, 1.102, 1.158, 1.216, 1.278, 1.343, 1.412, 1.484, 1.561, 1.642, 1.728, 1.818, 1.914, 2.016, 2.123, 2.237, 2.358, 2.487, 2.624, 2.770, 2.925, 3.090, 3.267, 3.456, 3.658, 3.876, 4.109, 4.360, 4.631, 4.924, 5.243, 5.589, 5.966, 6.380, 6.836, 7.340, 7.902, 8.531, 9.243, 10.057, 11.000, 12.111, 13.449, 15.114, 17.283, 20.339, 25.358, 37.682, 28.041, 21.125, 17.147, 14.314, 12.091, 10.247, 8.660, 7.261, 6.003, 4.856, 3.798, 2.813, 1.889, 1.016, 0.187, -0.602, -1.360, -2.088, -2.790, -3.469, -4.127, -4.767, -5.390, -5.998, -6.591, -7.173, -7.742, -8.301, -8.850, -9.390, -9.922, -10.446, -10.963, -11.473, -11.977, -12.475, -12.967, -13.455, -13.938, -14.416, -14.890, -15.360, -15.827, -16.290, -16.750, -17.207, -17.661, -18.112, -18.561, -19.007, -19.451, -19.893, -20.332, -20.770, -21.206, -21.640, -22.073, -22.504, -22.933, -23.362, -23.788, -24.214, -24.638, -25.062, -25.484, -25.905, -26.325, -26.745, -27.163, -27.581, -27.998, -28.414, -28.829, -29.244, -29.658, -30.071, -30.484, -30.897, -31.309, -31.720 }; Random r = new Random(); double[] randoms = new double[100]; double[] quantiles = new double[randoms.Length]; for (int i = 0; i < randoms.Length; i++) { randoms[i] = r.NextDouble(); quantiles[i] = QNorm(((double)i + 1.0 - 0.375) / ((double)randoms.Length + 0.25)); } Array.Sort(randoms); Plot plot0 = new Plot { Height = 300, Width = 500 }; plot0.Title = "Sin example"; plot0.Add(sin0); plot0.Add(sin1); plot0.Add(sin2); plot0.LegendStyle = LegendStyle.Inside; var im0 = plot0.ToImage(); Plot plot1 = new Plot { Height = 300, Width = 500 }; plot1.Title = "Histogram example"; plot1.Add(norm1, ps: PlotStyle.VerticalBars); plot1.Add(norm2, ps: PlotStyle.VerticalBars); plot1.LegendStyle = LegendStyle.Inside; var im1 = plot1.ToImage(); Plot plot2 = new Plot { Height = 300, Width = 500 }; plot2.Title = "Frequency response example"; plot2.Add(freq, fresp); plot2.GetHorizontalAxis().Title = "F, Hz"; plot2.GetHorizontalAxis().Logarithmic = true; plot2.GetHorizontalAxis().MinorTickNumber = 10; plot2.GetHorizontalAxis().GridStyle = GridStyle.Both; plot2.GetVerticalAxis().Title = "Vout, dB"; plot2.GetVerticalAxis().GridStyle = GridStyle.Both; var im2 = plot2.ToImage(); Plot plot3 = new Plot { Height = 300, Width = 500 }; plot3.Title = "Probability plot example"; plot3.GetHorizontalAxis().GridStyle = GridStyle.Both; plot3.GetVerticalAxis().GridStyle = GridStyle.Both; plot3.GetVerticalAxis().CustomTicks = new double[] { -2.326347874, -1.644853627, -1.281551566, -0.841621234, -0.524400513, -0.253347103, 0, 0.253347103, 0.524400513, 0.841621234, 1.281551566, 1.644853627, 2.326347874 }; plot3.GetVerticalAxis().CustomTicksLabels = new string[] { "1", "5", "10", "20", "30", "40", "50", "60", "70", "80", "90", "95", "99" }; plot3.Add(randoms, quantiles, ps: PlotStyle.Markers); plot3.Add(randoms, LinearRegression(randoms, quantiles, false)).LineWidth = 2; var im3 = plot3.ToImage(); Image im = new Bitmap(1000, 600); Graphics g = Graphics.FromImage(im); g.DrawImage(im0, 0, 0); g.DrawImage(im1, 500, 0); g.DrawImage(im2, 0, 300); g.DrawImage(im3, 500, 300); im.Save("plot.png"); /*OMPlot.Plot p = new Plot(); * p.Height = 500; * p.Width = 500; * var plot0 = p.Add(dataX, dataY1); * plot0.MarkStyle = Data.MarkerStyle.SolidCircle; * * var plot1 = p.Add(dataX, dataY2); * plot1.LineStyle = Data.LineStyle.None; * plot0.FillPlot = plot1;*/ /*foreach (Data.PlotInterpolation inter in Enum.GetValues(typeof(Data.PlotInterpolation))) * foreach (Data.FillStyle fill in Enum.GetValues(typeof(Data.FillStyle))) * PlotStyleTestBitmap(p, plot0, inter, fill);*/ //AxisTestBitmap(p, "Title", AxisPosition.Center, LabelsPosition.Near, Alignment.Center, LabelsPosition.Far, Alignment.Near, Alignment.Center, TicksLabelsRotation.Tilted); /*foreach (AxisPosition ap in Enum.GetValues(typeof(AxisPosition))) * foreach (LabelsPosition tp in Enum.GetValues(typeof(LabelsPosition))) * foreach (Alignment ta in Enum.GetValues(typeof(Alignment))) * foreach (LabelsPosition tlp in new LabelsPosition[] { LabelsPosition.Near, LabelsPosition.Far }) * foreach (Alignment tla in Enum.GetValues(typeof(Alignment))) * foreach (Alignment tlla in Enum.GetValues(typeof(Alignment))) * foreach (TicksLabelsRotation tlr in Enum.GetValues(typeof(TicksLabelsRotation))) * try * { * AxisTestBitmap(p, "Title", ap, tp, ta, tlp, tla, tlla, tlr); * } * catch * { }*/ /*dataX = new double[11]; * dataY1 = new double[dataX.Length]; * dataY2 = new double[dataX.Length]; * for (int i = 0; i < dataX.Length; i++) * { * dataX[i] = i - 5; * dataY1[i] = 25 - dataX[i] * dataX[i]; * dataY2[i] = 25 - (dataX[i] - 2) * (dataX[i] - 2); * } * * p.Clear(); * plot0 = p.Add(dataX, dataY1); * plot0.LineStyle = Data.LineStyle.None; * plot0.BarStyle = Data.BarStyle.Vertical; * plot0.BarDuty = 1.0f; * plot0.BarFillColor = Color.Red; * * plot1 = p.Add(dataX, dataY2); * plot1.LineStyle = Data.LineStyle.None; * plot1.BarStyle = Data.BarStyle.Vertical; * plot1.BarDuty = 1.0f; * plot1.BarFillColor = Color.Blue; * * p.ToImage().Save("Bar_Vertical_Fill.png"); * * plot0.BarStacking = true; * plot1.BarStacking = true; * p.ToImage().Save("Bar_Vertical_Stacking_Fill.png"); * * plot0.BarDuty = 0.5f; * plot1.BarDuty = 0.5f; * p.ToImage().Save("Bar_Vertical_Stacking_Duty_Fill.png"); * * * plot0.BarFillColor = Color.FromArgb(0, 0, 0,0); * plot1.BarFillColor = Color.FromArgb(0, 0, 0, 0); * plot0.BarLineColor = Color.Red; * plot1.BarLineColor = Color.Blue; * p.ToImage().Save("Bar_Vertical_Stacking_Duty_Line.png"); * * * * p.Clear(); * plot0 = p.Add(dataY1, dataX); * plot0.LineStyle = Data.LineStyle.None; * plot0.BarStyle = Data.BarStyle.Horisontal; * plot0.BarDuty = 1.0f; * plot0.BarFillColor = Color.Red; * * plot1 = p.Add(dataY2, dataX); * plot1.LineStyle = Data.LineStyle.None; * plot1.BarStyle = Data.BarStyle.Horisontal; * plot1.BarDuty = 1.0f; * plot1.BarFillColor = Color.Blue; * * p.ToImage().Save("Bar_Horisontal_Fill.png"); * * plot0.BarStacking = true; * plot1.BarStacking = true; * p.ToImage().Save("Bar_Horisontal_Stacking_Fill.png"); * * plot0.BarDuty = 0.5f; * plot1.BarDuty = 0.5f; * p.ToImage().Save("Bar_Horisontal_Stacking_Duty_Fill.png"); * * * plot0.BarFillColor = Color.FromArgb(0, 0, 0, 0); * plot1.BarFillColor = Color.FromArgb(0, 0, 0, 0); * plot0.BarLineColor = Color.Red; * plot1.BarLineColor = Color.Blue; * p.ToImage().Save("Bar_Horisontal_Stacking_Duty_Line.png"); * * p.Clear(); * double[] sinX = new double[100]; * double[] sinY1 = new double[sinX.Length]; * double[] sinY2 = new double[sinX.Length]; * double[] sinY3 = new double[sinX.Length]; * double[] sinY4 = new double[sinX.Length]; * double[] sinY5 = new double[sinX.Length]; * double[] sinY6 = new double[sinX.Length]; * double[] sinY7 = new double[sinX.Length]; * double[] sinY8 = new double[sinX.Length]; * double[] sinY9 = new double[sinX.Length]; * double[] sinY11 = new double[sinX.Length]; * double[] sinY12 = new double[sinX.Length]; * double[] sinY13 = new double[sinX.Length]; * double[] sinY14 = new double[sinX.Length]; * double[] sinY15 = new double[sinX.Length]; * double[] sinY16 = new double[sinX.Length]; * double[] sinY17 = new double[sinX.Length]; * double[] sinY18 = new double[sinX.Length]; * double[] sinY19 = new double[sinX.Length]; * * double f = 3; * double dt = 2.0 / sinX.Length; * * for (int i = 0; i < sinX.Length; i++) * { * sinX[i] = (sinX.Length - 1 - i) * dt; * sinY1[i] = Math.Sin(2 * Math.PI * sinX[i] * f) + 0.1; * sinY2[i] = Math.Sin(2 * Math.PI * sinX[i] * f) + 0.2; * sinY3[i] = Math.Sin(2 * Math.PI * sinX[i] * f) + 0.3; * sinY4[i] = Math.Sin(2 * Math.PI * sinX[i] * f) + 0.4; * sinY5[i] = Math.Sin(2 * Math.PI * sinX[i] * f) + 0.5; * sinY6[i] = Math.Sin(2 * Math.PI * sinX[i] * f) + 0.6; * sinY7[i] = Math.Sin(2 * Math.PI * sinX[i] * f) + 0.7; * sinY8[i] = Math.Sin(2 * Math.PI * sinX[i] * f) + 0.8; * sinY9[i] = Math.Sin(2 * Math.PI * sinX[i] * f) + 0.9; * sinY11[i] = Math.Sin(2 * Math.PI * sinX[i] * f) + 1.1; * sinY12[i] = Math.Sin(2 * Math.PI * sinX[i] * f) + 1.2; * sinY13[i] = Math.Sin(2 * Math.PI * sinX[i] * f) + 1.3; * sinY14[i] = Math.Sin(2 * Math.PI * sinX[i] * f) + 1.4; * sinY15[i] = Math.Sin(2 * Math.PI * sinX[i] * f) + 1.5; * sinY16[i] = Math.Sin(2 * Math.PI * sinX[i] * f) + 1.6; * sinY17[i] = Math.Sin(2 * Math.PI * sinX[i] * f) + 1.7; * sinY18[i] = Math.Sin(2 * Math.PI * sinX[i] * f) + 1.8; * sinY19[i] = Math.Sin(2 * Math.PI * sinX[i] * f) + 1.9; * } * * var pl1 = p.Add(sinX, sinY1, "Plot1"); * var pl2 = p.Add(sinX, sinY2, "Plot2"); * var pl3 = p.Add(sinX, sinY3, "Plot3"); * var pl4 = p.Add(sinX, sinY4, "Plot4"); * var pl5 = p.Add(sinX, sinY5, "Plot5Plot5Plot5"); * var pl6 = p.Add(sinX, sinY6, "Plot6"); * var pl7 = p.Add(sinX, sinY7, "Plot7"); * var pl8 = p.Add(sinX, sinY8, "Plot8"); * var pl9 = p.Add(sinX, sinY9, "Plot9"); * var pl11 = p.Add(sinX, sinY11, "Plot11"); * var pl12 = p.Add(sinX, sinY12, "Plot12"); * var pl13 = p.Add(sinX, sinY13, "Plot13"); * var pl14 = p.Add(sinX, sinY14, "Plot14"); * var pl15 = p.Add(sinX, sinY15, "Plot15"); * var pl16 = p.Add(sinX, sinY16, "Plot16"); * var pl17 = p.Add(sinX, sinY17, "Plot17"); * var pl18 = p.Add(sinX, sinY18, "Plot18"); * var pl19 = p.Add(sinX, sinY19, "Plot19"); * * pl1.BarStyle = Data.BarStyle.Vertical; * pl1.BarFillColor = Color.Red; * pl2.MarkStyle = Data.MarkerStyle.SolidCircle; * pl3.LineStyle = Data.LineStyle.Dash; * pl4.LineStyle = Data.LineStyle.DashDot; * pl5.LineStyle = Data.LineStyle.DashDotDot; * pl6.LineStyle = Data.LineStyle.Dot; * * p.LegendStyle = LegendStyle.Outside; * p.LegendPosition = LegendPosition.Top; p.ToImage().Save("Legend_Outside_Top.png"); * p.LegendPosition = LegendPosition.Bottom; p.ToImage().Save("Legend_Outside_Bottom.png"); * p.LegendPosition = LegendPosition.Left; p.ToImage().Save("Legend_Outside_Left.png"); * p.LegendPosition = LegendPosition.Right; p.ToImage().Save("Legend_Outside_Right.png"); * * p.LegendStyle = LegendStyle.Inside; * p.LegendAlign = LegendAlign.Near; * p.LegendPosition = LegendPosition.Top; p.ToImage().Save("Legend_Inside_Near_Top.png"); * p.LegendPosition = LegendPosition.Bottom; p.ToImage().Save("Legend_Inside_Near_Bottom.png"); * p.LegendPosition = LegendPosition.Left; p.ToImage().Save("Legend_Inside_Near_Left.png"); * p.LegendPosition = LegendPosition.Right; p.ToImage().Save("Legend_Inside_Near_Right.png"); * * p.LegendStyle = LegendStyle.Inside; * p.LegendAlign = LegendAlign.Center; * p.LegendPosition = LegendPosition.Top; p.ToImage().Save("Legend_Inside_Center_Top.png"); * p.LegendPosition = LegendPosition.Bottom; p.ToImage().Save("Legend_Inside_Center_Bottom.png"); * p.LegendPosition = LegendPosition.Left; p.ToImage().Save("Legend_Inside_Center_Left.png"); * p.LegendPosition = LegendPosition.Right; p.ToImage().Save("Legend_Inside_Center_Right.png"); * * p.LegendStyle = LegendStyle.Inside; * p.LegendAlign = LegendAlign.Far; * p.LegendPosition = LegendPosition.Top; p.ToImage().Save("Legend_Inside_Far_Top.png"); * p.LegendPosition = LegendPosition.Bottom; p.ToImage().Save("Legend_Inside_Far_Bottom.png"); * p.LegendPosition = LegendPosition.Left; p.ToImage().Save("Legend_Inside_Far_Left.png"); * p.LegendPosition = LegendPosition.Right; p.ToImage().Save("Legend_Inside_Far_Right.png");*/ Application.Run(new Form1()); }
private Result Calculate(Tab tab) { var resultTable = new decimal?[4, 2]; //------ input data ------- var jobPalette = tab.DurationByWork; var mashines = GenerateInputMashines(tab.DeviceProductivities); //-------- get chains ---------- List <List <int> > chains = ChainsAlgorithm.GetChains(jobPalette); //------ get jobsScheduling ------- decimal C_1; decimal?Cmax1; var jobsScheduling1 = ScheduleAlgorithm.BuildedSchedule(chains, mashines, AlgorithmType.A1, out C_1, out Cmax1); decimal C_2; decimal?Cmax2; var jobsScheduling2 = ScheduleAlgorithm.BuildedSchedule(chains, mashines, AlgorithmType.A2, out C_2, out Cmax2); decimal C_3; decimal?Cmax3; var jobsScheduling3 = ScheduleAlgorithm.BuildedSchedule(chains, mashines, AlgorithmType.A3, out C_3, out Cmax3); decimal C_4; decimal?Cmax4; var jobsScheduling4 = ScheduleAlgorithm.BuildedSchedule(chains, mashines, AlgorithmType.A4, out C_4, out Cmax4); //----- for result -------- var ChainResult = new decimal[tab.DurationByWork.GetLength(0) * tab.DurationByWork.GetLength(1), 2]; var index = 0; var chainNumber = 1; foreach (var job in chains) { decimal currentNum = chainNumber; foreach (var jobDuration in job) { currentNum += .1m; ChainResult[index, 0] = currentNum; ChainResult[index, 1] = decimal.Round(jobDuration, 0); index++; } chainNumber++; } var plot1 = new Plot(); foreach (var val in jobsScheduling1) { plot1.Add(val.Key, val.Value); } var plot2 = new Plot(); foreach (var val in jobsScheduling2) { plot2.Add(val.Key, val.Value); } var plot3 = new Plot(); foreach (var val in jobsScheduling3) { plot3.Add(val.Key, val.Value); } var plot4 = new Plot(); foreach (var val in jobsScheduling4) { plot4.Add(val.Key, val.Value); } return(new Result { Chain = ChainResult, AlgorithSummaries = new AlgorithSummary[] { new AlgorithSummary { Type = AlgorithmType.A1, Cstar = decimal.Round(C_1, 2), Cmax = decimal.Round((decimal)Cmax1, 2) }, new AlgorithSummary { Type = AlgorithmType.A2, Cstar = decimal.Round(C_2, 2), Cmax = decimal.Round((decimal)Cmax2, 2) }, new AlgorithSummary { Type = AlgorithmType.A3, Cstar = decimal.Round(C_3, 2), Cmax = decimal.Round((decimal)Cmax3, 2) }, new AlgorithSummary { Type = AlgorithmType.A4, Cstar = decimal.Round(C_4, 2), Cmax = decimal.Round((decimal)Cmax4, 2) }, }, PlotData = new Dictionary <AlgorithmType, Plot> { { AlgorithmType.A1, plot1 }, { AlgorithmType.A2, plot2 }, { AlgorithmType.A3, plot3 }, { AlgorithmType.A4, plot4 }, } }); }