internal CoreSize PrepareChart(AxisTags source, ChartCore chart) { if (!(Math.Abs(MaxLimit - MinLimit) > S * .01) || !ShowLabels) { return(new CoreSize()); } CalculateSeparator(chart, source); var f = GetFormatter(); var biggest = new CoreSize(0, 0); var tolerance = S / 10; for (var i = MinLimit; i <= MaxLimit - (EvaluatesUnitWidth ? 1 : 0); i += S) { SeparatorElementCore asc; var key = Math.Round(i / tolerance) * tolerance; if (!Cache.TryGetValue(key, out asc)) { asc = new SeparatorElementCore { IsNew = true }; Cache[key] = asc; } else { asc.IsNew = false; } View.RenderSeparator(asc, Chart); asc.Key = key; asc.Value = i; asc.IsActive = true; var labelsSize = asc.View.UpdateLabel(f(i), this); biggest.Width = labelsSize.Width > biggest.Width ? labelsSize.Width : biggest.Width; biggest.Height = labelsSize.Height > biggest.Height ? labelsSize.Height : biggest.Height; if (LastAxisMax == null) { asc.State = SeparationState.InitialAdd; continue; } asc.State = SeparationState.Keep; } #if DEBUG Debug.WriteLine("Axis.Separations: " + Cache.Count); #endif return(biggest); }
private void DrawSeparator(double i, double tolerance, CoreMargin currentMargin, Func <double, string> f, AxisOrientation source) { if (i < BotLimit) { return; } SeparatorElementCore asc; var key = Math.Round(i / tolerance) * tolerance; if (!Cache.TryGetValue(key, out asc)) { asc = new SeparatorElementCore { IsNew = true }; Cache[key] = asc; } else { asc.IsNew = false; } View.RenderSeparator(asc, Chart); asc.Key = key; asc.Value = i; asc.GarbageCollectorIndex = GarbageCollectorIndex; var labelsMargin = asc.View.UpdateLabel(f(i), this, source); currentMargin.Width = labelsMargin.TakenWidth > currentMargin.Width ? labelsMargin.TakenWidth : currentMargin.Width; currentMargin.Height = labelsMargin.TakenHeight > currentMargin.Height ? labelsMargin.TakenHeight : currentMargin.Height; currentMargin.Left = labelsMargin.Left > currentMargin.Left ? labelsMargin.Left : currentMargin.Left; currentMargin.Right = labelsMargin.Right > currentMargin.Right ? labelsMargin.Right : currentMargin.Right; currentMargin.Top = labelsMargin.Top > currentMargin.Top ? labelsMargin.Top : currentMargin.Top; currentMargin.Bottom = labelsMargin.Bottom > currentMargin.Bottom ? labelsMargin.Bottom : currentMargin.Bottom; if (LastAxisMax == null) { asc.State = SeparationState.InitialAdd; return; } asc.State = SeparationState.Keep; }
internal override CoreMargin PrepareChart(AxisOrientation source, ChartCore chart) { if (!(Math.Abs(TopLimit - BotLimit) > S * .01) || !ShowLabels) { return(new CoreMargin()); } CalculateSeparator(chart, source); var f = GetFormatter(); var currentMargin = new CoreMargin(); if (S < 1) { S = 1; } var tolerance = S / 10; InitializeGarbageCollector(); var bl = Math.Ceiling(BotLimit / Magnitude) * Magnitude; var @base = ((ILogarithmicAxisView)View).Base; for (var i = bl; i <= TopLimit - (EvaluatesUnitWidth ? 1 : 0); i += S) { var minTolerance = tolerance / 10; if (Math.Abs(i - bl) > tolerance) { var step = Math.Pow(@base, i - 1); for (var j = Math.Pow(@base, i - 1) + step; j < Math.Pow(@base, i); j += step) { SeparatorElementCore minorAsc; var scaledJ = Math.Log(j, @base); var minorKey = Math.Round(scaledJ / minTolerance) * minTolerance; if (!Cache.TryGetValue(minorKey, out minorAsc)) { minorAsc = new SeparatorElementCore { IsNew = true }; Cache[minorKey] = minorAsc; } else { minorAsc.IsNew = false; } View.RenderSeparator(minorAsc, Chart); minorAsc.Key = minorKey; minorAsc.Value = scaledJ; minorAsc.GarbageCollectorIndex = GarbageCollectorIndex; minorAsc.View.UpdateLabel(string.Empty, this, source); if (LastAxisMax == null) { minorAsc.State = SeparationState.InitialAdd; continue; } minorAsc.State = SeparationState.Keep; } } SeparatorElementCore asc; var key = Math.Round(i / tolerance) * tolerance; if (!Cache.TryGetValue(key, out asc)) { asc = new SeparatorElementCore { IsNew = true }; Cache[key] = asc; } else { asc.IsNew = false; } View.RenderSeparator(asc, Chart); asc.Key = key; asc.Value = i; asc.GarbageCollectorIndex = GarbageCollectorIndex; var labelsMargin = asc.View.UpdateLabel(f(i), this, source); currentMargin.Width = labelsMargin.TakenWidth > currentMargin.Width ? labelsMargin.TakenWidth : currentMargin.Width; currentMargin.Height = labelsMargin.TakenHeight > currentMargin.Height ? labelsMargin.TakenHeight : currentMargin.Height; currentMargin.Left = labelsMargin.Left > currentMargin.Left ? labelsMargin.Left : currentMargin.Left; currentMargin.Right = labelsMargin.Right > currentMargin.Right ? labelsMargin.Right : currentMargin.Right; currentMargin.Top = labelsMargin.Top > currentMargin.Top ? labelsMargin.Top : currentMargin.Top; currentMargin.Bottom = labelsMargin.Bottom > currentMargin.Bottom ? labelsMargin.Bottom : currentMargin.Bottom; if (LastAxisMax == null) { asc.State = SeparationState.InitialAdd; continue; } asc.State = SeparationState.Keep; } return(currentMargin); }
internal CoreMargin PrepareChart(AxisTags source, ChartCore chart) { if (!(Math.Abs(MaxLimit - MinLimit) > S*.01) || !ShowLabels) return new CoreMargin(); CalculateSeparator(chart, source); var f = GetFormatter(); var currentMargin = new CoreMargin(); var tolerance = S/10; InitializeGarbageCollector(); for (var i = MinLimit; i <= MaxLimit - (EvaluatesUnitWidth ? 1 : 0); i += S) { SeparatorElementCore asc; var key = Math.Round(i/tolerance)*tolerance; if (!Cache.TryGetValue(key, out asc)) { asc = new SeparatorElementCore {IsNew = true}; Cache[key] = asc; } else { asc.IsNew = false; } View.RenderSeparator(asc, Chart); asc.Key = key; asc.Value = i; asc.GarbageCollectorIndex = GarbageCollectorIndex; var labelsMargin = asc.View.UpdateLabel(f(i), this, source); currentMargin.Width = labelsMargin.TakenWidth > currentMargin.Width ? labelsMargin.TakenWidth : currentMargin.Width; currentMargin.Height = labelsMargin.TakenHeight > currentMargin.Height ? labelsMargin.TakenHeight : currentMargin.Height; currentMargin.Left = labelsMargin.Left > currentMargin.Left ? labelsMargin.Left : currentMargin.Left; currentMargin.Right = labelsMargin.Right > currentMargin.Right ? labelsMargin.Right : currentMargin.Right; currentMargin.Top = labelsMargin.Top > currentMargin.Top ? labelsMargin.Top : currentMargin.Top; currentMargin.Bottom = labelsMargin.Bottom > currentMargin.Bottom ? labelsMargin.Bottom : currentMargin.Bottom; if (LastAxisMax == null) { asc.State = SeparationState.InitialAdd; continue; } asc.State = SeparationState.Keep; } return currentMargin; }
internal CoreMargin PrepareChart(AxisTags source, ChartCore chart) { if (!(Math.Abs(MaxLimit - MinLimit) > S * .01) || !ShowLabels) { return(new CoreMargin()); } CalculateSeparator(chart, source); var f = GetFormatter(); var currentMargin = new CoreMargin(); var tolerance = S / 10; InitializeGarbageCollector(); for (var i = MinLimit; i <= MaxLimit - (EvaluatesUnitWidth ? 1 : 0); i += S) { SeparatorElementCore asc; var key = Math.Round(i / tolerance) * tolerance; if (!Cache.TryGetValue(key, out asc)) { asc = new SeparatorElementCore { IsNew = true }; Cache[key] = asc; } else { asc.IsNew = false; } View.RenderSeparator(asc, Chart); asc.Key = key; asc.Value = i; asc.GarbageCollectorIndex = GarbageCollectorIndex; var labelsMargin = asc.View.UpdateLabel(f(i), this, source); currentMargin.Width = labelsMargin.TakenWidth > currentMargin.Width ? labelsMargin.TakenWidth : currentMargin.Width; currentMargin.Height = labelsMargin.TakenHeight > currentMargin.Height ? labelsMargin.TakenHeight : currentMargin.Height; currentMargin.Left = labelsMargin.Left > currentMargin.Left ? labelsMargin.Left : currentMargin.Left; currentMargin.Right = labelsMargin.Right > currentMargin.Right ? labelsMargin.Right : currentMargin.Right; currentMargin.Top = labelsMargin.Top > currentMargin.Top ? labelsMargin.Top : currentMargin.Top; currentMargin.Bottom = labelsMargin.Bottom > currentMargin.Bottom ? labelsMargin.Bottom : currentMargin.Bottom; if (LastAxisMax == null) { asc.State = SeparationState.InitialAdd; continue; } asc.State = SeparationState.Keep; } return(currentMargin); }
internal virtual CoreMargin PrepareChart(AxisOrientation source, ChartCore chart) { if (!(Math.Abs(TopLimit - BotLimit) > S * .01) || !ShowLabels) { return(new CoreMargin()); } CalculateSeparator(chart, source); var f = GetFormatter(); var currentMargin = new CoreMargin(); var tolerance = S / 10; InitializeGarbageCollector(); var m = !double.IsNaN(View.BarUnit) ? View.BarUnit : (!double.IsNaN(View.Unit) ? View.Unit : Magnitude); var u = !double.IsNaN(View.BarUnit) ? View.BarUnit : (!double.IsNaN(View.Unit) ? View.Unit : 1); var bl = Math.Truncate(BotLimit / m) * m; FirstSeparator = bl; for (var i = bl; i <= TopLimit - (EvaluatesUnitWidth ? u : 0); i += S) { if (i < BotLimit) { continue; } LastSeparator = i; SeparatorElementCore asc; var key = Math.Round(i / tolerance) * tolerance; if (!Cache.TryGetValue(key, out asc)) { asc = new SeparatorElementCore { IsNew = true }; Cache[key] = asc; } else { asc.IsNew = false; } View.RenderSeparator(asc, Chart); asc.Key = key; asc.Value = i; asc.GarbageCollectorIndex = GarbageCollectorIndex; var labelsMargin = asc.View.UpdateLabel(f(i), this, source); currentMargin.Width = labelsMargin.TakenWidth > currentMargin.Width ? labelsMargin.TakenWidth : currentMargin.Width; currentMargin.Height = labelsMargin.TakenHeight > currentMargin.Height ? labelsMargin.TakenHeight : currentMargin.Height; currentMargin.Left = labelsMargin.Left > currentMargin.Left ? labelsMargin.Left : currentMargin.Left; currentMargin.Right = labelsMargin.Right > currentMargin.Right ? labelsMargin.Right : currentMargin.Right; currentMargin.Top = labelsMargin.Top > currentMargin.Top ? labelsMargin.Top : currentMargin.Top; currentMargin.Bottom = labelsMargin.Bottom > currentMargin.Bottom ? labelsMargin.Bottom : currentMargin.Bottom; if (LastAxisMax == null) { asc.State = SeparationState.InitialAdd; continue; } asc.State = SeparationState.Keep; } return(currentMargin); }