internal override void UpdateUICore(ChartLayoutContext context)
 {
     this.IsRendered = false;
     base.UpdateUICore(context);
     this.IsRendered = true;
     this.UpdateSeriesClip();
 }
Exemple #2
0
        private void UpdateTicks(ChartLayoutContext context)
        {
            int visibleTicks = 0;

            foreach (AxisTickModel tick in this.model.ticks)
            {
                if (!tick.isVisible)
                {
                    continue;
                }

                // the GetVisual method will update the UIElement's Visibility property
                FrameworkElement visual = this.GetTickVisual(tick, visibleTicks);
                this.TransformTick(tick, visual);
                this.ArrangeUIElement(visual, this.GetLayoutSlot(tick, context));

                visibleTicks++;
            }

            // remove unnecessary ticks
            while (visibleTicks < this.tickVisuals.Count)
            {
                this.tickVisuals[visibleTicks].Visibility = Visibility.Collapsed;
                visibleTicks++;
            }
        }
Exemple #3
0
        internal virtual ChartLayoutFlags GetLayoutFlags(ChartLayoutContext context)
        {
            // check whether last layout context is valid
            if (this.lastLayoutContext.AvailableSize == InfinitySize)
            {
                return(ChartLayoutFlags.Size);
            }

            ChartLayoutFlags flags = ChartLayoutFlags.None;

            if (this.lastLayoutContext.AvailableSize != context.AvailableSize)
            {
                flags |= ChartLayoutFlags.Size;
            }
            if (this.lastLayoutContext.Scale != context.Scale)
            {
                flags |= ChartLayoutFlags.Zoom;
            }
            if (this.lastLayoutContext.PlotOrigin != context.PlotOrigin)
            {
                flags |= ChartLayoutFlags.Pan;
            }

            return(flags);
        }
Exemple #4
0
        internal virtual void InvalidateCore()
        {
            this.lastLayoutContext = ChartLayoutContext.Invalid;

            // TODO: Check carefully for any performance impact
            this.isPaletteApplied = false;
        }
Exemple #5
0
        internal override void UpdateAxisLine(ChartLayoutContext context)
        {
            double antiAliasOffset = this.model.LineThickness % 2 == 1 ? 0.5 : 0;

            // update line points
            if (this.type == AxisType.First)
            {
                this.line.X1 = this.model.layoutSlot.X;
                this.line.X2 = this.model.layoutSlot.Right;
                if (this.model.VerticalLocation == AxisVerticalLocation.Bottom)
                {
                    this.line.Y1 = this.line.Y2 = this.model.layoutSlot.Y - antiAliasOffset;
                }
                else
                {
                    this.line.Y1 = this.line.Y2 = this.model.layoutSlot.Bottom - antiAliasOffset;
                }
            }
            else
            {
                this.line.Y1 = this.model.layoutSlot.Y;
                this.line.Y2 = this.model.layoutSlot.Bottom;

                if (this.model.HorizontalLocation == AxisHorizontalLocation.Left)
                {
                    this.line.X1 = this.line.X2 = this.model.layoutSlot.Right + antiAliasOffset;
                }
                else
                {
                    this.line.X1 = this.line.X2 = this.model.layoutSlot.X + antiAliasOffset;
                }
            }

            base.UpdateAxisLine(context);
        }
        internal override void OnPlotOriginChanged(ChartLayoutContext context)
        {
            base.OnPlotOriginChanged(context);

            this.UpdateVisuals();
            this.UpdateClip();
        }
Exemple #7
0
        /// <summary>
        /// Updates of all of the chart elements presented by this instance.
        /// </summary>
        internal override void UpdateUICore(ChartLayoutContext context)
        {
            base.UpdateUICore(context);

            // update the UI of each presenter
            foreach (UIElement child in this.renderSurface.Children)
            {
                PresenterBase presenter = child as PresenterBase;
                if (presenter != null)
                {
                    presenter.UpdateUI(context);
                }
            }

            // position the plot area decoraction
            RadRect plotAreaSlot = this.PlotAreaDecorationSlot;

            Canvas.SetLeft(this.plotAreaBackground, plotAreaSlot.X);
            Canvas.SetTop(this.plotAreaBackground, plotAreaSlot.Y);
            this.plotAreaBackground.Width  = plotAreaSlot.Width;
            this.plotAreaBackground.Height = plotAreaSlot.Height;

            this.adornerLayer.IsHitTestVisible = !context.IsEmpty;
            this.labelLayer.Opacity            = context.IsEmpty ? 0 : 1;

            this.StackedSeriesContext.Clear();
        }
        private void UpdatePresenters(ChartLayoutContext context)
        {
            int index = 0;
            ChartSeriesModel series = this.Model;

            if (this.chart.chartArea.IsTreeLoaded && (this.HasPointTemplate || this.SupportsDefaultVisuals))
            {
                foreach (DataPoint point in series.DataPointsInternal)
                {
                    // point is empty or is laid-out outside the clip area, skip it from visualization.
                    if (point.isEmpty || !context.ClipRect.IntersectsWith(point.layoutSlot))
                    {
                        continue;
                    }

                    FrameworkElement element = this.GetDataPointVisual(point, index);
                    if (element != null)
                    {
                        this.ArrangeUIElement(element, point.layoutSlot);
                        index++;
                    }
                }
            }

            while (index < this.realizedDataPointPresenters.Count)
            {
                var presenter = this.realizedDataPointPresenters[index];
                if (presenter.Visibility == Visibility.Visible)
                {
                    presenter.Visibility = Visibility.Collapsed;
                }
                index++;
            }
        }
Exemple #9
0
 internal virtual void UpdateAxisLine(ChartLayoutContext context)
 {
     if (!this.drawWithComposition)
     {
         // update stroke thickness
         this.line.StrokeThickness = this.model.LineThickness;
     }
 }
        /// <summary>
        /// Updates of all of the chart elements presented by this instance.
        /// </summary>
        internal override void UpdateUICore(ChartLayoutContext context)
        {
            if (this.renderSurface == null)
            {
                return;
            }
            base.UpdateUICore(context);

            this.UpdatePresenters(context);
        }
        /// <summary>
        /// Updates of all of the chart elements presented by this instance.
        /// </summary>
        internal override void UpdateUICore(ChartLayoutContext context)
        {
            base.UpdateUICore(context);

            this.majorXLines.Stripes = this.grid.xStripes;
            this.majorYLines.Stripes = this.grid.yStripes;

            this.UpdateVisuals();
            this.UpdateClip();
        }
Exemple #12
0
        /// <summary>
        /// Updates of all of the chart elements presented by this instance.
        /// </summary>
        internal override void UpdateUICore(ChartLayoutContext context)
        {
            base.UpdateUICore(context);

            if (this.renderSurface != null)
            {
                // create and arrange ticks, labels and axis line
                this.ArrangeVisuals(context);

                this.UpdateTitle();
            }
        }
Exemple #13
0
        internal override void OnPlotOriginChanged(ChartLayoutContext context)
        {
            base.OnPlotOriginChanged(context);

            if (this.chart.chartArea.plotArea.layoutSlot != this.lastPlotAreaRect)
            {
                this.UpdateUICore(context);
            }
            else
            {
                this.UpdateClip(context);
            }
        }
Exemple #14
0
        internal override void UpdateUICore(ChartLayoutContext context)
        {
            base.UpdateUICore(context);

            this.signalRenderer.Render(this.drawWithComposition);

            if (this.drawWithComposition && this.signalRenderer.renderPoints.Count > 2)
            {
                foreach (DataPointSegment dataSegment in ChartSeriesRenderer.GetDataSegments(this.signalRenderer.renderPoints))
                {
                    this.chart.ContainerVisualsFactory.PrepareLineRenderVisual(this.signalRendererVisual, this.signalRenderer.GetPoints(dataSegment), this.SignalStroke, this.StrokeThickness);
                }
            }
        }
        private void UpdatePresenters(ChartLayoutContext context)
        {
            int index = 0;
            ChartSeriesModel series = this.Model;

            if (this.HasPointTemplate || this.SupportsDefaultVisuals)
            {
                foreach (DataPoint point in series.DataPointsInternal)
                {
                    // point is laid-out outside the clip area, skip it from visualization
                    if (!context.ClipRect.IntersectsWith(point.layoutSlot))
                    {
                        continue;
                    }

                    if (this.drawWithComposition)
                    {
                        var containerVisual = this.GetContainerVisual(index);
                        this.chart.ContainerVisualsFactory.PrepareBarIndicatorVisual(containerVisual, point);
                        index++;
                    }
                    else
                    {
                        FrameworkElement element = this.GetDataPointVisual(point, index);
                        if (element != null)
                        {
                            this.ArrangeUIElement(element, point.layoutSlot);
                            index++;
                        }
                    }
                }
            }

            if (this.drawWithComposition)
            {
                while (index < this.realizedVisualDataPoints.Count)
                {
                    this.realizedVisualDataPoints[index].IsVisible = false;
                    index++;
                }
            }
            else
            {
                while (index < this.realizedDataPoints.Count)
                {
                    this.realizedDataPoints[index].Visibility = Visibility.Collapsed;
                    index++;
                }
            }
        }
Exemple #16
0
        private void UpdateLabels(ChartLayoutContext context)
        {
            double sineOrCosine = 0;

            if (this.model.labelFitMode == AxisLabelFitMode.Rotate)
            {
                double radiansByModulo = (this.normalizedRotationAngle % 90) * RadMath.DegToRadFactor;

                if (this.normalizedRotationAngle < 90 ||
                    (this.normalizedRotationAngle >= 180 && this.normalizedRotationAngle < 270))
                {
                    sineOrCosine = Math.Sin(radiansByModulo);
                }
                else
                {
                    sineOrCosine = Math.Cos(radiansByModulo);
                }
            }

            int visibleLabels = 0;

            foreach (AxisLabelModel label in this.model.labels)
            {
                if (!label.isVisible)
                {
                    continue;
                }

                // the GetVisual method will update the UIelement's Visibility property
                FrameworkElement visual     = this.GetLabelVisual(label, visibleLabels);
                RadRect          layoutSlot = this.GetLayoutSlot(label, context);

                if (this.model.labelFitMode == AxisLabelFitMode.Rotate)
                {
                    var margin      = visual.Margin;
                    var actualWidth = label.untransformedDesiredSize.Width - (margin.Left + margin.Right);
                    layoutSlot.Y += (int)(sineOrCosine * actualWidth / 2);
                }

                this.ArrangeUIElement(visual, layoutSlot, false);
                visibleLabels++;
            }

            // remove unnecessary ticks
            while (visibleLabels < this.labelVisuals.Count)
            {
                this.labelVisuals[visibleLabels].Visibility = Visibility.Collapsed;
                visibleLabels++;
            }
        }
Exemple #17
0
        internal virtual void UpdateClip(ChartLayoutContext context)
        {
            this.plotOriginTransform.X = context.PlotOrigin.X;
            this.plotOriginTransform.Y = context.PlotOrigin.Y;

            if (this.renderSurface != null)
            {
                this.chart.ApplyPlotAreaClip(this.renderSurface, this.ClipToPlotArea);
            }

            if (this.labelLayer != null)
            {
                this.chart.ApplyPlotAreaClip(this.labelLayer, this.ClipToPlotArea);
            }
        }
Exemple #18
0
        /// <summary>
        /// Updates of all of the chart elements presented by this instance.
        /// </summary>
        internal override void UpdateUICore(ChartLayoutContext context)
        {
            if (this.renderSurface == null)
            {
                return;
            }
            RadSize availableSize = new RadSize(
                this.chart.chartArea.layoutSlot.Width * this.chart.zoomCache.Width,
                this.chart.chartArea.layoutSlot.Height * this.chart.zoomCache.Height);

            this.updateContext = this.GetUpdateContext(availableSize);
            this.UpdateSegments();

            base.UpdateUICore(context);
        }
Exemple #19
0
        internal virtual RadRect GetLayoutSlot(Node node, ChartLayoutContext context)
        {
            RadRect layoutSlot = node.layoutSlot;

            if (this.type == AxisType.First)
            {
                layoutSlot.X += context.PlotOrigin.X;
            }
            else
            {
                layoutSlot.Y += context.PlotOrigin.Y;
            }

            return(layoutSlot);
        }
Exemple #20
0
        internal override void UpdateAxisLine(ChartLayoutContext context)
        {
            PolarChartAreaModel chartArea = this.chart.chartArea as PolarChartAreaModel;
            double   angle  = chartArea.NormalizeAngle(0);
            RadPoint center = chartArea.plotArea.layoutSlot.Center;
            RadPoint point  = RadMath.GetArcPoint(angle, center, chartArea.plotArea.layoutSlot.Width / 2);

            double antiAliasOffset = this.model.LineThickness % 2 == 1 ? 0.5 : 0;

            this.line.X1 = center.X;
            this.line.Y1 = center.Y - antiAliasOffset;
            this.line.X2 = point.X;
            this.line.Y2 = point.Y - antiAliasOffset;

            base.UpdateAxisLine(context);
        }
Exemple #21
0
        private void CallUpdateUI()
        {
            if (!this.IsTemplateApplied)
            {
                // the template may not be applied if the control is edited in Blend
                return;
            }

            this.UpdateChartArea();
            ChartLayoutContext context = new ChartLayoutContext(this.availableSize, this.zoomCache, this.PlotOrigin, this.PlotAreaClip)
            {
                IsEmpty = this.UpdateEmptyContent()
            };

            this.UpdateUI(context);
        }
Exemple #22
0
        internal override void UpdateUICore(ChartLayoutContext context)
        {
            if (this.Visibility == Visibility.Collapsed)
            {
                return;
            }

            base.UpdateUICore(context);

            if (this.model.CombineMode == ChartSeriesCombineMode.Stack ||
                this.model.CombineMode == ChartSeriesCombineMode.Stack100)
            {
                // pass our reference to next stacked series
                this.chart.StackedSeriesContext.PreviousStackedArea = this.areaRenderer.topSurfacePoints;
            }
        }
Exemple #23
0
        private void UpdateTicks(ChartLayoutContext context)
        {
            int visibleTicks = 0;

            foreach (AxisTickModel tick in this.model.ticks)
            {
                if (!tick.isVisible)
                {
                    continue;
                }

                if (this.drawWithComposition)
                {
                    var containerVisual = this.GetContainerVisual(visibleTicks);
                    this.chart.ContainerVisualsFactory.PrepareTickVisual(containerVisual, this.GetLayoutSlot(tick, context));

                    visibleTicks++;
                }
                else
                {
                    // the GetVisual method will update the UIElement's Visibility property
                    FrameworkElement visual = this.GetTickVisual(tick, visibleTicks);
                    this.TransformTick(tick, visual);
                    this.ArrangeUIElement(visual, this.GetLayoutSlot(tick, context));

                    visibleTicks++;
                }
            }

            // remove unnecessary ticks
            if (this.drawWithComposition)
            {
                while (visibleTicks < this.containerVisuals.Count)
                {
                    this.containerVisuals[visibleTicks].IsVisible = false;
                    visibleTicks++;
                }
            }
            else
            {
                while (visibleTicks < this.tickVisuals.Count)
                {
                    this.tickVisuals[visibleTicks].Visibility = Visibility.Collapsed;
                    visibleTicks++;
                }
            }
        }
Exemple #24
0
        /// <summary>
        /// Updates of all of the chart elements presented by this instance.
        /// </summary>
        internal override void UpdateUICore(ChartLayoutContext context)
        {
            base.UpdateUICore(context);

            // hide the series if for some reason the chart is not setup properly
            this.Opacity = context.IsEmpty ? 0 : 1;

            if (this.showLabelsCache && this.labelLayer == null)
            {
                this.labelLayer = this.chart.AddLabelLayer(this);
                this.labelLayer.RenderTransform = this.plotOriginTransform;
            }

            this.UpdateLabels(context);

            this.UpdateClip(context);
            this.lastPlotAreaRect = this.chart.chartArea.plotArea.layoutSlot;
        }
Exemple #25
0
        internal virtual void UpdateClip(ChartLayoutContext context)
        {
            if (this.renderSurface == null)
            {
                return;
            }

            if (this.ClipToPlotArea)
            {
                RadRect           clipArea = this.chart.chartArea.plotArea.layoutSlot;
                RectangleGeometry clip     = new RectangleGeometry();
                clip.Rect = new Rect(clipArea.X, clipArea.Y, clipArea.Width, clipArea.Height);
                this.renderSurface.Clip = clip;
            }
            else
            {
                this.renderSurface.Clip = null;
            }
        }
Exemple #26
0
        internal override void UpdateAxisLine(ChartLayoutContext context)
        {
            if (this.drawWithComposition && this.lineContainer != null)
            {
                this.chart.ContainerVisualsFactory.PrepareCartesianAxisLineVisual(this, this.lineContainer, this.model.layoutSlot, this.type);
            }
            else
            {
                double antiAliasOffset = this.model.LineThickness % 2 == 1 ? 0.5 : 0;

                // update line points
                if (this.type == AxisType.First)
                {
                    this.line.X1 = this.model.layoutSlot.X;
                    this.line.X2 = this.model.layoutSlot.Right;
                    if (this.model.VerticalLocation == AxisVerticalLocation.Bottom)
                    {
                        this.line.Y1 = this.line.Y2 = this.model.layoutSlot.Y - antiAliasOffset;
                    }
                    else
                    {
                        this.line.Y1 = this.line.Y2 = this.model.layoutSlot.Bottom - antiAliasOffset;
                    }
                }
                else
                {
                    this.line.Y1 = this.model.layoutSlot.Y;
                    this.line.Y2 = this.model.layoutSlot.Bottom;

                    if (this.model.HorizontalLocation == AxisHorizontalLocation.Left)
                    {
                        this.line.X1 = this.line.X2 = this.model.layoutSlot.Right + antiAliasOffset;
                    }
                    else
                    {
                        this.line.X1 = this.line.X2 = this.model.layoutSlot.X + antiAliasOffset;
                    }
                }
            }

            base.UpdateAxisLine(context);
        }
Exemple #27
0
        internal void Update(ChartLayoutContext context)
        {
            if (this.renderSurface == null)
            {
                this.isInvalidateRequired = true;
                return;
            }

            this.UpdateVisibility();
            if (this.Visibility == Visibility.Collapsed)
            {
                return;
            }

            if (this.Model.IsUpdated)
            {
                this.UpdatePresenters();
            }
            this.UpdateClip(context);
        }
Exemple #28
0
        internal void UpdateUI(ChartLayoutContext context)
        {
            context.Flags = this.GetLayoutFlags(context);

            if ((context.Flags & ChartLayoutFlags.Size) == ChartLayoutFlags.Size ||
                (context.Flags & ChartLayoutFlags.Zoom) == ChartLayoutFlags.Zoom)
            {
                this.UpdateUICore(context);
            }
            else if ((context.Flags & ChartLayoutFlags.Pan) == ChartLayoutFlags.Pan)
            {
                this.OnPlotOriginChanged(context);
            }

            // update the palette after UI has been updated
            this.isPaletteApplied = false;
            this.ApplyPalette();

            this.lastLayoutContext = context;
            this.OnUIUpdated();
        }
Exemple #29
0
        private void UpdateLabels(ChartLayoutContext context)
        {
            int index = 0;
            ChartSeriesModel series = this.Model;
            ChartSeriesLabelUpdateContext labelContext = new ChartSeriesLabelUpdateContext();

            labelContext.PlotDirection = this.Model.GetTypedValue <AxisPlotDirection>(AxisModel.PlotDirectionPropertyKey, AxisPlotDirection.Vertical);
            labelContext.IsPlotInverse = this.Model.GetIsPlotInverse(labelContext.PlotDirection);

            if (this.showLabelsCache)
            {
                foreach (DataPoint point in series.DataPointsInternal)
                {
                    // point is empty or is laid-out outside the clip area, skip it from visualization.
                    if (point.isEmpty || !context.ClipRect.IntersectsWith(point.layoutSlot))
                    {
                        continue;
                    }

                    labelContext.Point             = point;
                    labelContext.PointVirtualIndex = index;
                    this.ProcessDataPointLabels(labelContext);
                    index++;
                }
            }

            while (index < this.labels.Count)
            {
                List <FrameworkElement> pointLabels = this.labels[index].Value;
                foreach (FrameworkElement label in pointLabels)
                {
                    label.Visibility = Visibility.Collapsed;
                }
                index++;
            }
        }
Exemple #30
0
 internal override void OnPlotOriginChanged(ChartLayoutContext context)
 {
     // TODO: Possible optimizations
     this.UpdateUICore(context);
 }