Ejemplo n.º 1
0
        /// <summary>
        ///     Gets the specified axis.
        /// </summary>
        /// <param name="plot">The plot to configure.</param>
        /// <param name="direction">The axis direction.</param>
        /// <param name="secondary">Indicates if the secondary axis should be retrieved.</param>
        /// <param name="configure">Configures the axis.</param>
        public static PlotConfigurator WithAxis <T>(this PlotConfigurator plot, AxisDirection direction, bool secondary,
                                                    Action <AxisConfigurator <T> >?configure = null)
            where T : Axis
        {
            IAxisConfigurator?existing = plot.Axes
                                         .FirstOrDefault(a
                                                         => a.Position.GetPosition() == AxisPositionConfigurator.CalculatePosition(direction, secondary));

            // Axis is null or another type
            if (existing is not AxisConfigurator <T> configurator)
            {
                if (existing != null)
                {
                    plot.Axes.Remove(existing);
                }

                configurator = new AxisConfigurator <T>();
                configurator.Position.ToIncludedState();
                configurator.Position.Direction   = direction;
                configurator.Position.IsSecondary = secondary;

                plot.Axes.Add(configurator);
            }

            configure?.Invoke(configurator);

            return(plot);
        }
Ejemplo n.º 2
0
 /// <summary>
 ///     Sets the extra gridlines for the axis.
 /// </summary>
 /// <param name="axis">The axis to configure.</param>
 /// <param name="configure">Configures the gridlines.</param>
 public static AxisConfigurator <T> WithExtraGridlines <T>(this AxisConfigurator <T> axis,
                                                           Action <ExtraGridlinesConfigurator>?configure = null)
     where T : Axis =>
 axis.With(a => a.ExtraGridlines, configure);
Ejemplo n.º 3
0
 /// <summary>
 ///     Sets the label format string.
 /// </summary>
 /// <param name="axis">The axis to configure.</param>
 /// <param name="format">The format.</param>
 public static AxisConfigurator <T> SetLabelFormat <T>(this AxisConfigurator <T> axis, string format)
     where T : Axis =>
 axis.Set(a => a.LabelFormat, format);
Ejemplo n.º 4
0
 /// <summary>
 ///     Sets the minor ticks for the axis.
 /// </summary>
 /// <param name="axis">The axis to configure.</param>
 /// <param name="configure">Configures the ticks.</param>
 public static AxisConfigurator <T> WithMinorTicks <T>(this AxisConfigurator <T> axis,
                                                       Action <AxisTickConfigurator>?configure = null)
     where T : Axis =>
 axis.With(a => a.MinorTicks, configure);
Ejemplo n.º 5
0
 /// <summary>
 ///     Sets the tick label angle.
 /// </summary>
 /// <param name="axis">The axis to configure.</param>
 /// <param name="angle">The angle.</param>
 public static AxisConfigurator <T> SetLabelAngle <T>(this AxisConfigurator <T> axis, double angle)
     where T : Axis =>
 axis.Set(a => a.LabelAngle, angle);
Ejemplo n.º 6
0
 /// <summary>
 ///     Sets the maximum for the axis.
 /// </summary>
 /// <param name="axis">The axis to configure.</param>
 /// <param name="maximum">The maximum value.</param>
 public static AxisConfigurator <T> SetMaximum <T>(this AxisConfigurator <T> axis, double maximum)
     where T : Axis =>
 axis.Set(a => a.Maximum, maximum);
Ejemplo n.º 7
0
 /// <summary>
 ///     Sets the tick style for the axis.
 /// </summary>
 /// <param name="axis">The axis to configure.</param>
 /// <param name="style">The style.</param>
 public static AxisConfigurator <T> SetTickStyle <T>(this AxisConfigurator <T> axis, TickStyle style)
     where T : Axis =>
 axis.Set(a => a.TickStyle, style);
Ejemplo n.º 8
0
 /// <summary>
 ///     Sets the title for the axis.
 /// </summary>
 /// <param name="axis">The axis to configure.</param>
 /// <param name="title">The title.</param>
 public static AxisConfigurator <T> SetTitle <T>(this AxisConfigurator <T> axis, string title)
     where T : Axis =>
 axis.Set(a => a.Title, title);
Ejemplo n.º 9
0
 /// <summary>
 /// Configures the <paramref name="axis"/> using the information in <paramref name="configurator"/>.
 /// </summary>
 /// <param name="axis">The <see cref="Axis"/> to configure.</param>
 /// <param name="configurator">The configuration to apply.</param>
 /// <typeparam name="T">The <see cref="Axis"/> type.</typeparam>
 public static void Configure <T>(this T axis, AxisConfigurator <T> configurator)
     where T : Axis
 => configurator.Configure(axis);