/// <summary> /// /// </summary> internal override CoreMargin PrepareChart(AxisOrientationNew source, ChartCore chart) { if (!(Math.Abs(TopLimit - BotLimit) > S * .01) || !ShowLabels) { return(new CoreMargin()); } var currentMargin = new CoreMargin(); var tolerance = S / 10; InitializeGarbageCollector(); // Determine which magnitude and unit to use var m = (!double.IsNaN(View.Unit) ? View.Unit : Magnitude); var u = (!double.IsNaN(View.Unit) ? View.Unit : 1); // Calculate the separator indices var indices = CalculateSeparatorIndices(chart, source, u); // Draw the separators foreach (var index in indices) { DrawSeparator(index, tolerance, currentMargin, source); } return(currentMargin); }
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; }
private void DrawSeparator(double x, double tolerance, CoreMargin currentMargin, AxisOrientationNew source) { SeparatorElementCore elementCore; var key = Math.Round(x / tolerance) * tolerance; if (!Cache.TryGetValue(key, out elementCore)) { elementCore = new DateSeparatorElementCore { IsNew = true }; Cache[key] = elementCore; } else { elementCore.IsNew = false; } // Determine whether this separator is a header now ((DateSeparatorElementCore)elementCore).IsHeader = SelectedWindow.IsHeader(x); View.RenderSeparator(elementCore, Chart); elementCore.Key = key; elementCore.Value = x; elementCore.GarbageCollectorIndex = GarbageCollectorIndex; var labelsMargin = elementCore.View.UpdateLabel(SelectedWindow.FormatAxisLabel(x), 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) { elementCore.State = SeparationState.InitialAdd; return; } elementCore.State = SeparationState.Keep; }
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); if (TopLimit <= 0 && BotLimit < 0) { var l = TopLimit - (EvaluatesUnitWidth ? u : 0); LastSeparator = l; for (var i = l; i >= Math.Truncate(BotLimit / m) * m; i -= S) { FirstSeparator = i; DrawSeparator(i, tolerance, currentMargin, f, source); } } else { var l = Math.Truncate(BotLimit / m) * m; FirstSeparator = l; for (var i = l; i <= TopLimit - (EvaluatesUnitWidth ? u : 0); i += S) { LastSeparator = i; DrawSeparator(i, tolerance, currentMargin, f, source); } } return(currentMargin); }
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); }