Esempio n. 1
0
        /// <summary>
        /// Updates this instance.
        /// </summary>
        internal void Update()
        {
            double desiredWidth = 0;

            CalculateAutoInterval();
            GenerateLabels();
            if (this.ActualHeight > 0 && this.ActualWidth > 0)
            {
                double yAxisHeightStep     = this.ActualHeight / ((MIntervalCount > 0) ? MIntervalCount : 1);
                double yAxisHeightPosition = 0;
                Rect   oldRect             = new Rect(0, 0, 0, 0);
                AxisLine.X1 = this.ActualWidth;
                AxisLine.X2 = this.ActualWidth;
                AxisLine.Y1 = 0;
                AxisLine.Y2 = this.ActualHeight;
                Binding binding = new Binding();
                binding.Path   = new PropertyPath("AxisLineStyle");
                binding.Source = this;
                AxisLine.SetBinding(Line.StyleProperty, binding);
                double labelSize  = 0;
                int    minorCount = 0;
                if (this.MLabels.Count == Labels.Count)
                {
                    for (int i = this.MLabels.Count - 1; i >= 0; i--)
                    {
                        yAxisHeightPosition = this.DataToPoint(MLabelValues[i]);
                        ContentControl label = Labels[i];
                        label.Content = MLabels[i];
                        label.Measure(new Size(this.ActualHeight, this.ActualWidth));
                        RotateTransform labelRotation = new RotateTransform();
                        labelRotation.Angle = LabelAngle;
                        Rect rotatedRect = GetRotatedRect(new Rect(0, 0, label.DesiredSize.Width, label.DesiredSize.Height), labelRotation);
                        label.RenderTransform = labelRotation;
                        Line   tickLine     = MajorTickLines[i];
                        double labelPadding = 0;
                        tickLine.Measure(new Size(this.ActualHeight, this.ActualWidth));
                        //tickLine.X1 = this.ActualWidth;
                        tickLine.Y1 = yAxisHeightPosition;
                        tickLine.Y2 = yAxisHeightPosition;
                        //tickLine.X2 = tickLine.X1 - MajorLineSize;
                        switch (MajorTicksPosition)
                        {
                        case TickPosition.Inside:
                            tickLine.X1 = this.ActualWidth;
                            tickLine.X2 = tickLine.X1 + MajorLineSize;
                            if (this.ShowMajorTicks)
                            {
                                labelPadding = 0;
                                desiredWidth = 0;
                            }
                            break;

                        case TickPosition.Cross:
                            tickLine.X1 = this.ActualWidth - (MajorLineSize / 2);
                            tickLine.X2 = this.ActualWidth + (MajorLineSize / 2);
                            if (this.ShowMajorTicks)
                            {
                                labelPadding = tickLine.X2;
                                desiredWidth = this.MajorLineSize / 2;
                            }
                            break;

                        case TickPosition.Outside:
                            tickLine.X1 = this.ActualWidth;
                            tickLine.X2 = tickLine.X1 - MajorLineSize;
                            if (this.ShowMajorTicks)
                            {
                                labelPadding = tickLine.X2;
                                desiredWidth = this.MajorLineSize;
                            }
                            break;

                        default:
                            break;
                        }
                        //desiredWidth = 0;
                        if (i != 0)
                        {
                            double minorWidth = yAxisHeightStep;
                            double minorstep  = minorWidth / (MinorTicksCount + 1);
                            for (int j = 0; j < this.MinorTicksCount; j++)
                            {
                                Line minorLine = MinorTickLines[minorCount];
                                minorLine.Y1 = (yAxisHeightPosition + minorstep * (j + 1));
                                minorLine.Y2 = (yAxisHeightPosition + minorstep * (j + 1));
                                //minorLine.X1 = this.ActualWidth - (minorLine.StrokeThickness);
                                // minorLine.X2 = minorLine.X1 - MinorLineSize;
                                switch (MinorTicksPosition)
                                {
                                case TickPosition.Inside:
                                    minorLine.X1 = this.ActualWidth;
                                    minorLine.X2 = minorLine.X1 + MinorLineSize;
                                    break;

                                case TickPosition.Cross:
                                    minorLine.X1 = this.ActualWidth - (MinorLineSize / 2);
                                    minorLine.X2 = this.ActualWidth + (MinorLineSize / 2);
                                    break;

                                case TickPosition.Outside:
                                    minorLine.X1 = this.ActualWidth;
                                    minorLine.X2 = minorLine.X1 - MinorLineSize;
                                    break;

                                default:
                                    break;
                                }
                                minorCount++;
                            }
                        }

                        if (this.LabelAngle == 0)
                        {
                            Canvas.SetLeft(label, this.ActualWidth - (label.DesiredSize.Width) - desiredWidth - 1);
                            Canvas.SetTop(label, yAxisHeightPosition - (label.DesiredSize.Height / 2));
                            labelSize = Math.Max(labelSize, label.DesiredSize.Width);
                        }
                        else
                        {
                            Canvas.SetLeft(label, this.ActualWidth - (rotatedRect.Width) - rotatedRect.X - desiredWidth - 1);
                            Canvas.SetTop(label, yAxisHeightPosition - (rotatedRect.Height / 2) - rotatedRect.Y);
                            labelSize = Math.Max(labelSize, rotatedRect.Width);
                        }
                    }
                }
                else
                {
                    if (this.MLabels.Count > Labels.Count)
                    {
                        int offset = this.MLabels.Count - Labels.Count;
                        for (int j = 0; j < offset; j++)
                        {
                            ContentControl label = new ContentControl();
                            label.Content = MLabels[this.MLabels.Count - offset - 1];
                            //label.ContentTemplate = this.LabelTemplate;
                            Binding labelTemplateBinding = new Binding();
                            labelTemplateBinding.Path   = new PropertyPath("LabelTemplate");
                            labelTemplateBinding.Source = this;
                            label.SetBinding(ContentControl.ContentTemplateProperty, labelTemplateBinding);
                            label.Measure(new Size(this.ActualHeight, this.ActualWidth));
                            RotateTransform labelRotation = new RotateTransform();
                            labelRotation.Angle = LabelAngle;
                            Rect rotatedRect = GetRotatedRect(new Rect(0, 0, label.DesiredSize.Width, label.DesiredSize.Height), labelRotation);
                            label.RenderTransform = labelRotation;
                            Labels.Add(label);
                            Line    tickLine     = new Line();
                            Binding styleBinding = new Binding();
                            styleBinding.Path   = new PropertyPath("MajorLineStyle");
                            styleBinding.Source = this;
                            tickLine.SetBinding(Line.StyleProperty, styleBinding);
                            tickLine.Measure(new Size(this.ActualHeight, this.ActualWidth));
                            tickLine.Y1 = yAxisHeightPosition;
                            tickLine.Y2 = yAxisHeightPosition;
                            //tickLine.X2 = tickLine.X1 - MajorLineSize;
                            switch (MajorTicksPosition)
                            {
                            case TickPosition.Inside:
                                tickLine.X1 = this.ActualWidth;
                                tickLine.X2 = tickLine.X1 + MajorLineSize;
                                break;

                            case TickPosition.Cross:
                                tickLine.X1 = this.ActualWidth - (MajorLineSize / 2);
                                tickLine.X2 = this.ActualWidth + (MajorLineSize / 2);
                                break;

                            case TickPosition.Outside:
                                tickLine.X1 = this.ActualWidth;
                                tickLine.X2 = tickLine.X1 - MajorLineSize;
                                break;

                            default:
                                break;
                            }
                            //Binding tickSizeBinding = new Binding();
                            //tickSizeBinding.Path = new PropertyPath("MajorLineSize");
                            //tickSizeBinding.Source = this;
                            //tickSizeBinding.Converter = new MajorSizeThicknessConverter();
                            //tickSizeBinding.ConverterParameter = tickLine.X1;
                            //tickLine.SetBinding(Line.X2Property, tickSizeBinding);
                            Binding ticklineVisibilityBinding = new Binding();
                            ticklineVisibilityBinding.Path      = new PropertyPath("ShowMajorTicks");
                            ticklineVisibilityBinding.Source    = this;
                            ticklineVisibilityBinding.Converter = new BooleanToVisibilityConverter();
                            tickLine.SetBinding(Line.VisibilityProperty, ticklineVisibilityBinding);
                            double minorWidth = yAxisHeightStep;
                            double minorstep  = minorWidth / (MinorTicksCount + 1);
                            for (int k = 0; k < this.MinorTicksCount; j++)
                            {
                                Line    minorLine         = new Line();
                                Binding minorstyleBinding = new Binding();
                                minorstyleBinding.Path   = new PropertyPath("MinorLineStyle");
                                minorstyleBinding.Source = this;
                                minorLine.SetBinding(Line.StyleProperty, minorstyleBinding);
                                minorLine.Measure(new Size(this.ActualHeight, this.ActualWidth));
                                minorLine.Y1 = (yAxisHeightPosition + minorstep * (j + 1));
                                minorLine.Y2 = (yAxisHeightPosition + minorstep * (j + 1));
                                switch (MinorTicksPosition)
                                {
                                case TickPosition.Inside:
                                    minorLine.X1 = this.ActualWidth;
                                    minorLine.X2 = minorLine.X1 + MinorLineSize;
                                    break;

                                case TickPosition.Cross:
                                    minorLine.X1 = this.ActualWidth - (MinorLineSize / 2);
                                    minorLine.X2 = this.ActualWidth + (MinorLineSize / 2);
                                    break;

                                case TickPosition.Outside:
                                    minorLine.X1 = this.ActualWidth;
                                    minorLine.X2 = minorLine.X1 - MinorLineSize;
                                    break;

                                default:
                                    break;
                                }
                                MinorTickLines.Add(minorLine);
                                this.Children.Add(minorLine);
                            }
                            this.Children.Add(label);
                            MajorTickLines.Add(tickLine);
                            this.Children.Add(tickLine);
                        }
                    }
                    else
                    {
                        int offset = Labels.Count - this.MLabels.Count;
                        for (int j = 0; j < offset; j++)
                        {
                            this.Children.Remove(Labels[Labels.Count - 1]);
                            Labels.RemoveAt(Labels.Count - 1);
                            for (int k = 0; k < this.MinorTicksCount; k++)
                            {
                                this.Children.Remove(MinorTickLines[MinorTickLines.Count - 1]);
                                MinorTickLines.RemoveAt(MinorTickLines.Count - 1);
                            }
                            this.Children.Remove(MajorTickLines[MajorTickLines.Count - 1]);
                            MajorTickLines.RemoveAt(MajorTickLines.Count - 1);
                        }
                    }
                    for (int i = this.MLabels.Count - 1; i >= 0; i--)
                    {
                        ContentControl label = Labels[i];
                        label.Content = MLabels[i];
                        label.Measure(new Size(this.ActualHeight, this.ActualWidth));
                        RotateTransform labelRotation = new RotateTransform();
                        labelRotation.Angle = LabelAngle;
                        Rect rotatedRect = GetRotatedRect(new Rect(0, 0, label.DesiredSize.Width, label.DesiredSize.Height), labelRotation);
                        label.RenderTransform = labelRotation;
                        Line   tickLine     = MajorTickLines[i];
                        double labelPadding = 0;

                        tickLine.Y1 = yAxisHeightPosition;
                        tickLine.Y2 = yAxisHeightPosition;
                        switch (MajorTicksPosition)
                        {
                        case TickPosition.Inside:
                            tickLine.X1 = this.ActualWidth;
                            tickLine.X2 = tickLine.X1 + MajorLineSize;
                            if (this.ShowMajorTicks)
                            {
                                labelPadding = 0;
                                desiredWidth = 0;
                            }
                            break;

                        case TickPosition.Cross:
                            tickLine.X1 = this.ActualWidth - (MajorLineSize / 2);
                            tickLine.X2 = this.ActualWidth + (MajorLineSize / 2);
                            if (this.ShowMajorTicks)
                            {
                                labelPadding = tickLine.X2;
                                desiredWidth = this.MajorLineSize / 2;
                            }
                            break;

                        case TickPosition.Outside:
                            tickLine.X1 = this.ActualWidth;
                            tickLine.X2 = tickLine.X1 - MajorLineSize;
                            if (this.ShowMajorTicks)
                            {
                                labelPadding = tickLine.X2;
                                desiredWidth = this.MajorLineSize;
                            }
                            break;

                        default:
                            break;
                        }
                        tickLine.Measure(new Size(this.ActualHeight, this.ActualWidth));
                        //desiredWidth = 0;
                        double minorstep = 0;
                        if (!(i == 0))
                        {
                            double minorWidth = yAxisHeightStep;
                            minorstep = minorWidth / (MinorTicksCount + 1);
                            for (int j = 0; j < this.MinorTicksCount; j++)
                            {
                                Line minorLine = MinorTickLines[minorCount];
                                minorLine.Y1 = (yAxisHeightPosition + minorstep * (j + 1));
                                minorLine.Y2 = (yAxisHeightPosition + minorstep * (j + 1));
                                //minorLine.X1 = this.ActualWidth - (minorLine.StrokeThickness);
                                //minorLine.X2 = minorLine.X1 - MinorLineSize;
                                switch (MinorTicksPosition)
                                {
                                case TickPosition.Inside:
                                    minorLine.X1 = this.ActualWidth;
                                    minorLine.X2 = minorLine.X1 + MinorLineSize;
                                    break;

                                case TickPosition.Cross:
                                    minorLine.X1 = this.ActualWidth - (MinorLineSize / 2);
                                    minorLine.X2 = this.ActualWidth + (MinorLineSize / 2);
                                    break;

                                case TickPosition.Outside:
                                    minorLine.X1 = this.ActualWidth;
                                    minorLine.X2 = minorLine.X1 - MinorLineSize;
                                    break;

                                default:
                                    break;
                                }
                                minorCount++;
                            }
                        }

                        if (this.LabelAngle == 0)
                        {
                            Canvas.SetLeft(label, this.ActualWidth - (label.DesiredSize.Width) - desiredWidth - 1);
                            Canvas.SetTop(label, yAxisHeightPosition - (label.DesiredSize.Height / 2));
                            labelSize = Math.Max(labelSize, label.DesiredSize.Width);
                        }
                        else
                        {
                            Canvas.SetLeft(label, this.ActualWidth - (rotatedRect.Width - rotatedRect.X) - desiredWidth - 1);
                            Canvas.SetTop(label, yAxisHeightPosition - (rotatedRect.Height / 2) - rotatedRect.Y);
                            labelSize = Math.Max(labelSize, rotatedRect.Width);
                        }
                        yAxisHeightPosition += yAxisHeightStep;
                        //desiredWidth = desiredWidth + labelSize;
                    }
                }
                header.Measure(new Size(this.ActualHeight, this.ActualWidth));
                Canvas.SetLeft(header, this.ActualWidth - labelSize - header.DesiredSize.Height - this.MajorLineSize - 1);
                Canvas.SetTop(header, this.ActualHeight / 2);
                desiredWidth = desiredWidth + header.DesiredSize.Height + labelSize;
            }
            if (this.Chart.AxisWidth < desiredWidth)
            {
                this.Chart.AxisWidth = desiredWidth + 1;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Updates this instance.
        /// </summary>
        internal void Update()
        {
            double desiredHeight = 0;
            double labelSize     = 0;

            CalculateAutoInterval();
            GenerateLabels();
            if (this.ActualHeight > 0 && this.ActualWidth > 0)
            {
                double xAxisWidthStep     = this.ActualWidth / ((MIntervalCount > 0) ? MIntervalCount : 1);
                double xAxisWidthPosition = 0;
                double minorstep          = 0;
                AxisLine.X2 = this.ActualWidth;
                Rect oldRect = new Rect(0, 0, 0, 0);

                if (this.MLabels.Count == Labels.Count)
                {
                    int k          = 0;
                    int minorCount = 0;
                    for (int i = 0; i < this.MLabels.Count; i++)
                    {
                        xAxisWidthPosition = this.DataToPoint(MStartValue + (MInterval * k));
                        ContentControl label = Labels[k];
                        label.Content = MLabels[k];
                        label.Measure(new Size(this.ActualHeight, this.ActualWidth));
                        RotateTransform labelRotation = new RotateTransform();
                        labelRotation.Angle = LabelAngle;
                        Rect originalRect = new Rect(0, 0, label.DesiredSize.Width, label.DesiredSize.Height);

                        Rect rotatedRect = GetRotatedRect(originalRect, labelRotation);
                        //label.RenderTransformOrigin = new Point(0.5, 0.5);
                        label.RenderTransform = labelRotation;
                        Line   tickLine     = MajorTickLines[k];
                        double labelPadding = 0;
                        tickLine.Measure(new Size(this.ActualHeight, this.ActualWidth));
                        tickLine.X1 = xAxisWidthPosition;
                        tickLine.X2 = xAxisWidthPosition;
                        switch (MajorTicksPosition)
                        {
                        case TickPosition.Inside:
                            if (this.ShowMajorTicks)
                            {
                                labelPadding  = 0;
                                desiredHeight = 0;
                            }
                            break;

                        case TickPosition.Cross:
                            if (this.ShowMajorTicks)
                            {
                                labelPadding  = tickLine.Y2;
                                desiredHeight = tickLine.Y2;
                            }
                            break;

                        case TickPosition.Outside:
                            if (this.ShowMajorTicks)
                            {
                                labelPadding  = tickLine.Y2;
                                desiredHeight = tickLine.Y2;
                            }
                            break;

                        default:
                            break;
                        }
                        if (!(i == this.MLabels.Count - 1))
                        {
                            double minorWidth = xAxisWidthStep;
                            minorstep = minorWidth / (MinorTicksCount + 1);
                            for (int j = 0; j < this.MinorTicksCount; j++)
                            {
                                Line minorLine = MinorTickLines[minorCount];
                                minorLine.X1 = (xAxisWidthPosition + minorstep * (j + 1));
                                minorLine.X2 = (xAxisWidthPosition + minorstep * (j + 1));
                                switch (MinorTicksPosition)
                                {
                                case TickPosition.Inside:
                                    minorLine.Y1 = 0;
                                    break;

                                case TickPosition.Cross:
                                    //minorLine.Y1 = MinorLineSize / 2;
                                    break;

                                case TickPosition.Outside:
                                    minorLine.Y1 = 0;
                                    break;

                                default:
                                    break;
                                }

                                minorCount++;
                            }
                        }

                        //Canvas.SetLeft(label, xAxisWidthPosition - (label.DesiredSize.Width / 2));
                        //Canvas.SetTop(label, desiredHeight);
                        if (this.LabelAngle == 0)
                        {
                            Canvas.SetLeft(label, xAxisWidthPosition - (label.DesiredSize.Width / 2));
                            Canvas.SetTop(label, desiredHeight);
                            labelSize = Math.Max(labelSize, label.DesiredSize.Height);
                        }
                        else
                        {
                            Canvas.SetLeft(label, xAxisWidthPosition - (rotatedRect.Width / 2) - rotatedRect.X);
                            Canvas.SetTop(label, desiredHeight - rotatedRect.Y);
                            labelSize = Math.Max(labelSize, rotatedRect.Height);
                        }
                        k++;
                    }
                }
                else
                {
                    if (this.MLabels.Count > Labels.Count)
                    {
                        int offset = this.MLabels.Count - Labels.Count;
                        for (int j = 0; j < offset; j++)
                        {
                            ContentControl label = new ContentControl();
                            label.Content = MLabels[this.MLabels.Count - offset - 1];
                            Binding labelTemplateBinding = new Binding();
                            labelTemplateBinding.Path   = new PropertyPath("LabelTemplate");
                            labelTemplateBinding.Source = this;
                            label.SetBinding(ContentControl.ContentTemplateProperty, labelTemplateBinding);
                            label.Measure(new Size(this.ActualHeight, this.ActualWidth));
                            RotateTransform labelRotation = new RotateTransform();
                            labelRotation.Angle = LabelAngle;
                            Rect rotatedRect = GetRotatedRect(new Rect(0, 0, label.DesiredSize.Width, label.DesiredSize.Height), labelRotation);
                            // label.RenderTransformOrigin = new Point(0.5, 0.5);
                            label.RenderTransform = labelRotation;
                            Labels.Add(label);
                            Line    tickLine     = new Line();
                            Binding styleBinding = new Binding();
                            styleBinding.Path   = new PropertyPath("MajorLineStyle");
                            styleBinding.Source = this;
                            tickLine.SetBinding(Line.StyleProperty, styleBinding);
                            tickLine.Measure(new Size(this.ActualHeight, this.ActualWidth));
                            tickLine.X1 = xAxisWidthPosition - (tickLine.DesiredSize.Width / 2);
                            tickLine.X2 = xAxisWidthPosition - (tickLine.DesiredSize.Width / 2);

                            switch (this.MajorTicksPosition)
                            {
                            case TickPosition.Inside:
                                tickLine.Y1 = 0;
                                Binding tickSizeInsideBinding = new Binding();
                                tickSizeInsideBinding.Path      = new PropertyPath("MajorLineSize");
                                tickSizeInsideBinding.Source    = this;
                                tickSizeInsideBinding.Converter = new NegativeConverter();
                                tickLine.SetBinding(Line.Y2Property, tickSizeInsideBinding);
                                if (this.ShowMajorTicks)
                                {
                                    desiredHeight = 0;
                                }
                                break;

                            case TickPosition.Cross:
                                Binding tickSizeNegativeCrossBinding = new Binding();
                                tickSizeNegativeCrossBinding.Path      = new PropertyPath("MajorLineSize");
                                tickSizeNegativeCrossBinding.Source    = this;
                                tickSizeNegativeCrossBinding.Converter = new NegativeHalfConverter();
                                tickLine.SetBinding(Line.Y1Property, tickSizeNegativeCrossBinding);
                                Binding tickSizeCrossBinding = new Binding();
                                tickSizeCrossBinding.Path      = new PropertyPath("MajorLineSize");
                                tickSizeCrossBinding.Source    = this;
                                tickSizeCrossBinding.Converter = new HalfValueConverter();
                                tickLine.SetBinding(Line.Y2Property, tickSizeCrossBinding);
                                if (this.ShowMajorTicks)
                                {
                                    desiredHeight = MajorLineSize / 2;
                                }
                                break;

                            case TickPosition.Outside:
                                tickLine.Y1 = 0;
                                Binding tickSizeBinding = new Binding();
                                tickSizeBinding.Path   = new PropertyPath("MajorLineSize");
                                tickSizeBinding.Source = this;
                                tickLine.SetBinding(Line.Y2Property, tickSizeBinding);
                                if (this.ShowMajorTicks)
                                {
                                    desiredHeight = MajorLineSize;
                                }
                                break;
                            }

                            Binding ticklineVisibilityBinding = new Binding();
                            ticklineVisibilityBinding.Path      = new PropertyPath("ShowMajorTicks");
                            ticklineVisibilityBinding.Source    = this;
                            ticklineVisibilityBinding.Converter = new BooleanToVisibilityConverter();
                            tickLine.SetBinding(Line.VisibilityProperty, ticklineVisibilityBinding);
                            double minorWidth = xAxisWidthStep;
                            minorstep = minorWidth / (MinorTicksCount + 1);
                            for (int k = 0; k < this.MinorTicksCount; k++)
                            {
                                Line    minorLine         = new Line();
                                Binding minorstyleBinding = new Binding();
                                minorstyleBinding.Path   = new PropertyPath("MinorLineStyle");
                                minorstyleBinding.Source = this;
                                minorLine.SetBinding(Line.StyleProperty, minorstyleBinding);
                                minorLine.Measure(new Size(this.ActualHeight, this.ActualWidth));
                                minorLine.X1 = (xAxisWidthPosition + minorstep);
                                minorLine.X2 = (xAxisWidthPosition + minorstep);
                                switch (MinorTicksPosition)
                                {
                                case TickPosition.Inside:
                                    minorLine.Y1 = 0;
                                    Binding minortickInsideSizeBinding = new Binding();
                                    minortickInsideSizeBinding.Path      = new PropertyPath("MinorLineSize");
                                    minortickInsideSizeBinding.Source    = this;
                                    minortickInsideSizeBinding.Converter = new NegativeConverter();
                                    minorLine.SetBinding(Line.Y2Property, minortickInsideSizeBinding);
                                    break;

                                case TickPosition.Cross:
                                    Binding minortickNegativeCrossSizeBinding = new Binding();
                                    minortickNegativeCrossSizeBinding.Path      = new PropertyPath("MinorLineSize");
                                    minortickNegativeCrossSizeBinding.Source    = this;
                                    minortickNegativeCrossSizeBinding.Converter = new NegativeHalfConverter();
                                    minorLine.SetBinding(Line.Y1Property, minortickNegativeCrossSizeBinding);

                                    Binding minortickCrossSizeBinding = new Binding();
                                    minortickCrossSizeBinding.Path      = new PropertyPath("MinorLineSize");
                                    minortickCrossSizeBinding.Source    = this;
                                    minortickCrossSizeBinding.Converter = new HalfValueConverter();
                                    minorLine.SetBinding(Line.Y2Property, minortickCrossSizeBinding);
                                    break;

                                case TickPosition.Outside:
                                    minorLine.Y1 = 0;
                                    Binding minortickSizeBinding = new Binding();
                                    minortickSizeBinding.Path   = new PropertyPath("MinorLineSize");
                                    minortickSizeBinding.Source = this;
                                    minorLine.SetBinding(Line.Y2Property, minortickSizeBinding);
                                    break;
                                }
                                MinorTickLines.Add(minorLine);
                                this.Children.Add(minorLine);
                                minorstep += minorstep;
                            }
                            MajorTickLines.Add(tickLine);
                            this.Children.Add(label);
                            this.Children.Add(tickLine);
                        }
                    }
                    else
                    {
                        int offset = Labels.Count - this.MLabels.Count;
                        for (int j = 0; j < offset; j++)
                        {
                            this.Children.Remove(Labels[Labels.Count - 1]);
                            Labels.RemoveAt(Labels.Count - 1);
                            for (int k = 0; k < this.MinorTicksCount; k++)
                            {
                                this.Children.Remove(MinorTickLines[MinorTickLines.Count - 1]);
                                MinorTickLines.RemoveAt(MinorTickLines.Count - 1);
                            }
                            this.Children.Remove(MajorTickLines[MajorTickLines.Count - 1]);
                            MajorTickLines.RemoveAt(MajorTickLines.Count - 1);
                        }
                    }
                    for (int i = 0; i < this.MLabels.Count; i++)
                    {
                        ContentControl label = Labels[i];
                        label.Content = MLabels[i];
                        label.Measure(new Size(this.ActualHeight, this.ActualWidth));
                        RotateTransform labelRotation = new RotateTransform();
                        labelRotation.Angle = LabelAngle;
                        Rect rotatedRect = GetRotatedRect(new Rect(0, 0, label.DesiredSize.Width, label.DesiredSize.Height), labelRotation);
                        //label.RenderTransformOrigin = new Point(0.5, 0.5);
                        label.RenderTransform = labelRotation;
                        Line   tickLine     = MajorTickLines[i];
                        double labelPadding = 0;
                        int    minorCount   = 0;
                        tickLine.X1 = xAxisWidthPosition;
                        tickLine.X2 = xAxisWidthPosition;
                        tickLine.Measure(new Size(this.ActualHeight, this.ActualWidth));

                        if (!(i == this.MLabels.Count - 1))
                        {
                            double minorWidth = xAxisWidthStep;
                            minorstep = minorWidth / (MinorTicksCount + 1);
                            for (int j = 0; j < this.MinorTicksCount; j++)
                            {
                                Line minorLine = MinorTickLines[minorCount];
                                minorLine.X1 = (xAxisWidthPosition + minorstep * (j + 1));
                                minorLine.X2 = (xAxisWidthPosition + minorstep * (j + 1));
                                minorCount++;
                            }
                        }

                        if (this.LabelAngle == 0)
                        {
                            Canvas.SetLeft(label, xAxisWidthPosition - (label.DesiredSize.Width / 2));
                            Canvas.SetTop(label, desiredHeight);
                            labelSize = Math.Max(labelSize, label.DesiredSize.Height);
                        }
                        else
                        {
                            Canvas.SetLeft(label, xAxisWidthPosition - (rotatedRect.Width / 2) - rotatedRect.X);
                            Canvas.SetTop(label, desiredHeight - rotatedRect.Y);
                            labelSize = Math.Max(labelSize, rotatedRect.Height);
                        }
                        xAxisWidthPosition += xAxisWidthStep;
                    }
                }
                desiredHeight += labelSize;
                header.Measure(new Size(this.ActualHeight, this.ActualWidth));
                Canvas.SetLeft(header, (this.ActualWidth / 2) - (header.DesiredSize.Width / 2));
                Canvas.SetTop(header, desiredHeight);
                desiredHeight        += header.DesiredSize.Height;
                this.Chart.AxisHeight = desiredHeight;
            }
            //if (this.Chart.AxisHeight < desiredHeight)
        }