private void DoDrawMayorLabels() { additionalLabelsCanvas.Children.Clear(); ITicksProvider <T> mayorTicksProvider = ticksProvider.MayorProvider; if (mayorTicksProvider != null && MayorLabelProvider != null) { Size renderSize = RenderSize; var mayorTicks = mayorTicksProvider.GetTicks(range, DefaultTicksProvider.DefaultTicksCount); double[] screenCoords = mayorTicks.Ticks.Select(tick => createDataPoint(convertToDouble(tick))). Select(p => p.DataToScreen(transform)).Select(p => getCoordinate(p)).ToArray(); // todo this is not the best decision - when displaying, for example, // milliseconds, it causes to create hundreds and thousands of textBlocks. double rangesRatio = GetRangesRatio(mayorTicks.Ticks.GetPairs().ToArray()[0], range); object info = mayorTicks.Info; MayorLabelsInfo newInfo = new MayorLabelsInfo { Info = info, MayorLabelsCount = (int)Math.Ceiling(rangesRatio) }; var newMayorTicks = new TicksInfo <T> { Info = newInfo, Ticks = mayorTicks.Ticks, TickSizes = mayorTicks.TickSizes }; UIElement[] additionalLabels = MayorLabelProvider.CreateLabels(newMayorTicks); for (int i = 0; i < additionalLabels.Length; i++) { if (screenCoords[i].IsNaN()) { continue; } UIElement tickLabel = additionalLabels[i]; tickLabel.Measure(renderSize); StackCanvas.SetCoordinate(tickLabel, screenCoords[i]); StackCanvas.SetEndCoordinate(tickLabel, screenCoords[i + 1]); if (tickLabel is FrameworkElement) { ((FrameworkElement)tickLabel).LayoutTransform = additionalLabelTransform; } additionalLabelsCanvas.Children.Add(tickLabel); } } }
private void DoDrawMayorLabels() { AdditionalLabelsCanvas.Children.Clear(); ITicksProvider <T> mayorTicksProvider = ticksProvider.MayorProvider; if (mayorTicksProvider != null && MayorLabelProvider != null) { Size renderSize = RenderSize; //if (renderSize.Width == 0 || renderSize.Height == 0) return; var mayorTicks = mayorTicksProvider.GetTicks(range, DefaultTicksProvider.DefaultTicksCount); double[] screenCoords = mayorTicks.Ticks.Select(tick => createDataPoint(convertToDouble(tick))). Select(p => p.DataToScreen(transform)).Select(p => getCoordinate(p)).ToArray(); int expectedMayorLabelsCount = mayorTicks.Ticks.Length; // todo this is not the best decision - when displaying, for example, // milliseconds, it causes to create hundreds and thousands of textBlocks. double rangesRatio = GetRangesRatio(mayorTicks.Ticks.GetPairs().ToArray()[0], range); object info = mayorTicks.Info; MayorLabelsInfo newInfo = new MayorLabelsInfo { Info = info, MayorLabelsCount = (int)Math.Ceiling(rangesRatio) }; var newMayorTicks = new TicksInfo <T> { Info = newInfo, Ticks = mayorTicks.Ticks, TickSizes = mayorTicks.TickSizes }; IEnumerable <FrameworkElement> additionalLabels = MayorLabelProvider.CreateLabels(newMayorTicks); int i = 0; foreach (FrameworkElement fe in additionalLabels) { fe.Measure(renderSize); StackCanvas.SetCoordinate(fe, screenCoords[i]); if (i + 1 < screenCoords.Length) { StackCanvas.SetEndCoordinate(fe, screenCoords[i + 1]); } AdditionalLabelsCanvas.Children.Add(fe); i++; } } }