Esempio n. 1
0
        /// <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();
        }
Esempio n. 2
0
        /// <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();


                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;
                }

            }
        }