private static ChartPanelHitTestResult HandleChartPanelHit(ChartPanel chartPanel, UIElement element, Point point) { return(new ChartPanelHitTestResult { ChartPanel = chartPanel, Visual = element, Position = point, }); }
/// <summary> /// Raises the <see cref="ChartElement.Updated"/> event. /// </summary> /// <remarks> /// <strong>Notes to Inheritors:</strong> When overriding <see cref="OnUpdate"/> in a /// derived class, be sure to call the base class's <see cref="OnUpdate"/> method so that /// registered delegates receive the event. /// </remarks> protected override void OnUpdate() { if (_background != null) { Rect bounds = ChartPanel.GetChartAreaBounds(XAxis, YAxis); _background.Margin = new Thickness(bounds.Left, bounds.Top, 0, 0); _background.Width = bounds.Width; _background.Height = bounds.Height; _background.HorizontalAlignment = HorizontalAlignment.Left; _background.VerticalAlignment = VerticalAlignment.Top; _background.Visibility = Visibility.Visible; } base.OnUpdate(); }
private static void OnYAxisChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs eventArgs) { if (eventArgs.OldValue == eventArgs.NewValue) { return; } // Synchronize the attached dependency property ChartPanel.YAxis with the dependency // property ChartElement.YAxis. Axis yAxis = (Axis)eventArgs.NewValue; ChartPanel.SetYAxis(dependencyObject, yAxis); // Call ChartElement.OnYAxisChanged to raise the Invalidated event. ((ChartElement)dependencyObject).OnYAxisChanged(eventArgs); }
protected FrameworkElement CreateDataPoint(object dataContext) { if (DataPointTemplate == null) { throw new ChartException("Cannot create data point. DataPointTemplate is not set."); } var marker = DataPointTemplate.LoadContent() as FrameworkElement; if (marker != null) { if (dataContext != null) { marker.DataContext = dataContext; } ChartPanel.SetIsDataPoint(marker, true); marker.SetBinding(StyleProperty, new Binding("DataPointStyle") { Source = this }); } return(marker); }
/// <summary> /// Raises the <see cref="ChartElement.Updated"/> event. /// </summary> /// <remarks> /// <strong>Notes to Inheritors:</strong> When overriding <see cref="OnUpdate"/> in a /// derived class, be sure to call the base class's <see cref="OnUpdate"/> method so that /// the base class <see cref="Chart"/> can update the data source if required. /// </remarks> protected override void OnUpdate() { base.OnUpdate(); // Updates the data source, if required. // Cleanup _lineRenderer.Clear(); _areaRenderer.Clear(); Debug.Assert(Canvas.Children.Count == 0, "Canvas should be cleared in base class."); Canvas.Children.Add(_areaPath); Canvas.Children.Add(_linePath); if (Data != null && Data.Count != 0) { // Clip filled area and lines to the chart area. Rect chartArea = ChartPanel.GetChartAreaBounds(XAxis, YAxis); // Allow line to draw on chart axes. Rect lineClipRect = new Rect(chartArea.Left - 2, chartArea.Top - 2, chartArea.Width + 4, chartArea.Height + 4); LineClipGeometry = new RectangleGeometry { Rect = lineClipRect }; // Keep area inside the chart area. Rect areaClipRect = chartArea; AreaClipGeometry = new RectangleGeometry { Rect = areaClipRect }; FindVisibleDataPoints(); CachePositions(); #if SILVERLIGHT OnUpdateLines(_startIndex, _endIndexExclusive, _xPositions, _basePositions, _yPositions); UpdateMarkers(); #else switch (RenderMode) { case ChartRenderMode.Quality: // Update lines and markers immediately. OnUpdateLines(_startIndex, _endIndexExclusive, _xPositions, _basePositions, _yPositions); UpdateMarkers(); break; case ChartRenderMode.Performance: // Immediately update lines. OnUpdateLines(_startIndex, _endIndexExclusive, _xPositions, _basePositions, _yPositions); // Temporarily disable bitmap cache and anti-aliasing. // Update markers when application is idle. if (!_updatePending) { _updatePending = true; ClearCacheMode(); ClearEdgeMode(); ChartHelper.Defer(Dispatcher, () => { if (_updatePending) { _updatePending = false; UpdateMarkers(); RestoreCacheMode(); RestoreEdgeMode(); } }); } break; case ChartRenderMode.DoNotRender: // Do nothing. break; } #endif } }
private static ChartPanelHitTestResult HandleChartPanelHit(ChartPanel chartPanel, UIElement element, Point point) { return new ChartPanelHitTestResult { ChartPanel = chartPanel, Visual = element, Position = point, }; }