internal IEnumerable <double> CalculateSeparatorIndices(ChartCore chart, AxisOrientationNew source, double unit) { if (!double.IsNaN(Separator.Step)) { throw new Exception("Step should be NaN for WindowAxis separators"); } if (Windows == null) { return(Enumerable.Empty <double>()); } // Holder for the calculated separator indices and the proposed window var supportedSeparatorCount = 0; var separatorIndices = new List <double>(); IAxisWindow proposedWindow = AxisWindows.EmptyWindow; // Build a range of possible separator indices var rangeIndices = Enumerable.Range((int)Math.Floor(BotLimit), (int)Math.Floor(TopLimit - (EvaluatesUnitWidth ? unit : 0) - BotLimit)).Select(i => (double)i).ToList(); // Make sure we have at least 2 separators to show if (Windows != null && rangeIndices.Count > 1) { foreach (var window in Windows) { IEnumerable <double> proposedSeparatorIndices; // Calculate the number of supported separators. supportedSeparatorCount = (int)Math.Floor(chart.ControlSize.Width / (window.MinimumSeparatorWidth * CleanFactor)); // Try go get separators. Continue if the window invalidated. if (!window.TryGetSeparatorIndices(rangeIndices, supportedSeparatorCount, out proposedSeparatorIndices)) { continue; } // Double check whether the window exceeded the maximum separator count. // It might be it does not respect the supportedSeparatorCount parameter. separatorIndices = proposedSeparatorIndices.ToList(); if (supportedSeparatorCount < separatorIndices.Count) { continue; } // Pick this window. It is the first who passed both validations and our best candidate proposedWindow = window; break; } } if (proposedWindow == null) { // All variables are still set to defaults } // Force the step of 1, as our prepare chart will filter the X axis for valid separators, and will skip a few S = 1; Magnitude = Math.Pow(10, Math.Floor(Math.Log(supportedSeparatorCount) / Math.Log(10))); SelectedWindow = proposedWindow; return(separatorIndices); }
public void SetSelectedWindow(IAxisWindow window) { SetCurrentValue(SelectedWindowProperty, window); }