/// <summary> /// Initialize a new empty instance of the <c>Graphmatic.Interaction.Plotting.GraphAxis</c> class from serialized XML data. /// </summary> /// <param name="xml">The XML data to use for deserializing this Resource.</param> public GraphAxis(XElement xml) { GridSize = Double.Parse(xml.Element("GridSize").Value); MajorInterval = Double.Parse(xml.Element("MajorInterval").Value); HorizontalType = (GraphAxisType)Enum.Parse(typeof(GraphAxisType), xml.Element("HorizontalType").Value); VerticalType = (GraphAxisType)Enum.Parse(typeof(GraphAxisType), xml.Element("VerticalType").Value); }
/// <summary> /// Initialize a new empty instance of the <c>Graphmatic.Interaction.Plotting.GraphAxis</c> class with the specified grid parameters. /// </summary> /// <param name="gridSize">The graph-space distance between grid lines.</param> /// <param name="majorInterval">The interval between major (darker, numbered) grid lines.</param> public GraphAxis(double gridSize, int majorInterval) { GridSize = gridSize; MajorInterval = majorInterval; HorizontalType = GraphAxisType.Radians; VerticalType = GraphAxisType.Radians; }
/// <summary> /// Gets the graph label scale for a gixen axis type. /// <para/> /// For example, labels in degrees are scaled by a factor of 180/pi, and radians are not scaled. /// </summary> /// <param name="axisType">The graph axis type for which to return the scale.</param> /// <returns>The graph label scale for a gixen axis type.</returns> public static double AxisTypeLabelScale(this GraphAxisType axisType) { switch (axisType) { case GraphAxisType.Degrees: return(180.0 / Math.PI); case GraphAxisType.Grads: return(200.0 / Math.PI); default: return(1.0); } }
/// <summary> /// Gets the graph label suffix for a given axis type. /// <para/> /// For example, degrees have a degree symbol (°) suffix, and radians have none. /// </summary> /// <param name="axisType">The graph axis type for which to return the suffix.</param> /// <returns>The graph label suffix for a given axis type.</returns> public static string AxisTypeExtension(this GraphAxisType axisType) { switch (axisType) { case GraphAxisType.Degrees: return("°"); case GraphAxisType.Grads: return("g"); default: return(""); } }
/// <summary> /// Gets the graph grid scale for a gixen axis type. /// <para/> /// For example, degrees and grads are scaled by a factor of 2*pi/5 to make major intervals line /// up with the full angle around a circle, and radians are left unscaled. /// </summary> /// <param name="axisType">The graph grid type for which to return the scale.</param> /// <returns>The grid scale for a gixen axis type.</returns> public static double AxisTypeGridScale(this GraphAxisType axisType) { switch (axisType) { case GraphAxisType.Degrees: return(2 * Math.PI / 5); case GraphAxisType.Grads: return(2 * Math.PI / 5); default: return(1.0); } }