/// <summary> /// Основная фаза - тело действия /// </summary> /// <returns> </returns> protected override object MainProcess() { var chart = ChartBuilder.ParseDatasets(ChartData); var brick = chart.ToBrickDataset(); var height = (Context.Get("__height") ?? "400").ToInt(); var brickRequest = new BrickRequest { Size = height, SourceMinValue = brick.GetMin(), SourceMaxValue = brick.GetMax(), MinimalScaleBehavior = MiniamlScaleBehavior.FitMin }; var catalog = new BrickCatalog(); var variant = catalog.GetBestVariant(brickRequest); brick.Preferences.SeriaCalcMode = SeriaCalcMode.Linear; brick.Preferences.Height = height; brick.Preferences.YMin = "auto"; brick.FirstScale = new Scale { Min = variant.ResultMinValue, Max = variant.ResultMaxValue }; var newChart = brick.Calculate().ToChart(); newChart.SetNumDivLines(variant.ResultDivCount); newChart.SetYAxisMinValue(Convert.ToDouble(variant.ResultMinValue)); newChart.SetYAxisMaxValue(Convert.ToDouble(variant.ResultMaxValue)); return(newChart); }
public void BUGZero() { var brickRequest = new BrickRequest(); brickRequest.SourceMaxValue = 0; brickRequest.SourceMinValue = -36177; brickRequest.Size = 325; brickRequest.MinPixelTop = 0; brickRequest.Setup("", "0", "auto", "0", "0"); var bcatalog = new BrickCatalog(); var variant = bcatalog.GetBestVariant(brickRequest); }
private static void ExecuteScaleTest(string dataRow, double expectedMin, double expectedMax, double divline, bool checkDivlines, int height, int minvalue, bool upperlabel) { var data = dataRow.SmartSplit(false, true, new[] { ',' }).Select(_ => Convert.ToDecimal(_, CultureInfo.InvariantCulture)); decimal maxval = data.Max(); decimal minval = data.Min(); //: minvalue; var behavior = MiniamlScaleBehavior.KeepZero; if (minvalue == -1) { behavior = MiniamlScaleBehavior.FitMin; } if (minvalue != -1 && minvalue != 0) { behavior = MiniamlScaleBehavior.MatchMin; if (minvalue < minval) { minval = minvalue; } } var request = new BrickRequest(maxval, minval, upperlabel) { Size = height, MinimalScaleBehavior = behavior }; var catalog = new BrickCatalog(); var variant = catalog.GetBestVariant(request); Console.WriteLine("Expected: from {0} to {1} with {2} divlines", expectedMin, expectedMax, divline); Console.WriteLine("Gotten: from {0} to {1} with {2} divlines", variant.ResultMinValue, variant.ResultMaxValue, variant.ResultDivCount); Assert.AreEqual(expectedMin, variant.ResultMinValue); Assert.AreEqual(expectedMax, variant.ResultMaxValue); if (checkDivlines) { Assert.AreEqual(divline, variant.ResultDivCount); } }
private void CalculateFirstScale() { if (0 == Preferences.YFixMin && 0 == Preferences.YFixMin && 0 == Preferences.YFixDiv) { if (FirstScale == null) { var realMin = GetMin(); var realMax = GetMax(); var req = new BrickRequest { SourceMinValue = realMin, SourceMaxValue = realMax }; req.Setup(Preferences.Y, Preferences.YMin, Preferences.YMax, Preferences.YTop.ToString(), Preferences.YSignDelta.ToString()); var cat = new BrickCatalog(); var result = cat.GetBestVariant(req); FirstScale = new Scale { Prepared = true, Min = result.ResultMinValue, Max = result.ResultMaxValue, DivLines = result.ResultDivCount }; } FirstScale.ValueInPixel = BrickDataSetHelper.GetValuesInPixel(FirstScale.Min, FirstScale.Max, Preferences.Height); } else { FirstScale = new Scale(); } }
private void CalculateSecondScale() { if (0 == Preferences.SYFixMin && 0 == Preferences.SYFixMin && 0 == Preferences.SYFixDiv) { var realMin = GetMin(ScaleType.Second); var realMax = GetMax(ScaleType.Second); var req = new BrickRequest { SourceMinValue = realMin, SourceMaxValue = realMax }; req.Setup(Preferences.SY, Preferences.SYMin, Preferences.SYMax, Preferences.SYTop.ToString(), Preferences.SYSignDelta.ToString()); var cat = new BrickCatalog(); var result = cat.GetBestVariant(req); SecondScale = new Scale { Prepared = true, Min = result.ResultMinValue, Max = result.ResultMaxValue, DivLines = result.ResultDivCount, }; SecondScale.ValueInPixel = (SecondScale.Max - SecondScale.Min)/Preferences.Height; } else { SecondScale = new Scale(); } }