當前位置: 首頁>>代碼示例>>C#>>正文


C# Axis.FormatValue方法代碼示例

本文整理匯總了C#中OxyPlot.Axes.Axis.FormatValue方法的典型用法代碼示例。如果您正苦於以下問題:C# Axis.FormatValue方法的具體用法?C# Axis.FormatValue怎麽用?C# Axis.FormatValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在OxyPlot.Axes.Axis的用法示例。


在下文中一共展示了Axis.FormatValue方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: RenderTickText

        /// <summary>
        /// Renders major tick text
        /// </summary>
        /// <param name="axis">The axis.</param>
        /// <param name="x">The x-value.</param>
        /// <param name="angleAxis">The angle axis.</param>
        private void RenderTickText(Axis axis, double x, Axis angleAxis)
        {
            var actualAngle = GetActualAngle(axis, angleAxis);
            var dx = axis.AxisTickToLabelDistance * Math.Sin(actualAngle);
            var dy = -axis.AxisTickToLabelDistance * Math.Cos(actualAngle);

            HorizontalAlignment ha;
            VerticalAlignment va;
            GetTickTextAligment(actualAngle, out ha, out va);

            var pt = axis.Transform(x, angleAxis.Angle, angleAxis);
            pt = new ScreenPoint(pt.X + dx, pt.Y + dy);

            string text = axis.FormatValue(x);
            this.RenderContext.DrawMathText(
                pt,
                text,
                axis.ActualTextColor,
                axis.ActualFont,
                axis.ActualFontSize,
                axis.ActualFontWeight,
                axis.Angle,
                ha,
                va);
        }
開發者ID:benjaminrupp,項目名稱:oxyplot,代碼行數:31,代碼來源:MagnitudeAxisRenderer.cs

示例2: RenderMajorItems


//.........這裏部分代碼省略.........
                            VerticalAlignment.Middle,
                            out ha,
                            out va);
                        break;
                    case AxisPosition.Right:
                        pt = new ScreenPoint(axisPosition + a1 + axis.AxisTickToLabelDistance, transformedValue);
                        this.GetRotatedAlignments(
                            axis.Angle,
                            HorizontalAlignment.Left,
                            VerticalAlignment.Middle,
                            out ha,
                            out va);
                        break;
                    case AxisPosition.Top:
                        pt = new ScreenPoint(transformedValue, axisPosition + a1 - axis.AxisTickToLabelDistance);
                        this.GetRotatedAlignments(
                            axis.Angle,
                            HorizontalAlignment.Center,
                            VerticalAlignment.Bottom,
                            out ha,
                            out va);
                        break;
                    case AxisPosition.Bottom:
                        pt = new ScreenPoint(transformedValue, axisPosition + a1 + axis.AxisTickToLabelDistance);
                        this.GetRotatedAlignments(
                            axis.Angle,
                            HorizontalAlignment.Center,
                            VerticalAlignment.Top,
                            out ha,
                            out va);
                        break;
                }

                string text = axis.FormatValue(value);
                this.RenderContext.DrawMathText(
                    pt,
                    text,
                    axis.ActualTextColor,
                    axis.ActualFont,
                    axis.ActualFontSize,
                    axis.ActualFontWeight,
                    axis.Angle,
                    ha,
                    va);
            }

            // Draw the zero crossing line
            if (axis.PositionAtZeroCrossing && this.ZeroPen != null && this.IsWithin(0, actualMinimum, actualMaximum))
            {
                double t0 = axis.Transform(0);
                if (isHorizontal)
                {
                    this.RenderContext.DrawLine(t0, plotAreaTop, t0, plotAreaBottom, this.ZeroPen);
                }
                else
                {
                    this.RenderContext.DrawLine(plotAreaLeft, t0, plotAreaRight, t0, this.ZeroPen);
                }
            }

            // Draw extra grid lines
            if (axis.ExtraGridlines != null && this.ExtraPen != null)
            {
                foreach (double value in axis.ExtraGridlines)
                {
                    if (!this.IsWithin(value, actualMinimum, actualMaximum))
開發者ID:Celderon,項目名稱:oxyplot,代碼行數:67,代碼來源:HorizontalAndVerticalAxisRenderer.cs

示例3: Render

        /// <summary>
        /// Renders the specified axis.
        /// </summary>
        /// <param name="axis">The axis.</param>
        /// <param name="pass">The render pass.</param>
        /// <exception cref="System.InvalidOperationException">Magnitude axis not defined.</exception>
        public override void Render(Axis axis, int pass)
        {
            var angleAxis = (AngleAxis)axis;

            base.Render(axis, pass);

            var magnitudeAxis = this.Plot.DefaultMagnitudeAxis;

            if (magnitudeAxis == null)
            {
                throw new InvalidOperationException("Magnitude axis not defined.");
            }

            var scaledStartAngle = angleAxis.StartAngle / angleAxis.Scale;
            var scaledEndAngle = angleAxis.EndAngle / angleAxis.Scale;

            var axisLength = Math.Abs(scaledEndAngle - scaledStartAngle);
            var eps = axis.MinorStep * 1e-3;
            if (this.MinorPen != null)
            {
                var tickCount = Math.Abs((int)(axisLength / axis.ActualMinorStep));
                var screenPoints = this.MinorTickValues
                    .Where(x => x > Math.Min(scaledStartAngle, scaledEndAngle) - eps &&
                           x < Math.Max(scaledStartAngle, scaledEndAngle) + eps &&
                           !this.MajorTickValues.Contains(x))
                    .Take(tickCount + 1)
                    .Select(x => magnitudeAxis.Transform(magnitudeAxis.ActualMaximum, x, axis));

                foreach (var screenPoint in screenPoints)
                {
                    this.RenderContext.DrawLine(magnitudeAxis.MidPoint.x, magnitudeAxis.MidPoint.y, screenPoint.x, screenPoint.y, this.MinorPen, false);
                }
            }

            var isFullCircle = Math.Abs(Math.Abs(Math.Max(angleAxis.EndAngle, angleAxis.StartAngle) - Math.Min(angleAxis.StartAngle, angleAxis.EndAngle)) - 360) < 1e-3;
            var majorTickCount = (int)(axisLength / axis.ActualMajorStep);
            if (!isFullCircle)
            {
                majorTickCount++;
            }

            if (this.MajorPen != null)
            {
                var screenPoints = this.MajorTickValues
                    .Where(x => x > Math.Min(scaledStartAngle, scaledEndAngle) - eps && x < Math.Max(scaledStartAngle, scaledEndAngle) + eps)
                    .Take(majorTickCount)
                    .Select(x => magnitudeAxis.Transform(magnitudeAxis.ActualMaximum, x, axis))
                    .ToArray();

                foreach (var point in screenPoints)
                {
                    this.RenderContext.DrawLine(magnitudeAxis.MidPoint.x, magnitudeAxis.MidPoint.y, point.x, point.y, this.MajorPen, false);
                }
            }

            foreach (var value in this.MajorLabelValues.Take(majorTickCount))
            {
                var pt = magnitudeAxis.Transform(magnitudeAxis.ActualMaximum, value, axis);
                var angle = Math.Atan2(pt.y - magnitudeAxis.MidPoint.y, pt.x - magnitudeAxis.MidPoint.x);

                // add some margin
                pt.x += Math.Cos(angle) * axis.AxisTickToLabelDistance;
                pt.y += Math.Sin(angle) * axis.AxisTickToLabelDistance;

                // Convert to degrees
                angle *= 180 / Math.PI;

                var text = axis.FormatValue(value);

                var ha = HorizontalAlignment.Left;
                var va = VerticalAlignment.Middle;

                if (Math.Abs(Math.Abs(angle) - 90) < 10)
                {
                    ha = HorizontalAlignment.Center;
                    va = angle >= 90 ? VerticalAlignment.Top : VerticalAlignment.Bottom;
                    angle = 0;
                }
                else if (angle > 90 || angle < -90)
                {
                    angle -= 180;
                    ha = HorizontalAlignment.Right;
                }

                this.RenderContext.DrawMathText(
                    pt, text, axis.ActualTextColor, axis.ActualFont, axis.ActualFontSize, axis.ActualFontWeight, angle, ha, va);
            }
        }
開發者ID:benjaminrupp,項目名稱:oxyplot,代碼行數:94,代碼來源:AngleAxisRenderer.cs


注:本文中的OxyPlot.Axes.Axis.FormatValue方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。