当前位置: 首页>>代码示例>>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;未经允许,请勿转载。