コード例 #1
0
        public LabelEvaluation UpdateLabel(string text, AxisCore axis, AxisOrientation source)
        {
            TextBlock.Text = text;
            TextBlock.UpdateLayout();

            var transform = new LabelEvaluation(axis.View.LabelsRotation,
                                                TextBlock.ActualWidth, TextBlock.ActualHeight, axis, source);

            TextBlock.RenderTransform = Math.Abs(transform.LabelAngle) > 1
                ? new RotateTransform(transform.LabelAngle)
                : null;

            LabelModel = transform;

            return(transform);
        }
コード例 #2
0
        /// <summary>
        /// Updates the label.
        /// </summary>
        /// <param name="text">The text.</param>
        /// <param name="axis">The axis.</param>
        /// <param name="source">The source.</param>
        /// <returns></returns>
        public LabelEvaluation UpdateLabel(string text, AxisCore axis, AxisOrientation source)
        {
            TextBlock.Text = text;
            TextBlock.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));

            var transform = new LabelEvaluation(axis.View.LabelsRotation,
                                                TextBlock.DesiredSize.Width, TextBlock.DesiredSize.Height, axis, source);

            TextBlock.RenderTransform = Math.Abs(transform.LabelAngle) > 1
                ? new RotateTransform {
                Angle = transform.LabelAngle
            }
                : null;

            LabelModel = transform;

            return(transform);
        }
コード例 #3
0
        /// <summary>
        ///     Updates the label.
        /// </summary>
        /// <param name="text">The text.</param>
        /// <param name="axis">The axis.</param>
        /// <param name="source">The source.</param>
        /// <returns></returns>
        public LabelEvaluation UpdateLabel(string text, AxisCore axis, AxisOrientation source)
        {
            TextBlock.Text = text;

            var formattedText = new FormattedText(
                TextBlock.Text,
                CultureInfo.CurrentUICulture,
                FlowDirection.LeftToRight,
                new Typeface(TextBlock.FontFamily, TextBlock.FontStyle, TextBlock.FontWeight, TextBlock.FontStretch),
                TextBlock.FontSize, Brushes.Black);

            var transform = new LabelEvaluation(axis.View.LabelsRotation,
                                                formattedText.Width, formattedText.Height, axis, source);

            TextBlock.RenderTransform = Math.Abs(transform.LabelAngle) > 1
                ? new RotateTransform(transform.LabelAngle)
                : null;

            LabelModel = transform;

            return(transform);
        }
コード例 #4
0
        /// <summary>
        /// Updates the label.
        /// </summary>
        /// <param name="text">The text.</param>
        /// <param name="axis">The axis.</param>
        /// <param name="source">The source.</param>
        /// <returns></returns>
        public LabelEvaluation UpdateLabel(string text, AxisCore axis, AxisOrientation source)
        {
            TextBlock.Text = text;

            var formattedText = new FormattedText(
                  TextBlock.Text,
                  CultureInfo.CurrentUICulture,
                  FlowDirection.LeftToRight,
                  new Typeface(TextBlock.FontFamily, TextBlock.FontStyle, TextBlock.FontWeight, TextBlock.FontStretch),
                  TextBlock.FontSize, Brushes.Black);

            var transform = new LabelEvaluation(axis.View.LabelsRotation,
                formattedText.Width, formattedText.Height, axis, source);

            TextBlock.RenderTransform = Math.Abs(transform.LabelAngle) > 1
                ? new RotateTransform(transform.LabelAngle)
                : null;

            LabelModel = transform;

            return transform;
        }
コード例 #5
0
        public LabelEvaluation UpdateLabel(string text, AxisCore axis, AxisOrientation source)
        {
            TextBlock.Text = text;
            TextBlock.UpdateLayout();

            var transform = new LabelEvaluation(axis.View.LabelsRotation,
                TextBlock.ActualWidth, TextBlock.ActualHeight, axis, source);

            TextBlock.RenderTransform = Math.Abs(transform.LabelAngle) > 1
                ? new RotateTransform(transform.LabelAngle)
                : null;

            LabelModel = transform;

            return transform;
        }
コード例 #6
0
        private void PlaceLabel(string text, AxisCore axis, AxisOrientation source)
        {
            _label.Text = text;

            var formattedText = new FormattedText(
                _label.Text,
                CultureInfo.CurrentUICulture,
                FlowDirection.LeftToRight,
                new Typeface(_label.FontFamily, _label.FontStyle, _label.FontWeight, _label.FontStretch),
                _label.FontSize, Brushes.Black);

            var transform = new LabelEvaluation(axis.View.LabelsRotation,
                                                formattedText.Width + 10, formattedText.Height, axis, source);

            _label.RenderTransform = Math.Abs(transform.LabelAngle) > 1
                ? new RotateTransform(transform.LabelAngle)
                : null;

            var toLine = ChartFunctions.ToPlotArea(Value + SectionOffset + SectionWidth * .5, source, Model.Chart,
                                                   axis);

            var direction = source == AxisOrientation.X ? 1 : -1;

            toLine += axis.EvaluatesUnitWidth ? direction * ChartFunctions.GetUnitWidth(source, Model.Chart, axis) / 2 : 0;
            var toLabel = toLine + transform.GetOffsetBySource(source);

            var chart = Model.Chart;

            if (axis.IsMerged)
            {
                const double padding = 4;

                if (source == AxisOrientation.Y)
                {
                    if (toLabel + transform.ActualHeight >
                        chart.DrawMargin.Top + chart.DrawMargin.Height)
                    {
                        toLabel -= transform.ActualHeight + padding;
                    }
                }
                else
                {
                    if (toLabel + transform.ActualWidth >
                        chart.DrawMargin.Left + chart.DrawMargin.Width)
                    {
                        toLabel -= transform.ActualWidth + padding;
                    }
                }
            }

            var labelTab = axis.Tab;

            labelTab += transform.GetOffsetBySource(source.Invert());

            if (source == AxisOrientation.Y)
            {
                labelTab += 8 * (axis.Position == AxisPosition.LeftBottom ? 1 : -1);

                if (Model.View.DisableAnimations || DisableAnimations)
                {
                    Canvas.SetLeft(_label, labelTab);
                    Canvas.SetTop(_label, toLabel);
                    return;
                }

                _label.BeginAnimation(Canvas.TopProperty,
                                      new DoubleAnimation(toLabel, chart.View.AnimationsSpeed));
                _label.BeginAnimation(Canvas.LeftProperty,
                                      new DoubleAnimation(labelTab, chart.View.AnimationsSpeed));
            }
            else
            {
                if (Model.View.DisableAnimations || DisableAnimations)
                {
                    Canvas.SetLeft(_label, toLabel);
                    Canvas.SetTop(_label, labelTab);
                    return;
                }

                _label.BeginAnimation(Canvas.LeftProperty,
                                      new DoubleAnimation(toLabel, chart.View.AnimationsSpeed));
                _label.BeginAnimation(Canvas.TopProperty,
                                      new DoubleAnimation(labelTab, chart.View.AnimationsSpeed));
            }
        }
コード例 #7
0
ファイル: AxisSection.cs プロジェクト: Uwy/Live-Charts
        private void PlaceLabel(string text, AxisCore axis, AxisOrientation source)
        {
            _label.Text = text;

            _label.UpdateLayout();

            var transform = new LabelEvaluation(axis.View.LabelsRotation,
                                                _label.Width + 10, _label.Height, axis, source);

            _label.RenderTransform = Math.Abs(transform.LabelAngle) > 1
                ? new RotateTransform {
                Angle = transform.LabelAngle
            }
                : null;

            var toLine = ChartFunctions.ToPlotArea(Value, source, Model.Chart, axis);

            var direction = source == AxisOrientation.X ? 1 : -1;

            toLine += axis.EvaluatesUnitWidth ? direction * ChartFunctions.GetUnitWidth(source, Model.Chart, axis) / 2 : 0;
            var toLabel = toLine + transform.GetOffsetBySource(source);

            var chart = Model.Chart;

            if (axis.IsMerged)
            {
                const double padding = 4;

                if (source == AxisOrientation.Y)
                {
                    if (toLabel + transform.ActualHeight >
                        chart.DrawMargin.Top + chart.DrawMargin.Height)
                    {
                        toLabel -= transform.ActualHeight + padding;
                    }
                }
                else
                {
                    if (toLabel + transform.ActualWidth >
                        chart.DrawMargin.Left + chart.DrawMargin.Width)
                    {
                        toLabel -= transform.ActualWidth + padding;
                    }
                }
            }

            var labelTab = axis.Tab;

            labelTab += transform.GetOffsetBySource(source.Invert());

            if (source == AxisOrientation.Y)
            {
                if (Model.View.DisableAnimations || DisableAnimations)
                {
                    Canvas.SetLeft(_label, labelTab);
                    Canvas.SetTop(_label, toLabel);
                    return;
                }

                _label.BeginDoubleAnimation("Canvas.Top", toLabel, chart.View.AnimationsSpeed);
                _label.BeginDoubleAnimation("Canvas.Left", labelTab, chart.View.AnimationsSpeed);
            }
            else
            {
                if (Model.View.DisableAnimations || DisableAnimations)
                {
                    Canvas.SetLeft(_label, toLabel);
                    Canvas.SetTop(_label, labelTab);
                    return;
                }

                _label.BeginDoubleAnimation("Canvas.Left", toLabel, chart.View.AnimationsSpeed);
                _label.BeginDoubleAnimation("Canvas.Top", labelTab, chart.View.AnimationsSpeed);
            }
        }
コード例 #8
0
        /// <summary>
        /// Updates the label.
        /// </summary>
        /// <param name="text">The text.</param>
        /// <param name="axis">The axis.</param>
        /// <param name="source">The source.</param>
        /// <returns></returns>
        public LabelEvaluation UpdateLabel(string text, AxisCore axis, AxisOrientation source)
        {
            TextBlock.Text = text;
            TextBlock.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));

            var transform = new LabelEvaluation(axis.View.LabelsRotation,
                TextBlock.DesiredSize.Width, TextBlock.DesiredSize.Height, axis, source);

            TextBlock.RenderTransform = Math.Abs(transform.LabelAngle) > 1
                ? new RotateTransform {  Angle = transform.LabelAngle }
                : null;

            LabelModel = transform;

            return transform;
        }