Esempio n. 1
0
        /// <summary>
        /// Renders the labels.
        /// </summary>
        private void RenderLabels()
        {
            double aroundRadius = this.Radius + Math.Max(Axis.TickLineSize, 0);

            int pos = 0;


            foreach (ChartAxisLabel label in Axis.VisibleLabels)
            {
                double coef = this.Axis.ValueToPolarCoefficient(label.Position);

                FrameworkElement element = (FrameworkElement)contentControlRecycler[pos];

                Point vector       = ChartTransform.ValueToVector(this.Axis, label.Position);
                Point connectPoint = new Point(this.Center.X + aroundRadius * vector.X,
                                               this.Center.Y + aroundRadius * vector.Y);

                var labelwidth = ((element as UIElement).DesiredSize.Width) / 2;

                if (coef == 0.25d)
                {
                    connectPoint.X -= element.DesiredSize.Width;
                    connectPoint.Y -= element.DesiredSize.Height / 2;
                }
                else if (coef == 0.5d)
                {
                    connectPoint.X -= element.DesiredSize.Width / 2;
                }
                else if (coef == 0.75d)
                {
                    connectPoint.Y -= element.DesiredSize.Height / 2;
                }
                else if (coef == 1d || coef == 0d)
                {
                    connectPoint.X -= element.DesiredSize.Width / 2;
                    connectPoint.Y -= element.DesiredSize.Height;
                }
                else if (0 < coef && coef < 0.25d)
                {
                    connectPoint.X -= element.DesiredSize.Width;
                    connectPoint.Y -= element.DesiredSize.Height;
                }
                else if (0.25d < coef && coef < 0.5d)
                {
                    connectPoint.X -= element.DesiredSize.Width;
                }
                else if (0.75d < coef && coef < 1d)
                {
                    connectPoint.Y -= element.DesiredSize.Height;
                }

                // element.Arrange(new Rect(connectPoint, element.DesiredSize));
                Canvas.SetLeft(element, connectPoint.X);
                Canvas.SetTop(element, connectPoint.Y);
                pos++;
            }
        }
Esempio n. 2
0
            /// <summary>
            /// Transforms chart cordinates to real coordinates.
            /// </summary>
            /// <param name="x">The x value.</param>
            /// <param name="y">The y value.</param>
            /// <returns>The visible point</returns>
            public Point TransformToVisible(double x, double y)
            {
                x = x = x_IsLogarithmic && x > 0 ? Math.Log(x, xlogarithmicBase) : x;
                y = y_IsLogarithmic && y > 0 ? Math.Log(y, ylogarithmicBase) : y;

                double radius = m_radius * m_yAxis.ValueToCoefficient(y);
                Point  point  = ChartTransform.ValueToVector(m_xAxis, x);

                return(new Point(m_center.X + radius * point.X, m_center.Y + radius * point.Y));
            }
Esempio n. 3
0
        /// <summary>
        /// Renders the tick lines.
        /// </summary>
        private void RenderTicks()
        {
            Point  center = this.Center;
            double radius = this.Radius;
            int    pos    = 0;

            foreach (ChartAxisLabel label in Axis.VisibleLabels)
            {
                Point vector       = ChartTransform.ValueToVector(this.Axis, label.Position);
                Line  line         = lineRecycler[pos];
                Point connectPoint = new Point(center.X + radius * vector.X, center.Y + radius * vector.Y);
                line.X1 = connectPoint.X;
                line.Y1 = connectPoint.Y;
                line.X2 = connectPoint.X + Axis.TickLineSize * vector.X;
                line.Y2 = connectPoint.Y + Axis.TickLineSize * vector.Y;
                pos++;
            }
        }