first commit -push
This commit is contained in:
11
RobotNet.WebApp/Charts/Enums/AxisDirection.cs
Normal file
11
RobotNet.WebApp/Charts/Enums/AxisDirection.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Enums;
|
||||
|
||||
[JsonConverter(typeof(LowerCaseEnumConverter<AxisDirection>))]
|
||||
public enum AxisDirection
|
||||
{
|
||||
X,
|
||||
Y,
|
||||
XY
|
||||
}
|
||||
7
RobotNet.WebApp/Charts/Enums/BorderAlign.cs
Normal file
7
RobotNet.WebApp/Charts/Enums/BorderAlign.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
namespace RobotNet.WebApp.Charts.Enums;
|
||||
|
||||
public enum BorderAlign
|
||||
{
|
||||
Center,
|
||||
Inner
|
||||
}
|
||||
12
RobotNet.WebApp/Charts/Enums/BorderJoinStyle.cs
Normal file
12
RobotNet.WebApp/Charts/Enums/BorderJoinStyle.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Enums;
|
||||
|
||||
|
||||
[JsonConverter(typeof(LowerCaseEnumConverter<BorderJoinStyle>))]
|
||||
public enum BorderJoinStyle
|
||||
{
|
||||
Round,
|
||||
Bevel,
|
||||
Miter
|
||||
}
|
||||
17
RobotNet.WebApp/Charts/Enums/BorderSkipped.cs
Normal file
17
RobotNet.WebApp/Charts/Enums/BorderSkipped.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Enums;
|
||||
|
||||
[JsonConverter(typeof(LowerCaseEnumConverter<BorderSkipped>))]
|
||||
public enum BorderSkipped
|
||||
{
|
||||
Start,
|
||||
End,
|
||||
Middle,
|
||||
Bottom,
|
||||
Left,
|
||||
Top,
|
||||
Right,
|
||||
False,
|
||||
True
|
||||
}
|
||||
13
RobotNet.WebApp/Charts/Enums/ChartAxesType.cs
Normal file
13
RobotNet.WebApp/Charts/Enums/ChartAxesType.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Enums;
|
||||
|
||||
[JsonConverter(typeof(LowerCaseEnumConverter<ChartAxesType>))]
|
||||
public enum ChartAxesType
|
||||
{
|
||||
Linear,
|
||||
Logarithmic,
|
||||
Category,
|
||||
Time,
|
||||
Timeseries,
|
||||
}
|
||||
17
RobotNet.WebApp/Charts/Enums/ChartType.cs
Normal file
17
RobotNet.WebApp/Charts/Enums/ChartType.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Enums;
|
||||
|
||||
[JsonConverter(typeof(CamelCaseEnumConverter<ChartType>))]
|
||||
public enum ChartType
|
||||
{
|
||||
Line,
|
||||
Bar,
|
||||
Pie,
|
||||
Doughnut,
|
||||
PolarArea,
|
||||
Radar,
|
||||
Scatter,
|
||||
Bubble
|
||||
}
|
||||
|
||||
16
RobotNet.WebApp/Charts/Enums/DataLabelsAlignment.cs
Normal file
16
RobotNet.WebApp/Charts/Enums/DataLabelsAlignment.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Enums;
|
||||
|
||||
[JsonConverter(typeof(LowerCaseEnumConverter<DataLabelsAlignment>))]
|
||||
public enum DataLabelsAlignment
|
||||
{
|
||||
Center,
|
||||
Start,
|
||||
End,
|
||||
Right,
|
||||
Bottom,
|
||||
Left,
|
||||
Top,
|
||||
None
|
||||
}
|
||||
12
RobotNet.WebApp/Charts/Enums/DataLabelsAnchoring.cs
Normal file
12
RobotNet.WebApp/Charts/Enums/DataLabelsAnchoring.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Enums;
|
||||
|
||||
[JsonConverter(typeof(LowerCaseEnumConverter<DataLabelsAnchoring>))]
|
||||
public enum DataLabelsAnchoring
|
||||
{
|
||||
Center,
|
||||
Start,
|
||||
End,
|
||||
None,
|
||||
}
|
||||
10
RobotNet.WebApp/Charts/Enums/DatasetType.cs
Normal file
10
RobotNet.WebApp/Charts/Enums/DatasetType.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Enums;
|
||||
|
||||
[JsonConverter(typeof(LowerCaseEnumConverter<DatasetType>))]
|
||||
public enum DatasetType
|
||||
{
|
||||
Bar,
|
||||
Line,
|
||||
}
|
||||
40
RobotNet.WebApp/Charts/Enums/Easing.cs
Normal file
40
RobotNet.WebApp/Charts/Enums/Easing.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Enums;
|
||||
|
||||
|
||||
[JsonConverter(typeof(LowerCaseEnumConverter<Easing>))]
|
||||
public enum Easing
|
||||
{
|
||||
Linear,
|
||||
EaseInQuad,
|
||||
EaseOutQuad,
|
||||
EaseInOutQuad,
|
||||
EaseInCubic,
|
||||
EaseOutCubic,
|
||||
EaseInOutCubic,
|
||||
EaseInQuart,
|
||||
EaseOutQuart,
|
||||
EaseInOutQuart,
|
||||
EaseInQuint,
|
||||
EaseOutQuint,
|
||||
EaseInOutQuint,
|
||||
EaseInSine,
|
||||
EaseOutSine,
|
||||
EaseInOutSine,
|
||||
EaseInExpo,
|
||||
EaseOutExpo,
|
||||
EaseInOutExpo,
|
||||
EaseInCirc,
|
||||
EaseOutCirc,
|
||||
EaseInOutCirc,
|
||||
EaseInElastic,
|
||||
EaseOutElastic,
|
||||
EaseInOutElastic,
|
||||
EaseInBack,
|
||||
EaseOutBack,
|
||||
EaseInOutBack,
|
||||
EaseInBounce,
|
||||
EaseOutBounce,
|
||||
EaseInOutBounce,
|
||||
}
|
||||
38
RobotNet.WebApp/Charts/Enums/EnumExtensions.cs
Normal file
38
RobotNet.WebApp/Charts/Enums/EnumExtensions.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
namespace RobotNet.WebApp.Charts.Enums;
|
||||
|
||||
public static class EnumExtensions
|
||||
{
|
||||
|
||||
public static string? ToChartDatasetDataLabelAlignmentString(this DataLabelsAlignment alignment) =>
|
||||
alignment switch
|
||||
{
|
||||
DataLabelsAlignment.Start => "start",
|
||||
DataLabelsAlignment.Center or DataLabelsAlignment.None => "center", // default
|
||||
DataLabelsAlignment.End => "end",
|
||||
_ => null
|
||||
};
|
||||
|
||||
public static string? ToChartDatasetDataLabelAnchorString(this DataLabelsAnchoring anchor) =>
|
||||
anchor switch
|
||||
{
|
||||
DataLabelsAnchoring.Start => "start",
|
||||
DataLabelsAnchoring.Center or DataLabelsAnchoring.None => "center", // default
|
||||
DataLabelsAnchoring.End => "end",
|
||||
_ => null
|
||||
};
|
||||
|
||||
public static string ToCssString(this Unit unit) =>
|
||||
unit switch
|
||||
{
|
||||
Unit.Em => "em",
|
||||
Unit.Percentage => "%",
|
||||
Unit.Pt => "pt",
|
||||
Unit.Px => "px",
|
||||
Unit.Rem => "rem",
|
||||
Unit.Vh => "vh",
|
||||
Unit.VMax => "vmax",
|
||||
Unit.VMin => "vmin",
|
||||
Unit.Vw => "vw",
|
||||
_ => string.Empty
|
||||
};
|
||||
}
|
||||
10
RobotNet.WebApp/Charts/Enums/IndexAxis.cs
Normal file
10
RobotNet.WebApp/Charts/Enums/IndexAxis.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Enums;
|
||||
|
||||
[JsonConverter(typeof(LowerCaseEnumConverter<IndexAxis>))]
|
||||
public enum IndexAxis
|
||||
{
|
||||
X,
|
||||
Y,
|
||||
}
|
||||
37
RobotNet.WebApp/Charts/Enums/InteractionMode.cs
Normal file
37
RobotNet.WebApp/Charts/Enums/InteractionMode.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Enums;
|
||||
|
||||
[JsonConverter(typeof(LowerCaseEnumConverter<InteractionMode>))]
|
||||
public enum InteractionMode
|
||||
{
|
||||
/// <summary>
|
||||
/// Finds items in the same dataset.
|
||||
/// </summary>
|
||||
Dataset,
|
||||
|
||||
/// <summary>
|
||||
/// Finds item at the same index.
|
||||
/// </summary>
|
||||
Index,
|
||||
|
||||
/// <summary>
|
||||
/// Gets the items that are at the nearest distance to the point.
|
||||
/// </summary>
|
||||
Nearest,
|
||||
|
||||
/// <summary>
|
||||
/// Finds all of the items that intersect the point
|
||||
/// </summary>
|
||||
Point,
|
||||
|
||||
/// <summary>
|
||||
/// Returns all items that would intersect based on the X coordinate of the position only. Would be useful for a vertical cursor implementation. Note that this only applies to cartesian charts.
|
||||
/// </summary>
|
||||
X,
|
||||
|
||||
/// <summary>
|
||||
/// Returns all items that would intersect based on the Y coordinate of the position. This would be useful for a horizontal cursor implementation. Note that this only applies to cartesian charts.
|
||||
/// </summary>
|
||||
Y
|
||||
}
|
||||
11
RobotNet.WebApp/Charts/Enums/LegendAlignment.cs
Normal file
11
RobotNet.WebApp/Charts/Enums/LegendAlignment.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Enums;
|
||||
|
||||
[JsonConverter(typeof(LowerCaseEnumConverter<LegendAlignment>))]
|
||||
public enum LegendAlignment
|
||||
{
|
||||
Start,
|
||||
Center,
|
||||
End
|
||||
}
|
||||
16
RobotNet.WebApp/Charts/Enums/LegendPosition.cs
Normal file
16
RobotNet.WebApp/Charts/Enums/LegendPosition.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Enums;
|
||||
|
||||
[JsonConverter(typeof(LowerCaseEnumConverter<LegendPosition>))]
|
||||
public enum LegendPosition
|
||||
{
|
||||
Top,
|
||||
Left,
|
||||
Bottom,
|
||||
Right,
|
||||
/// <summary>
|
||||
/// Using the 'chartArea' option the legend position is at the moment not configurable, it will always be on the left side of the chart in the middle.
|
||||
/// </summary>
|
||||
ChartArea,
|
||||
}
|
||||
52
RobotNet.WebApp/Charts/Enums/LowerCaseEnumConverter.cs
Normal file
52
RobotNet.WebApp/Charts/Enums/LowerCaseEnumConverter.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Enums;
|
||||
|
||||
public class LowerCaseEnumConverter<T> : JsonConverter<T> where T : struct, Enum
|
||||
{
|
||||
public override T Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||
{
|
||||
var value = reader.GetString();
|
||||
if (Enum.TryParse(value, true, out T result))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
throw new JsonException($"Unable to convert \"{value}\" to enum {typeof(T)}.");
|
||||
}
|
||||
|
||||
public override void Write(Utf8JsonWriter writer, T value, JsonSerializerOptions options)
|
||||
{
|
||||
writer.WriteStringValue(value.ToString().ToLower());
|
||||
}
|
||||
}
|
||||
|
||||
public class CamelCaseEnumConverter<T> : JsonConverter<T> where T : struct, Enum
|
||||
{
|
||||
public override T Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||
{
|
||||
string value = reader.GetString() ?? throw new JsonException();
|
||||
foreach (T enumValue in Enum.GetValues<T>())
|
||||
{
|
||||
if (string.Equals(CamelCaseEnumConverter<T>.ToCamelCase(enumValue.ToString()), value, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return enumValue;
|
||||
}
|
||||
}
|
||||
throw new JsonException($"Unable to convert \"{value}\" to {typeof(T)}.");
|
||||
}
|
||||
|
||||
public override void Write(Utf8JsonWriter writer, T value, JsonSerializerOptions options)
|
||||
{
|
||||
string enumString = CamelCaseEnumConverter<T>.ToCamelCase(value.ToString());
|
||||
writer.WriteStringValue(enumString);
|
||||
}
|
||||
|
||||
private static string ToCamelCase(string input)
|
||||
{
|
||||
if (string.IsNullOrEmpty(input) || char.IsLower(input[0]))
|
||||
return input;
|
||||
|
||||
return char.ToLower(input[0]) + input[1..];
|
||||
}
|
||||
}
|
||||
18
RobotNet.WebApp/Charts/Enums/PointStyle.cs
Normal file
18
RobotNet.WebApp/Charts/Enums/PointStyle.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Enums;
|
||||
|
||||
[JsonConverter(typeof(LowerCaseEnumConverter<PointStyle>))]
|
||||
public enum PointStyle
|
||||
{
|
||||
Circle,
|
||||
Cross,
|
||||
CrossRot,
|
||||
Dash,
|
||||
Line,
|
||||
Rect,
|
||||
RectRounded,
|
||||
RectRot,
|
||||
Star,
|
||||
Triangle,
|
||||
}
|
||||
11
RobotNet.WebApp/Charts/Enums/TicksAlignment.cs
Normal file
11
RobotNet.WebApp/Charts/Enums/TicksAlignment.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Enums;
|
||||
|
||||
[JsonConverter(typeof(LowerCaseEnumConverter<TicksAlignment>))]
|
||||
public enum TicksAlignment
|
||||
{
|
||||
Center,
|
||||
Start,
|
||||
End
|
||||
}
|
||||
11
RobotNet.WebApp/Charts/Enums/TitleAlignment.cs
Normal file
11
RobotNet.WebApp/Charts/Enums/TitleAlignment.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Enums;
|
||||
|
||||
[JsonConverter(typeof(LowerCaseEnumConverter<TitleAlignment>))]
|
||||
public enum TitleAlignment
|
||||
{
|
||||
Start,
|
||||
Center,
|
||||
End
|
||||
}
|
||||
12
RobotNet.WebApp/Charts/Enums/TitlePosition.cs
Normal file
12
RobotNet.WebApp/Charts/Enums/TitlePosition.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Enums;
|
||||
|
||||
[JsonConverter(typeof(LowerCaseEnumConverter<TitlePosition>))]
|
||||
public enum TitlePosition
|
||||
{
|
||||
Top,
|
||||
Left,
|
||||
Bottom,
|
||||
Right,
|
||||
}
|
||||
19
RobotNet.WebApp/Charts/Enums/TooltipAlignment.cs
Normal file
19
RobotNet.WebApp/Charts/Enums/TooltipAlignment.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Enums;
|
||||
|
||||
[JsonConverter(typeof(LowerCaseEnumConverter<TooltipXAlignment>))]
|
||||
public enum TooltipXAlignment
|
||||
{
|
||||
Left,
|
||||
Center,
|
||||
Right,
|
||||
}
|
||||
|
||||
[JsonConverter(typeof(LowerCaseEnumConverter<TooltipYAlignment>))]
|
||||
public enum TooltipYAlignment
|
||||
{
|
||||
Top,
|
||||
Center,
|
||||
Bottom,
|
||||
}
|
||||
11
RobotNet.WebApp/Charts/Enums/TooltipPosition.cs
Normal file
11
RobotNet.WebApp/Charts/Enums/TooltipPosition.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Enums;
|
||||
|
||||
|
||||
[JsonConverter(typeof(LowerCaseEnumConverter<TooltipPosition>))]
|
||||
public enum TooltipPosition
|
||||
{
|
||||
Average,
|
||||
Nearest
|
||||
}
|
||||
57
RobotNet.WebApp/Charts/Enums/Unit.cs
Normal file
57
RobotNet.WebApp/Charts/Enums/Unit.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace RobotNet.WebApp.Charts.Enums;
|
||||
|
||||
[JsonConverter(typeof(LowerCaseEnumConverter<Unit>))]
|
||||
public enum Unit
|
||||
{
|
||||
/// <summary>
|
||||
/// No unit.
|
||||
/// </summary>
|
||||
None,
|
||||
|
||||
/// <summary>
|
||||
/// Ems.
|
||||
/// </summary>
|
||||
Em,
|
||||
|
||||
/// <summary>
|
||||
/// Percent.
|
||||
/// </summary>
|
||||
Percentage,
|
||||
|
||||
/// <summary>
|
||||
/// Points.
|
||||
/// </summary>
|
||||
Pt,
|
||||
|
||||
/// <summary>
|
||||
/// Pixels.
|
||||
/// </summary>
|
||||
Px,
|
||||
|
||||
/// <summary>
|
||||
/// Root ems.
|
||||
/// </summary>
|
||||
Rem,
|
||||
|
||||
/// <summary>
|
||||
/// Viewport height.
|
||||
/// </summary>
|
||||
Vh,
|
||||
|
||||
/// <summary>
|
||||
/// Viewport maximum height.
|
||||
/// </summary>
|
||||
VMax,
|
||||
|
||||
/// <summary>
|
||||
/// Viewport minimum height.
|
||||
/// </summary>
|
||||
VMin,
|
||||
|
||||
/// <summary>
|
||||
/// Viewport width.
|
||||
/// </summary>
|
||||
Vw
|
||||
}
|
||||
Reference in New Issue
Block a user