/// <summary>
        /// Prepares the <see cref="ContainerVisual"/> used for the visualization of the Axis's Lines by setting its Size, Color and Offset.
        /// </summary>
        /// <param name="axis">The <see cref="CartesianAxis"/> that will be visualized.</param>
        /// <param name="lineContainer">The <see cref="ContainerVisual"/> that is used by the Composition API.</param>
        /// <param name="layoutSlot">A Rectangle in the Euclidean plane geometry used for the Size and Offset of the <see cref="ContainerVisual"/>.</param>
        /// <param name="axisType">The <see cref="AxisType"/> of the Axis's line.</param>
        protected internal virtual ContainerVisual PrepareCartesianAxisLineVisual(CartesianAxis axis, ContainerVisual lineContainer, RadRect layoutSlot, AxisType axisType = AxisType.First)
        {
            if (axisType == AxisType.First)
            {
                float antiAliasOffset = axis.model.LineThickness % 2 == 1 ? 0.5f : 0;

                lineContainer.Offset = axis.VerticalLocation == AxisVerticalLocation.Bottom
                    ? new Vector3((float)layoutSlot.Location.X, (float)layoutSlot.Location.Y - antiAliasOffset, 0)
                    : new Vector3((float)layoutSlot.Location.X, (float)layoutSlot.Bottom - antiAliasOffset, 0);

                if (lineContainer.Size.X != layoutSlot.Width || lineContainer.Size.Y != ((float)axis.model.LineThickness - antiAliasOffset))
                {
                    lineContainer.Size = new Vector2((float)layoutSlot.Width, (float)axis.model.LineThickness - antiAliasOffset);
                }
            }
            else
            {
                lineContainer.Offset = axis.HorizontalLocation == AxisHorizontalLocation.Left
                    ? new Vector3((float)layoutSlot.Right, (float)layoutSlot.Location.Y, 0)
                    : new Vector3((float)layoutSlot.X, (float)layoutSlot.Location.Y, 0);

                if (lineContainer.Size.X != axis.model.LineThickness || lineContainer.Size.Y != layoutSlot.Height)
                {
                    lineContainer.Size = new Vector2((float)axis.model.LineThickness, (float)layoutSlot.Height);
                }
            }

            this.ChangeBrushesAccordingToAppTheme();
            this.SetCompositionColorBrush(lineContainer, this.telerikChartAxisBorderBrush);

            return(lineContainer);
        }
示例#2
0
 /// <summary>
 /// Occurs when one of the axes of the owning <see cref="RadCartesianChart"/> has been changed.
 /// </summary>
 /// <param name="oldAxis">The old axis.</param>
 /// <param name="newAxis">The new axis.</param>
 internal void ChartAxisChanged(CartesianAxis oldAxis, CartesianAxis newAxis)
 {
     if (this.horizontalAxisCache == null)
     {
         if (oldAxis != null && oldAxis.type == AxisType.First)
         {
             this.AxisModel.DetachAxis(oldAxis.model);
         }
         if (newAxis != null && newAxis.type == AxisType.First)
         {
             this.AxisModel.AttachAxis(newAxis.model, AxisType.First);
         }
     }
     if (this.verticalAxisCache == null)
     {
         if (oldAxis != null && oldAxis.type == AxisType.Second)
         {
             this.AxisModel.DetachAxis(oldAxis.model);
         }
         if (newAxis != null && newAxis.type == AxisType.Second)
         {
             this.AxisModel.AttachAxis(newAxis.model, AxisType.Second);
         }
     }
 }
 internal override void ChartAxisChanged(CartesianAxis oldAxis, CartesianAxis newAxis)
 {
     base.ChartAxisChanged(oldAxis, newAxis);
     if (this.HorizontalAxis == null)
     {
         if (oldAxis != null && oldAxis.type == AxisType.First)
         {
             this.model.DetachAxis(oldAxis.model);
         }
         if (newAxis != null && newAxis.type == AxisType.First)
         {
             this.model.AttachAxis(newAxis.model, AxisType.First);
         }
     }
     if (this.VerticalAxis == null)
     {
         if (oldAxis != null && oldAxis.type == AxisType.Second)
         {
             this.model.DetachAxis(oldAxis.model);
         }
         if (newAxis != null && newAxis.type == AxisType.Second)
         {
             this.model.AttachAxis(newAxis.model, AxisType.Second);
         }
     }
 }
示例#4
0
 private void OnAxisChanged(CartesianAxis oldAxis, CartesianAxis newAxis)
 {
     foreach (var seriesItem in this.series)
     {
         seriesItem.ChartAxisChanged(oldAxis, newAxis);
     }
     foreach (var indicator in this.indicators)
     {
         indicator.ChartAxisChanged(oldAxis, newAxis);
     }
     foreach (var annotation in this.annotations)
     {
         annotation.ChartAxisChanged(oldAxis, newAxis);
     }
     if (oldAxis != null)
     {
         this.OnPresenterRemoved(oldAxis);
         oldAxis.model.isPrimary = false;
     }
     if (newAxis != null)
     {
         newAxis.model.isPrimary = true;
         this.OnPresenterAdded(newAxis);
     }
 }
示例#5
0
        private void OnAxisChanged(CartesianAxis oldAxis, CartesianAxis newAxis)
        {
            if (oldAxis != null)
            {
                this.RemoveAxisFromChart(oldAxis, this.chart, true);
                this.AxisModel.DetachAxis(oldAxis.model);
            }

            if (newAxis != null)
            {
                this.AddAxisToChart(newAxis, this.chart);
                this.AxisModel.AttachAxis(newAxis.model, newAxis.type);
            }

            if (oldAxis != null && newAxis == null)
            {
                RadCartesianChart cartesianChart = this.chart as RadCartesianChart;
                if (cartesianChart != null)
                {
                    if (oldAxis.type == AxisType.First && cartesianChart.HorizontalAxis != null)
                    {
                        this.AxisModel.AttachAxis(cartesianChart.HorizontalAxis.model, AxisType.First);
                    }
                    else if (oldAxis.type == AxisType.Second && cartesianChart.VerticalAxis != null)
                    {
                        this.AxisModel.AttachAxis(cartesianChart.VerticalAxis.model, AxisType.Second);
                    }
                }
            }
        }
示例#6
0
        private static void OnVerticalAxisChanged(DependencyObject target, DependencyPropertyChangedEventArgs args)
        {
            RadCartesianChart chart   = target as RadCartesianChart;
            CartesianAxis     oldAxis = args.OldValue as CartesianAxis;
            CartesianAxis     newAxis = args.NewValue as CartesianAxis;

            chart.verticalAxisCache = newAxis;
            if (chart.verticalAxisCache != null)
            {
                chart.verticalAxisCache.type = AxisType.Second;
            }

            chart.OnAxisChanged(oldAxis, newAxis);
        }
示例#7
0
        private static void OnVerticalAxisChanged(DependencyObject target, DependencyPropertyChangedEventArgs args)
        {
            CartesianSeries series  = target as CartesianSeries;
            CartesianAxis   oldAxis = args.OldValue as CartesianAxis;
            CartesianAxis   newAxis = args.NewValue as CartesianAxis;

            series.verticalAxisCache = newAxis;
            if (series.verticalAxisCache != null)
            {
                series.verticalAxisCache.type = AxisType.Second;
            }

            series.OnAxisChanged(oldAxis, newAxis);
        }
示例#8
0
 private void AddAxisToChart(CartesianAxis axis, RadChartBase chart)
 {
     if (chart == null)
     {
         this.unattachedAxes.Add(axis);
     }
     else
     {
         if (axis.chart == null)
         {
             chart.OnPresenterAdded(axis);
         }
         axis.linkedSeriesCount++;
     }
 }
示例#9
0
        private void RemoveAxisFromChart(CartesianAxis axis, RadChartBase chart, bool detachFromSeries)
        {
            if (chart == null)
            {
                this.unattachedAxes.Remove(axis);
            }
            else
            {
                if (axis.linkedSeriesCount == 1)
                {
                    chart.OnPresenterRemoved(axis);
                }
                axis.linkedSeriesCount--;
            }

            if (!detachFromSeries)
            {
                this.unattachedAxes.Add(axis);
            }
        }
示例#10
0
 internal virtual void ChartAxisChanged(CartesianAxis oldAxis, CartesianAxis newAxis)
 {
 }