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,86 @@
using RobotNet.WebApp.Charts.Enums;
using System.Text.Json.Serialization;
namespace RobotNet.WebApp.Charts.Models.BarChart.Axes;
public class ChartAxes
{
/// <summary>
/// If true, scale will include 0 if it is not already included.
/// </summary>
public bool BeginAtZero { get; set; } = true;
/// <summary>
/// Define options for the border that run perpendicular to the axis.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public ChartAxesBorder? Border { get; set; }
/// <summary>
/// Gets or sets the grid configuration.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public ChartAxesGrid? Grid { get; set; }
/// <summary>
/// User defined maximum number for the scale, overrides maximum value from data.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public double? Max { get; set; }
/// <summary>
/// User defined minimum number for the scale, overrides minimum value from data.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public double? Min { get; set; }
/// <summary>
/// Should the data be stacked.
/// By default data is not stacked.
/// If the stacked option of the value scale (y-axis on horizontal chart) is true, positive and negative values are stacked
/// separately.
/// </summary>
public bool Stacked { get; set; }
/// <summary>
/// Adjustment used when calculating the maximum data value.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public double? SuggestedMax { get; set; }
/// <summary>
/// Adjustment used when calculating the minimum data value.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public double? SuggestedMin { get; set; }
/// <summary>
/// Gets or sets the tick configuration.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public ChartAxesTicks? Ticks { get; set; }
/// <summary>
/// Gets or sets the title configuration.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public ChartAxesTitle? Title { get; set; }
/// <summary>
/// Gets or sets the index scale type. />.
/// </summary>
/// <remarks>
/// Default value is <see langword="null" />.
/// </remarks>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public ChartAxesType? Type { get; set; } = null;
/// <summary>
/// The weight used to sort the axis. Higher weights are further away from the chart area.
/// </summary>
public int? Weight { get; set; }
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public TitlePosition? Position { get; set; }
}

View File

@@ -0,0 +1,41 @@
using System.Text.Json.Serialization;
namespace RobotNet.WebApp.Charts.Models.BarChart.Axes;
public class ChartAxesBorder
{
/// <summary>
/// The color of the border line.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? Color { get; set; }
/// <summary>
/// Length and spacing of dashes on grid lines
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public List<int>? Dash { get; set; }
/// <summary>
/// Offset for line dashes.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public int? DashOffset { get; set; }
/// <summary>
/// If <see langword="true" />, draw a border at the edge between the axis and the chart area.
/// </summary>
public bool Display { get; set; } = true;
/// <summary>
/// The width of the border line.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public int? Width { get; set; }
/// <summary>
/// z-index of the border layer. Values <= 0 are drawn under datasets, > 0 on top.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public int? Z { get; set; }
}

View File

@@ -0,0 +1,82 @@
using System.Text.Json.Serialization;
namespace RobotNet.WebApp.Charts.Models.BarChart.Axes;
public class ChartAxesGrid
{
/// <summary>
/// If <see langword="true" />, gridlines are circular (on radar and polar area charts only).
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public bool? Circular { get; set; }
/// <summary>
/// Color of the grid axis lines. Here one can write a CSS method or even a JavaScript method for a dynamic color.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? Color { get; set; }
/// <summary>
/// If false, do not display grid lines for this axis.
/// </summary>
public bool Display { get; set; } = true;
/// <summary>
/// If <see langword="true" />, draw lines on the chart area inside the axis lines. This is useful when there are multiple
/// axes and you need to control which grid lines are drawn.
/// </summary>
public bool DrawOnChartArea { get; set; } = true;
/// <summary>
/// If <see langword="true" />, draw lines beside the ticks in the axis area beside the chart.
/// </summary>
public bool DrawTicks { get; set; } = true;
/// <summary>
/// Stroke width of grid lines.
/// </summary>
public int LineWidth { get; set; } = 1;
/// <summary>
/// If <see langword="true" />, grid lines will be shifted to be between labels. This is set to true for a bar chart by
/// default.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public bool? Offset { get; set; } = false;
/// <summary>
/// Length and spacing of the tick mark line.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public List<int>? TickBorderDash { get; set; }
/// <summary>
/// Offset for the line dash of the tick mark.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public int? TickBorderDashOffset { get; set; }
/// <summary>
/// Color of the tick line. If unset, defaults to the grid line color.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? TickColor { get; set; }
/// <summary>
/// Length in pixels that the grid lines will draw into the axis area.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public int? TickLength { get; set; }
/// <summary>
/// Width of the tick mark in pixels.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public int? TickWidth { get; set; }
/// <summary>
/// z-index of the gridline layer. Values <= 0 are drawn under datasets, > 0 on top.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public int? Z { get; set; }
}

View File

@@ -0,0 +1,64 @@
using RobotNet.WebApp.Charts.Enums;
using RobotNet.WebApp.Charts.Models.Common;
using System.Text.Json.Serialization;
namespace RobotNet.WebApp.Charts.Models.BarChart.Axes;
public class ChartAxesTicks
{
[JsonPropertyName("align")]
public TicksAlignment Alignment { get; set; } = TicksAlignment.Center;
/// <summary>
/// Color of label backdrops
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? BackdropColor { get; set; }
/// <summary>
/// Padding of label backdrop
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public int? BackdropPadding { get; set; }
/// <summary>
/// Color of ticks
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? Color { get; set; }
/// <summary>
/// If <see langword="true" />, show tick labels.
/// </summary>
public bool Display { get; set; } = true;
/// <summary>
/// defines options for the major tick marks that are generated by the axis.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public ChartAxesTicksMajor? Major { get; set; }
/// <summary>
/// Sets the offset of the tick labels from the axis
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public ChartPadding? Padding { get; set; }
/// <summary>
/// If <see langword="true" />, draw a background behind the tick labels.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public bool? ShowLabelBackdrop { get; set; }
/// <summary>
/// The color of the stroke around the text.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? TextStrokeColor { get; set; }
/// <summary>
/// Stroke width around the text.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public int? TextStrokeWidth { get; set; }
}

View File

@@ -0,0 +1,10 @@
namespace RobotNet.WebApp.Charts.Models.BarChart.Axes;
public class ChartAxesTicksMajor
{
/// <summary>
/// If <see langword="true" />, major ticks are generated. A major tick will affect auto skipping and major will be defined
/// on ticks in the scriptable options context.
/// </summary>
public bool Enabled { get; set; } = false;
}

View File

@@ -0,0 +1,44 @@
using RobotNet.WebApp.Charts.Enums;
using RobotNet.WebApp.Charts.Models.Common;
using System.Text.Json.Serialization;
namespace RobotNet.WebApp.Charts.Models.BarChart.Axes;
public class ChartAxesTitle
{
/// <summary>
/// Alignment of the title.
/// Options are: 'start', 'center', and 'end'
/// </summary>
[JsonPropertyName("align")]
public TitleAlignment Alignment { get; set; } = TitleAlignment.Center;
/// <summary>
/// Color of text.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? Color { get; set; } = "black";
/// <summary>
/// Is the title shown?
/// </summary>
public bool Display { get; set; } = true;
public ChartFont? Font { get; set; } = new();
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; }
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? Text { get; set; }
}

View File

@@ -0,0 +1,118 @@
using RobotNet.WebApp.Charts.Models.Common.Dataset;
using RobotNet.WebApp.Charts.Enums;
using System.Text.Json.Serialization;
namespace RobotNet.WebApp.Charts.Models.BarChart;
public class BarChartDataset : ChartDataset<double>
{
/// <summary>
/// Percent (0-1) of the available width each bar should be within the category width.
/// 1.0 will take the whole category width and put the bars right next to each other.
/// </summary>
/// <remarks>
/// Default value is 0.9.
/// </remarks>
public double BarPercentage { get; set; } = 0.9;
/// <summary>
/// It is applied to the width of each bar, in pixels.
/// When this is enforced, barPercentage and categoryPercentage are ignored.
/// </summary>
/// <remarks>
/// Default value is <see langword="null" />.
/// </remarks>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public double? BarThickness { get; set; }
/// <summary>
/// This setting is used to avoid drawing the bar stroke at the base of the fill, or disable the border radius.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public BorderSkipped? BorderSkipped { get; set; }
/// <summary>
/// Percent (0-1) of the available width each category should be within the sample width.
/// </summary>
/// <remarks>
/// Default value is 0.8.
/// </remarks>
public double CategoryPercentage { get; set; } = 0.8;
/// <summary>
/// Should the bars be grouped on index axis.
/// When <see langword="true" />, all the datasets at same index value will be placed next to each other centering on that
/// index value.
/// When <see langword="false" />, each bar is placed on its actual index-axis value.
/// </summary>
/// <remarks>
/// Default value is <see langword="true" />.
/// </remarks>
public bool Grouped { get; set; } = true;
/// <summary>
/// The bar border radius when hovered (in pixels).
/// </summary>
/// <remarks>
/// Default value is 0.
/// </remarks>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public List<double>? HoverBorderRadius { get; set; }
/// <summary>
/// The base axis of the chart. 'x' for vertical charts and 'y' for horizontal charts.
/// Supported values are 'x' and 'y'.
/// </summary>
/// <remarks>
/// Default value is <see langword="null" />.
/// </remarks>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public IndexAxis? IndexAxis { get; set; }
/// <summary>
/// Set this to ensure that bars are not sized thicker than this.
/// </summary>
/// <remarks>
/// Default value is <see langword="null" />.
/// </remarks>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public double? MaxBarThickness { get; set; }
/// <summary>
/// Set this to ensure that bars have a minimum length in pixels.
/// </summary>
/// <remarks>
/// Default value is <see langword="null" />.
/// </remarks>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public double? MinBarLength { get; set; }
public PointStyle PointStyle { get; set; } = PointStyle.Circle;
/// <summary>
/// If <see langword="true" />, null or undefined values will not be used for spacing calculations when determining bar
/// size.
/// </summary>
/// <remarks>
/// Default value is <see langword="false" />.
/// </remarks>
public bool SkipNull { get; set; }
/// <summary>
/// The ID of the x axis to plot this dataset on.
/// </summary>
/// <remarks>
/// Default value is first x axis.
/// </remarks>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? XAxisID { get; set; }
/// <summary>
/// The ID of the y axis to plot this dataset on.
/// </summary>
/// <remarks>
/// Default value is first y axis.
/// </remarks>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? YAxisID { get; set; }
}

View File

@@ -0,0 +1,7 @@
using RobotNet.WebApp.Charts.Models.Common.Dataset;
namespace RobotNet.WebApp.Charts.Models.BarChart;
public class BarChartDatasetData(string? datasetLabel, object data, string? backgroundColor) : ChartDatasetData(datasetLabel, data, backgroundColor)
{
}

View File

@@ -0,0 +1,21 @@
using RobotNet.WebApp.Charts.Enums;
using RobotNet.WebApp.Charts.Models.Common;
namespace RobotNet.WebApp.Charts.Models.BarChart;
public class BarChartOptions : ChartOptions
{
/// <summary>
/// The base axis of the chart. 'x' for vertical charts and 'y' for horizontal charts.
/// Supported values are 'x' and 'y'.
/// </summary>
/// <remarks>
/// Default value is <see langword="null"/>.
/// </remarks>
public IndexAxis IndexAxis { get; set; } = IndexAxis.X;
public BarChartPlugins Plugins { get; set; } = new();
public BarScales Scales { get; set; } = new();
}

View File

@@ -0,0 +1,7 @@
using RobotNet.WebApp.Charts.Models.Common.Plugins;
namespace RobotNet.WebApp.Charts.Models.BarChart;
public class BarChartPlugins : ChartPlugins
{
}

View File

@@ -0,0 +1,13 @@
using RobotNet.WebApp.Charts.Models.BarChart.Axes;
using System.Text.Json.Serialization;
namespace RobotNet.WebApp.Charts.Models.BarChart;
public class BarScales
{
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public ChartAxes? X { get; set; } = new();
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public ChartAxes? Y { get; set; } = new();
}