Beispiel #1
0
        private void SeriesItemTemplateApplied(object sender, DependencyObject root, int index)
        {
            if (root == null)
            {
                return;
            }

            var sr = root as SeriesControl;

            if (sr == null)
            {
                MvvmChartException.ThrowDataTemplateRootElementException(nameof(this.SeriesTemplate), typeof(SeriesControl));
            }

            sr.Owner = this;

            sr.XRangeChanged += Sr_XValueRangeChanged;
            sr.YRangeChanged += Sr_YValueRangeChanged;

            sr.OnPlottingXValueRangeChanged(this.XPlottingRange);
            sr.OnPlottingYValueRangeChanged(this.YPlottingRange);

            //sr.UpdateValueRange();
            ((SeriesControl)sr).Refresh();
        }
Beispiel #2
0
        protected virtual void ScatterItemsControlScatterGenerated(object sender, FrameworkElement root, int index)
        {
            var scatter = root as Scatter;

            if (scatter == null)
            {
                MvvmChartException.ThrowDataTemplateRootElementException(nameof(this.ScatterTemplate), typeof(Scatter));
            }



            if (this.ScatterBrush != null && scatter.Fill == null)
            {
                scatter.SetCurrentValue(Scatter.FillProperty, this.ScatterBrush);
            }

            var item = scatter.DataContext;

            if (!this.Owner.SeriesControlOwner.IsSeriesCollectionChanging)
            {
                if (!this.Owner.XPixelPerUnit.IsNaN() && !this.Owner.YPixelPerUnit.IsNaN())
                {
                    scatter.Coordinate = this.Owner.GetPlotCoordinateForItem(item, index);
                }
            }
        }
        private void SeriesItemTemplateApplied(object sender, DependencyObject root, int index)
        {
            if (root == null)
            {
                return;
            }

            var sr = root as SeriesControl;

            if (sr == null)
            {
                MvvmChartException.ThrowDataTemplateRootElementException("SeriesTemplate", typeof(SeriesControl));
            }

            sr.Owner = this;

            sr.ValueRangeChanged += Sr_ValueRangeChanged;

            sr.RecalculateCoordinate();

            if (this.StackMode == StackMode.NotStacked)
            {
                sr.UpdateValueRange();
                sr.Refresh();
            }
        }
Beispiel #4
0
        protected virtual void BarItemsControlBarGenerated(object sender, FrameworkElement child, int childIndex)
        {
            var barItem = child as BarItem;

            if (barItem == null)
            {
                MvvmChartException.ThrowDataTemplateRootElementException(nameof(this.BarItemTemplate), typeof(BarItem));
            }

            if (this.BarBrush != null && barItem.Fill == null)
            {
                barItem.SetCurrentValue(BarItem.FillProperty, this.BarBrush);
            }

            if (this.BarBorderBrush != null && barItem.Stroke == null)
            {
                barItem.SetCurrentValue(BarItem.StrokeProperty, this.BarBorderBrush);
            }

            if (!this.BarBorderThickness.IsNaN() && barItem.StrokeThickness.IsNaN())
            {
                barItem.SetCurrentValue(BarItem.StrokeThicknessProperty, this.BarBorderThickness);
            }

            if (this.BarStyle != null && barItem.Style == null)
            {
                barItem.SetCurrentValue(BarItem.StyleProperty, this.BarStyle);
            }

            if (!this.Owner.SeriesControlOwner.IsSeriesCollectionChanging)
            {
                if (!this.Owner.XPixelPerUnit.IsNaN() && !this.Owner.YPixelPerUnit.IsNaN())
                {
                    var privousCoordinates = this.Owner.GetPreviousSeriesCoordinates(false);

                    var item       = barItem.DataContext;
                    var coordinate = this.Owner.GetPlotCoordinateForItem(item, childIndex);

                    var barHeight = privousCoordinates == null
                        ? coordinate.Y
                        : coordinate.Y - privousCoordinates[childIndex].Y;

                    if (!this.BarWidth.IsNaN() && barItem.Width.IsInvalid())
                    {
                        barItem.SetCurrentValue(BarItem.WidthProperty, this.BarWidth);
                    }

                    barItem.SetBarHeight(barHeight);
                    barItem.Coordinate = coordinate;
                }
            }
        }