first commit -push

This commit is contained in:
dungtt
2025-10-15 15:15:53 +07:00
parent 674ae395be
commit a9577c5756
885 changed files with 74595 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
namespace RobotNet.WebApp.Charts.Models.Common;
/// <summary>
/// The animation-subconfig of the options for a radial chart.
/// </summary>
public class ArcAnimation : ChartAnimation
{
/// <summary>
/// Gets or sets a value indicating whether the chart will
/// load in with a rotation animation or not.
/// </summary>
public bool? AnimateRotate { get; set; }
/// <summary>
/// Gets or sets a value indicating whether the chart will
/// load in with a scaling animation (from the center outwards) or not.
/// </summary>
public bool? AnimateScale { get; set; }
}

View File

@@ -0,0 +1,28 @@
using RobotNet.WebApp.Charts.Enums;
using System.Text.Json.Serialization;
namespace RobotNet.WebApp.Charts.Models.Common;
public class ChartAnimation
{
/// <summary>
/// Gets or sets the number of milliseconds an animation takes.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public long? Duration { get; set; }
/// <summary>
/// Delay before starting the animations.
/// </summary>
public int Delay { get; set; }
/// <summary>
/// If set to true, the animations loop endlessly.
/// </summary>
public bool Loop { get; set; }
/// <summary>
/// Gets or sets the easing function to use.
/// </summary>
public Easing Easing { get; set; }
}

View File

@@ -0,0 +1,36 @@
using System.Text.Json.Serialization;
namespace RobotNet.WebApp.Charts.Models.Common;
public class ChartFont
{
/// <summary>
/// Default font family for all text, follows CSS font-family options.
/// 'Helvetica Neue', 'Helvetica', 'Arial', sans-serif
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? Family { get; set; }
/// <summary>
/// Height of an individual line of text
/// </summary>
public double LineHeight { get; set; } = 1.2;
/// <summary>
/// Default font size (in px) for text. Does not apply to radialLinear scale point labels.
/// </summary>
public int Size { get; set; } = 12;
/// <summary>
/// Default font style. Does not apply to tooltip title or footer. Does not apply to chart title.
/// Follows CSS font-style options (i.e. normal, italic, oblique, initial, inherit).
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? Style { get; set; }
/// <summary>
/// Default font weight (boldness).
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? Weight { get; set; } = "bold";
}

View File

@@ -0,0 +1,17 @@
using System.Text.Json.Serialization;
namespace RobotNet.WebApp.Charts.Models.Common;
public class ChartLayout
{
/// <summary>
/// The padding to add inside the chart
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public ChartPadding? Padding { get; set; }
/// <summary>
/// Apply automatic padding so visible elements are completely drawn.
/// </summary>
public bool AutoPadding { get; set; } = true;
}

View File

@@ -0,0 +1,67 @@
using RobotNet.WebApp.Charts.Models.Common.Elements;
using System.Text.Json.Serialization;
namespace RobotNet.WebApp.Charts.Models.Common;
public class ChartOptions : IChartOptions
{
/// <summary>
/// Gets or sets the locale.
/// By default, the chart is using the default locale of the platform which is running on.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? Locale { get; set; }
/// <summary>
/// Gets or sets a value indicating whether to maintain the original canvas aspect ratio (width / height) when resizing.
/// </summary>
/// <remarks>
/// Default value is <see langword="true" />.
/// </remarks>
public bool MaintainAspectRatio { get; set; } = true;
/// <summary>
/// Gets or sets a value indicating whether the chart canvas should be resized when its container is.
/// </summary>
/// <remarks>
/// Default value is <see langword="false" />.
/// </remarks>
public bool Responsive { get; set; }
/// <summary>
/// Gets or sets the canvas aspect ratio (i.e. width / height, a value of 1 representing a square canvas).
/// <para>Note that this option is ignored if the height is explicitly defined either as attribute (of the canvas) or via the style.</para>
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public double? AspectRatio { get; set; }
/// <summary>
/// Gets or sets the duration in milliseconds it takes to animate to new size after a resize event.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public int? ResponsiveAnimationDuration { get; set; }
/// <summary>
/// Gets or sets the animation-configuration for this chart.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public ChartAnimation? Animation { get; set; }
/// <summary>
/// Gets or sets the layout options for this chart.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public ChartLayout? Layout { get; set; }
/// <summary>
/// Gets or sets the Interaction configuration for this chart.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public Interaction? Interaction { get; set; }
/// <summary>
/// Gets or sets the elements options for this chart.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public ChartElements? Elements { get; set; }
}

View File

@@ -0,0 +1,24 @@
namespace RobotNet.WebApp.Charts.Models.Common;
public class ChartPadding
{
public ChartPadding() { }
public ChartPadding(int padding)
{
Left = padding;
Right = padding;
Top = padding;
Bottom = padding;
}
public ChartPadding(int left, int top, int right, int bottom)
{
Left = left;
Right = top;
Top = right;
Bottom = bottom;
}
public int Left { get; set; }
public int Right { get; set; }
public int Top { get; set; }
public int Bottom { get; set; }
}

View File

@@ -0,0 +1,12 @@
using System.Text.Json.Serialization;
namespace RobotNet.WebApp.Charts.Models.Common.Dataset;
public class ChartData
{
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public List<IChartDataset>? Datasets { get; set; }
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public List<string>? Labels { get; set; }
}

View File

@@ -0,0 +1,256 @@
using System.Text.Json.Serialization;
namespace RobotNet.WebApp.Charts.Models.Common.Dataset;
public class ChartDataset<TData> : IChartDataset
{
public ChartDataset()
{
Oid = Guid.NewGuid();
}
/// <summary>
/// How to clip relative to chartArea. Positive value allows overflow, negative value clips that many pixels inside
/// chartArea. 0 = clip at chartArea.
/// Clipping can also be configured per side: clip: {left: 5, top: false, right: -2, bottom: 0}
/// </summary>
/// <remarks>
/// Default value is <see langword="null" />.
/// </remarks>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? Clip { get; set; }
/// <summary>
/// Get or sets the Data.
/// </summary>
/// <remarks>
/// Default value is <see langword="null" />.
/// </remarks>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public List<TData>? Data { get; set; }
/// <summary>
/// Configures the visibility state of the dataset. Set it to <see langword="true" />, to hide the dataset from the chart.
/// </summary>
/// <remarks>
/// Default value is <see langword="false" />.
/// </remarks>
public bool Hidden { get; set; }
/// <summary>
/// The label for the dataset which appears in the legend and tooltips.
/// </summary>
/// <remarks>
/// Default value is <see cref="string.Empty" />.
/// </remarks>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? Label { get; set; }
/// <summary>
/// Get unique object id.
/// </summary>
public Guid Oid { get; private set; }
/// <summary>
/// The drawing order of dataset. Also affects order for stacking, tooltip and legend.
/// </summary>
/// <remarks>
/// Default value is 0.
/// </remarks>
public int Order { get; set; }
/// <summary>
/// Gets or sets the chart type.
/// </summary>
/// <remarks>
/// Default value is <see langword="null" />.
/// </remarks>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? Type { get; set; }
/// <summary>
/// Arc background color.
/// </summary>
/// <remarks>
/// Default value is 'rgba(0, 0, 0, 0.1)'.
/// </remarks>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public List<string>? BackgroundColor { get; set; }
/// <summary>
/// Supported values are 'center' and 'inner'.
/// When 'center' is set, the borders of arcs next to each other will overlap.
/// When 'inner' is set, it is guaranteed that all borders will not overlap.
/// </summary>
/// <remarks>
/// Default value is 'center'.
/// </remarks>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public List<string>? BorderAlign { get; set; } // TODO: change this to enum
/// <summary>
/// Arc border color.
/// </summary>
/// <remarks>
/// Default value is '#fff'.
/// </remarks>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public List<string>? BorderColor { get; set; }
/// <summary>
/// Arc border length and spacing of dashes.
/// </summary>
/// <remarks>
/// Default value is <see langword="null" />.
/// </remarks>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public List<double>? BorderDash { get; set; }
/// <summary>
/// Arc border offset for line dashes.
/// </summary>
/// <remarks>
/// Default value is 0.0.
/// </remarks>
public double BorderDashOffset { get; set; }
/// <summary>
/// Arc border join style.
/// Supported values are 'round', 'bevel', 'miter'.
/// </summary>
/// <remarks>
/// Default value is <see langword="null" />.
/// </remarks>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public List<string>? BorderJoinStyle { get; set; }
/// <summary>
/// It is applied to all corners of the arc (outerStart, outerEnd, innerStart, innerRight).
/// </summary>
/// <remarks>
/// Default value is 0.
/// </remarks>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public List<double>? BorderRadius { get; set; }
/// <summary>
/// Arc border width (in pixels).
/// </summary>
/// <remarks>
/// Default value is 2.
/// </remarks>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public List<double>? BorderWidth { get; set; }
/// <summary>
/// Per-dataset override for the sweep that the arcs cover.
/// </summary>
/// <remarks>
/// Default value is <see langword="null" />.
/// </remarks>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public double? Circumference { get; set; }
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public ChartDatasetDataLabels? Datalabels { get; set; }
/// <summary>
/// Arc background color when hovered.
/// </summary>
/// <remarks>
/// Default value is <see langword="null" />.
/// </remarks>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public List<string>? HoverBackgroundColor { get; set; }
/// <summary>
/// Arc border color when hovered.
/// </summary>
/// <remarks>
/// Default value is <see langword="null" />.
/// </remarks>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public List<string>? HoverBorderColor { get; set; }
/// <summary>
/// Arc border length and spacing of dashes when hovered.
/// </summary>
/// <remarks>
/// Default value is <see langword="null" />.
/// </remarks>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public List<double>? HoverBorderDash { get; set; }
/// <summary>
/// Arc border offset for line dashes when hovered.
/// </summary>
/// <remarks>
/// Default value is <see langword="null" />.
/// </remarks>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public double? HoverBorderDashOffset { get; set; }
/// <summary>
/// Arc border join style when hovered.
/// Supported values are 'round', 'bevel', 'miter'.
/// </summary>
/// <remarks>
/// Default value is <see langword="null" />.
/// </remarks>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public List<string>? HoverBorderJoinStyle { get; set; } // TODO: change this to enum
/// <summary>
/// Arc border width when hovered (in pixels).
/// </summary>
/// <remarks>
/// Default value is <see langword="null" />.
/// </remarks>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public List<double>? HoverBorderWidth { get; set; }
/// <summary>
/// Arc offset when hovered (in pixels).
/// </summary>
/// <remarks>
/// Default value is 0.
/// </remarks>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public List<double>? HoverOffset { get; set; }
/// <summary>
/// Arc offset (in pixels).
/// </summary>
/// <remarks>
/// Default value is 0.
/// </remarks>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public List<double>? Offset { get; set; }
/// <summary>
/// Per-dataset override for the starting angle to draw arcs from.
/// </summary>
/// <remarks>
/// Default value is <see langword="null" />.
/// </remarks>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public double? Rotation { get; set; }
/// <summary>
/// Fixed arc offset (in pixels). Similar to <see cref="Offset" /> but applies to all arcs.
/// </summary>
/// <remarks>
/// Default value is 0.
/// </remarks>
public double Spacing { get; set; }
/// <summary>
/// The relative thickness of the dataset.
/// Providing a value for weight will cause the pie or doughnut dataset to be drawn
/// with a thickness relative to the sum of all the dataset weight values.
/// </summary>
/// <remarks>
/// Default value is 1.
/// </remarks>
public double Weight { get; set; } = 1;
}

View File

@@ -0,0 +1,10 @@
namespace RobotNet.WebApp.Charts.Models.Common.Dataset;
public class ChartDatasetData(string? datasetLabel, object data, string? backgroundColor) : IChartDatasetData
{
public string? DatasetLabel { get; init; } = datasetLabel;
public object Data { get; init; } = data;
public string? BackgroundColor { get; init; } = backgroundColor;
}

View File

@@ -0,0 +1,24 @@
using RobotNet.WebApp.Charts.Enums;
using System.Text.Json.Serialization;
namespace RobotNet.WebApp.Charts.Models.Common.Dataset;
public class ChartDatasetDataLabels
{
public DataLabelsAlignment Align { get; set; } = DataLabelsAlignment.Center;
public DataLabelsAnchoring Anchor { get; set; } = DataLabelsAnchoring.Center;
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? BackgroundColor { get; set; }
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? Color { get; set; }
public bool Display { get; set; } = true;
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public ChartFont? Font { get; set; }
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public ChartPadding? Padding { get; set; } = new(6);
}

View File

@@ -0,0 +1,55 @@
using RobotNet.WebApp.Charts.Enums;
using System.Text.Json.Serialization;
namespace RobotNet.WebApp.Charts.Models.Common.Elements;
public class Arc
{
/// <summary>
/// Arc angle to cover.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public double? Angle { get; set; }
/// <summary>
/// Arc fill color.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? BackgroundColor { get; set; }
/// <summary>
/// Arc stroke alignment.
/// </summary>
public BorderAlign BorderAlign { get; set; } = BorderAlign.Center;
/// <summary>
/// Arc stroke color.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? BorderColor { get; set; }
/// <summary>
/// Arc line dash
/// </summary>
public int[]? BorderDash { get; set; }
/// <summary>
/// Arc line dash offset
/// </summary>
public double BorderDashOffset { get; set; }
/// <summary>
/// Line join style.
/// </summary>
public BorderJoinStyle? BorderJoinStyle { get; set; }
/// <summary>
/// Arc stroke width.
/// </summary>
public int BorderWidth { get; set; } = 2;
/// <summary>
/// By default the Arc is curved. If circular: false the Arc will be flat
/// </summary>
public bool Circular { get; set; } = true;
}

View File

@@ -0,0 +1,46 @@
using RobotNet.WebApp.Charts.Enums;
using System.Text.Json.Serialization;
namespace RobotNet.WebApp.Charts.Models.Common.Elements;
public class Bar
{
/// <summary>
/// Bar fill color.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? BackgroundColor { get; set; }
/// <summary>
/// Bar stroke width.
/// </summary>
public int BorderWidth { get; set; } = 1;
/// <summary>
/// Bar stroke color.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? BorderColor { get; set; }
/// <summary>
/// Skipped (excluded) border.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public BorderSkipped? BorderSkipped { get; set; }
/// <summary>
/// The bar border radius (in pixels).
/// </summary>
public int BorderRadius { get; set; }
/// <summary>
/// The amount of pixels to inflate the bar rectangle(s) when drawing.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public int? InflateAmount { get; set; }
/// <summary>
/// Style of the point for legend.
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public PointStyle? PointStyle { get; set; }
}

View File

@@ -0,0 +1,30 @@
using System.Text.Json.Serialization;
namespace RobotNet.WebApp.Charts.Models.Common.Elements;
public class ChartElements
{
/// <summary>
/// Arcs are used in the polar area, doughnut and pie charts.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public Arc? Arc { get; set; }
/// <summary>
/// Bar elements are used to represent the bars in a bar chart.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public Bar? Bar { get; set; }
/// <summary>
/// Line elements are used to represent the line in a line chart.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public Line? Line { get; set; }
/// <summary>
/// Point elements are used to represent the points in a line, radar or bubble chart.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public Point? Point { get; set; }
}

View File

@@ -0,0 +1,71 @@
using RobotNet.WebApp.Charts.Enums;
using System.Text.Json.Serialization;
namespace RobotNet.WebApp.Charts.Models.Common.Elements;
public class Line
{
/// <summary>
/// Bézier curve tension (0 for no Bézier curves).
/// </summary>
public int Tension { get; set; }
/// <summary>
/// Line fill color.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? BackgroundColor { get; set; }
/// <summary>
/// Line stroke width.
/// </summary>
public int BorderWidth { get; set; } = 1;
/// <summary>
/// Line stroke color.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? BorderColor { get; set; }
/// <summary>
/// Line cap style.
/// </summary>
public string BorderCapStyle { get; set; } = "butt";
/// <summary>
/// Line dash.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public int[]? BorderDash { get; set; }
/// <summary>
/// Line dash offset.
/// </summary>
public double BorderDashOffset { get; set; }
/// <summary>
/// Line join style.
/// </summary>
public BorderJoinStyle BorderJoinStyle { get; set; } = BorderJoinStyle.Miter;
/// <summary>
/// if true to keep Bézier control inside the chart, false for no restriction.
/// </summary>
public bool CapBezierPoints { get; set; } = true;
/// <summary>
/// Interpolation mode to apply.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? CubicInterpolationMode { get; set; }
/// <summary>
/// How to fill the area under the line.
/// </summary>
public bool Fill { get; set; }
/// <summary>
/// if true to show the line as a stepped line (tension will be ignored).
/// </summary>
public bool Stepped { get; set; }
}

View File

@@ -0,0 +1,54 @@
using RobotNet.WebApp.Charts.Enums;
using System.Text.Json.Serialization;
namespace RobotNet.WebApp.Charts.Models.Common.Elements;
public class Point
{
/// <summary>
/// Point radius.
/// </summary>
public double Radius { get; set; } = 3;
/// <summary>
/// Point style.
/// </summary>
public PointStyle PointStyle { get; set; } = PointStyle.Circle;
/// <summary>
/// Point rotation (in degrees).
/// </summary>
public double Rotation { get; set; }
/// <summary>
/// Point fill color.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? BackgroundColor { get; set; }
/// <summary>
/// Point stroke width.
/// </summary>
public int BorderWidth { get; set; } = 1;
/// <summary>
/// Point stroke color.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? BorderColor { get; set; }
/// <summary>
/// Extra radius added to point radius for hit detection.
/// </summary>
public double HitRadius { get; set; } = 1;
/// <summary>
/// Point radius when hovered.
/// </summary>
public int HhoverRadius { get; set; } = 4;
/// <summary>
/// Stroke width when hovered.
/// </summary>
public int HoverBorderWidth { get; set; } = 1;
}

View File

@@ -0,0 +1,5 @@
namespace RobotNet.WebApp.Charts.Models.Common;
public interface IChartDataset
{
}

View File

@@ -0,0 +1,5 @@
namespace RobotNet.WebApp.Charts.Models.Common;
public interface IChartDatasetData
{
}

View File

@@ -0,0 +1,5 @@
namespace RobotNet.WebApp.Charts.Models.Common;
public interface IChartOptions
{
}

View File

@@ -0,0 +1,67 @@
using RobotNet.WebApp.Charts.Enums;
using System.Text.Json.Serialization;
namespace RobotNet.WebApp.Charts.Models.Common;
public class Interaction
{
private InteractionMode mode;
public Interaction() => Mode = InteractionMode.Nearest;
private void SetMode(InteractionMode interactionMode) =>
ChartInteractionMode = interactionMode switch
{
InteractionMode.Dataset => "dataset",
InteractionMode.Index => "index",
InteractionMode.Nearest => "nearest",
InteractionMode.Point => "point",
InteractionMode.X => "x",
InteractionMode.Y => "y",
_ => ""
};
/// <summary>
/// Sets which elements appear in the interaction.
/// </summary>
[JsonPropertyName("mode")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? ChartInteractionMode { get; private set; }
/// <summary>
/// if <see langword="true" />, the interaction mode only applies when the mouse position intersects an item on the chart.
/// </summary>
/// <remarks>
/// Default value is <see langword="true" />.
/// </remarks>
public bool Intersect { get; set; } = true;
/// <summary>
/// Sets which elements appear in the tooltip. See Interaction Modes for details.
/// </summary>
[JsonIgnore]
public InteractionMode Mode
{
get => mode;
set
{
mode = value;
SetMode(value);
}
}
/// <summary>
/// Gets or sets which directions are used in calculating distances.
/// Defaults to <see cref="AxisDirection.X"/> for <see cref="Mode"/> == <see cref="InteractionMode.Index"/>
/// and <see cref="AxisDirection.XY"/> for <see cref="Mode"/> == <see cref="InteractionMode.Dataset"/> or <see cref="InteractionMode.Nearest"/>.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public AxisDirection? Axis { get; set; }
/// <summary>
/// if true, the invisible points that are outside of the chart area will also be included when evaluating interactions.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public bool? IncludeInvisible { get; set; }
}

View File

@@ -0,0 +1,35 @@
using System.Text.Json.Serialization;
namespace RobotNet.WebApp.Charts.Models.Common.Plugins;
public class ChartPlugins
{
/// <summary>
/// The chart legend displays data about the datasets that are appearing on the chart.
/// </summary>
public ChartPluginsLegend Legend { get; set; } = new();
/// <summary>
/// The chart title defines text to draw at the top of the chart.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public ChartPluginsTitle? Title { get; set; }
/// <summary>
/// Tooltip for the element.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public ChartPluginsTooltip? Tooltip { get; set; }
/// <summary>
/// DataLabels for the element.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public ChartPluginsDataLabels? Datalabels { get; set; }
/// <summary>
/// Subtitle for the element.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public ChartPluginsSubtitle? Subtitle { get; set; }
}

View File

@@ -0,0 +1,37 @@
using RobotNet.WebApp.Charts.Enums;
using System.Text.Json.Serialization;
namespace RobotNet.WebApp.Charts.Models.Common.Plugins;
public class ChartPluginsDataLabels
{
public DataLabelsAlignment Align { get; set; } = DataLabelsAlignment.Center;
public DataLabelsAnchoring Anchor { get; set; } = DataLabelsAnchoring.Center;
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? BackgroundColor { get; set; }
public string BorderColor { get; set; } = "white";
public double BorderRadius { get; set; } = 25;
public double BorderWidth { get; set; } = 2;
public bool Clamp { get; set; } = false;
public bool Clip { get; set; } = false;
public string Color { get; set; } = "white";
public bool Display { get; set; } = true;
public ChartFont Font { get; set; } = new();
public int Offset { get; set; } = 4;
public double Opacity { get; set; } = 1;
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public ChartPadding? Padding { get; set; }
public int Rotation { get; set; }
public DataLabelsAlignment TextAlign { get; set; } = DataLabelsAlignment.Center;
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? TextStrokeColor { get; set; }
public int TextStrokeWidth { get; set; }
public int TextShadowBlur { get; set; }
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? TextShadowColor { get; set; }
}

View File

@@ -0,0 +1,67 @@
using RobotNet.WebApp.Charts.Enums;
using System.Text.Json.Serialization;
namespace RobotNet.WebApp.Charts.Models.Common.Plugins;
public class ChartPluginsLegend
{
/// <summary>
/// Alignment of the legend. Default values is 'center'. Other possible values 'start' and 'end'.
/// </summary>
public LegendAlignment Align { get; set; } = LegendAlignment.Center;
/// <summary>
/// Is the legend shown? Default value is 'true'.
/// </summary>
public bool Display { get; set; } = true;
/// <summary>
/// If <see langword="true" />, Marks that this box should take the full width/height of the canvas (moving other boxes). This is unlikely to need to be changed in day-to-day use.
/// </summary>
public bool FullSize { get; set; } = true;
/// <summary>
/// Label settings for the legend.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public ChartPluginsLegendLabels? Labels { get; set; }
/// <summary>
/// Maximum height of the legend, in pixels.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public int? MaxHeight { get; set; }
/// <summary>
/// Maximum width of the legend, in pixels.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public int? MaxWidth { get; set; }
/// <summary>
/// Position of the legend. Default value is 'top'. Other possible value is 'bottom'.
/// </summary>
public LegendPosition Position { get; set; } = LegendPosition.Top;
/// <summary>
/// If <see langword="true" />, the Legend will show datasets in reverse order.
/// </summary>
public bool Reverse { get; set; } = false;
/// <summary>
/// If <see langword="true" />, for rendering of the legends will go from right to left.
/// </summary>
public bool Rtl { get; set; } = false;
/// <summary>
/// This will force the text direction 'rtl' or 'ltr' on the canvas for rendering the legend, regardless of the css specified on the canvas
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? TextDirection { get; set; }
/// <summary>
/// Title object
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public ChartPluginsLegendTitle? Title { get; set; }
}

View File

@@ -0,0 +1,67 @@
using RobotNet.WebApp.Charts.Enums;
using System.Text.Json.Serialization;
namespace RobotNet.WebApp.Charts.Models.Common.Plugins;
public class ChartPluginsLegendLabels
{
/// <summary>
/// Width of coloured box.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public int? BoxWidth { get; set; }
/// <summary>
/// Height of the coloured box
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public int? BoxHeight { get; set; }
/// <summary>
/// Override the borderRadius to use.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public int? BorderRadius { get; set; }
/// <summary>
/// Color of label and the strikethrough.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? Color { get; set; }
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public ChartFont? Font { get; set; }
/// <summary>
/// Padding between rows of colored boxes.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public int? Padding { get; set; }
/// <summary>
/// If specified, this style of point is used for the legend. Only used if <see cref="UsePointStyle"/>> is true.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public PointStyle? PointStyle { get; set; }
/// <summary>
/// If <see cref="UsePointStyle"/> is <see langword="true" />, the width of the point style used for the legend.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public int? PointStyleWidth { get; set; }
/// <summary>
/// Label borderRadius will match corresponding <see cref="BorderRadius"/>.
/// </summary>
public bool UseBorderRadius { get; set; } = false;
/// <summary>
/// If <see langword="true"/>, Label style will match corresponding point style (size is based on pointStyleWidth or the minimum value between <see cref="BoxWidth"/> and <see cref="Font"/> -> Size).
/// </summary>
public bool UsePointStyle { get; set; } = false;
/// <summary>
/// Horizontal alignment of the label text
/// </summary>
public LegendAlignment TextAlign { get; set; } = LegendAlignment.Center;
}

View File

@@ -0,0 +1,35 @@
using System.Text.Json.Serialization;
namespace RobotNet.WebApp.Charts.Models.Common.Plugins;
public class ChartPluginsLegendTitle
{
/// <summary>
/// Color of the legend. Default value is 'black'.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? Color { get; set; }
/// <summary>
/// Is the legend title displayed.
/// </summary>
public bool Display { get; set; } = true;
/// <summary>
/// Padding around the title.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public ChartPadding? Padding { get; set; }
/// <summary>
/// The string title
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? Text { get; set; }
/// <summary>
/// Font Legend Title
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public ChartFont? Font { get; set; }
}

View File

@@ -0,0 +1,42 @@
using RobotNet.WebApp.Charts.Enums;
using System.Text.Json.Serialization;
namespace RobotNet.WebApp.Charts.Models.Common.Plugins;
public class ChartPluginsSubtitle
{
/// <summary>
/// Alignment of the title.
/// Options are: 'start', 'center', and 'end'
/// </summary>
public TitleAlignment Align { get; set; } = TitleAlignment.Center;
/// <summary>
/// Color of text.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? Color { get; set; }
/// <summary>
/// Is the title shown?
/// </summary>
public bool Display { get; set; } = true;
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public ChartFont? Font { get; set; }
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? Text { get; set; }
public bool FullSize { get; set; } = true;
/// <summary>
/// Gets or sets the position of the title.
/// </summary>
public TitlePosition Position { get; set; } = TitlePosition.Top;
/// <summary>
/// Gets or sets the number of pixels to add above and below the title text.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public ChartPadding? Padding { get; set; }
}

View File

@@ -0,0 +1,42 @@
using RobotNet.WebApp.Charts.Enums;
using System.Text.Json.Serialization;
namespace RobotNet.WebApp.Charts.Models.Common.Plugins;
public class ChartPluginsTitle
{
/// <summary>
/// Alignment of the title.
/// Options are: 'start', 'center', and 'end'
/// </summary>
public TitleAlignment Align { get; set; } = TitleAlignment.Center;
/// <summary>
/// Color of text.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? Color { get; set; }
/// <summary>
/// Is the title shown?
/// </summary>
public bool Display { get; set; } = true;
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public ChartFont? Font { get; set; }
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? Text { get; set; }
public bool FullSize { get; set; } = true;
/// <summary>
/// Gets or sets the position of the title.
/// </summary>
public TitlePosition Position { get; set; } = TitlePosition.Top;
/// <summary>
/// Gets or sets the number of pixels to add above and below the title text.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public ChartPadding? Padding { get; set; }
}

View File

@@ -0,0 +1,176 @@
using RobotNet.WebApp.Charts.Enums;
using System.Text.Json.Serialization;
namespace RobotNet.WebApp.Charts.Models.Common.Plugins;
public class ChartPluginsTooltip
{
/// <summary>
/// Background color of the tooltip.
/// </summary>
public string BackgroundColor { get; set; } = "rgba(0, 0, 0, 0.8)";
/// <summary>
/// Gets or sets which elements appear in the tooltip.
/// </summary>
public InteractionMode Mode { get; set; }
/// <summary>
/// Gets or sets the value indicating if the hover mode only applies when the mouse position intersects an item on the chart.
/// </summary>
public bool? Intersect { get; set; }
/// <summary>
/// The mode for positioning the tooltip.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public TooltipPosition? Position { get; set; } = TooltipPosition.Average;
/// <summary>
/// Horizontal alignment of the body text lines. left/right/center.
/// </summary>
public TooltipXAlignment BodyAlign { get; set; } = TooltipXAlignment.Left;
/// <summary>
/// Color of body text.
/// </summary>
public string BodyColor { get; set; } = "#fff";
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public ChartFont? BodyFont { get; set; }
/// <summary>
/// Spacing to add to top and bottom of each tooltip item.
/// </summary>
public int BodySpacing { get; set; } = 2;
/// <summary>
/// Padding for Tooltips
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public ChartPadding? Padding { get; set; }
/// <summary>
/// Extra distance to move the end of the tooltip arrow away from the tooltip point.
/// </summary>
public int CaretPadding { get; set; } = 2;
/// <summary>
/// Size, in px, of the tooltip arrow.
/// </summary>
public int CaretSize { get; set; } = 5;
/// <summary>
/// If <see langword="true" />, color boxes are shown in the tooltip.
/// </summary>
public bool DisplayColors { get; set; } = true;
/// <summary>
/// Are on-canvas tooltips enabled?
/// </summary>
public bool Enabled { get; set; } = true;
/// <summary>
/// Horizontal alignment of the footer text lines. left/right/center.
/// </summary>
public TooltipXAlignment FooterAlign { get; set; } = TooltipXAlignment.Left;
/// <summary>
/// Color of footer text.
/// </summary>
public string FooterColor { get; set; } = "#fff";
public ChartFont FooterFont { get; set; } = new();
/// <summary>
/// Margin to add before drawing the footer.
/// </summary>
public int FooterMarginTop { get; set; } = 6;
/// <summary>
/// Spacing to add to top and bottom of each footer line.
/// </summary>
public int FooterSpacing { get; set; } = 2;
/// <summary>
/// Horizontal alignment of the title text lines. left/right/center.
/// </summary>
public TooltipXAlignment TitleAlign { get; set; } = TooltipXAlignment.Left;
/// <summary>
/// Color of title text.
/// </summary>
public string TitleColor { get; set; } = "#fff";
public ChartFont TitleFont { get; set; } = new();
/// <summary>
/// Margin to add on bottom of title section.
/// </summary>
public int TitleMarginBottom { get; set; } = 6;
/// <summary>
/// Spacing to add to top and bottom of each title line.
/// </summary>
public int TitleSpacing { get; set; } = 2;
/// <summary>
/// Position of the tooltip caret in the X direction. left/center/right.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public TooltipXAlignment? XAlign { get; set; }
/// <summary>
/// Position of the tooltip caret in the Y direction. top/center/bottom.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public TooltipYAlignment? YAlign { get; set; }
/// <summary>
/// Width of the color box if displayColors is true.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public int? BoxWidth { get; set; }
/// <summary>
/// Height of the color box if displayColors is true.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public int? BoxHeight { get; set; }
/// <summary>
/// Padding between the color box and the text.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public int? BoxPadding { get; set; }
/// <summary>
/// Size of the border.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public int? BorderWidth { get; set; }
/// <summary>
/// Color of the border.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? BorderColor { get; set; }
/// <summary>
/// Use the corresponding point style (from dataset options) instead of color boxes, ex: star, triangle etc. (size is based on the minimum value between boxWidth and boxHeight).
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public bool? UsePointStyle { get; set; } = false;
/// <summary>
/// true for rendering the tooltip from right to left.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public bool? Rtl { get; set; }
/// <summary>
/// This will force the text direction 'rtl' or 'ltr' on the canvas for rendering the tooltips, regardless of the css specified on the canvas
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? TextDirection { get; set; }
}