-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathUtilityChart.cs
92 lines (83 loc) · 2.34 KB
/
UtilityChart.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
// Copyright (c) Argo Zhang ([email protected]). All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
// Website: https://www.blazor.zone or https://argozhang.github.io/
using BootstrapBlazor.Components;
namespace b06chart;
/// <summary>
/// Chart 工具类
/// </summary>
internal static class UtilityChart
{
public static IEnumerable<string> Colors { get; } = new List<string>() { "Red", "Blue", "Green", "Orange", "Yellow", "Tomato", "Pink", "Violet" };
/// <summary>
///
/// </summary>
/// <param name="chart"></param>
public static Task RandomData(Chart chart) => chart.Update(ChartAction.Update);
/// <summary>
///
/// </summary>
/// <param name="chart"></param>
/// <param name="dsCount"></param>
public static void AddDataSet(Chart chart, ref int dsCount)
{
if (dsCount < Colors.Count())
{
dsCount++;
_ = chart.Update(ChartAction.AddDataset);
}
}
/// <summary>
///
/// </summary>
/// <param name="chart"></param>
/// <param name="dsCount"></param>
public static void RemoveDataSet(Chart chart, ref int dsCount)
{
if (dsCount > 1)
{
dsCount--;
_ = chart.Update(ChartAction.RemoveDataset);
}
}
/// <summary>
///
/// </summary>
/// <param name="chart"></param>
/// <param name="daCount"></param>
public static void AddData(Chart chart, ref int daCount)
{
var limit = chart.ChartType switch
{
ChartType.Line => 14,
ChartType.Bar => 14,
ChartType.Bubble => 14,
_ => Colors.Count()
};
if (daCount < limit)
{
daCount++;
_ = chart.Update(ChartAction.AddData);
}
}
/// <summary>
///
/// </summary>
/// <param name="chart"></param>
/// <param name="daCount"></param>
public static void RemoveData(Chart chart, ref int daCount)
{
var limit = chart.ChartType switch
{
ChartType.Line => 7,
ChartType.Bar => 7,
ChartType.Bubble => 4,
_ => 2
};
if (daCount > limit)
{
daCount--;
_ = chart.Update(ChartAction.RemoveData);
}
}
}