feat(Chart): support min/max on Y axis (#3890)

* feat: 支持 y 轴设置建议最大值最小值

* refactor: 重构代码

* chore: bump version 8.1.6
This commit is contained in:
Argo Zhang 2024-07-21 16:39:01 +08:00 committed by GitHub
parent 8e4777c2a1
commit 33508fc5de
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 41 additions and 3 deletions

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">
<PropertyGroup>
<Version>8.1.5</Version>
<Version>8.1.6</Version>
<PackageTags>Bootstrap Blazor WebAssembly wasm UI Components Chart</PackageTags>
<Description>Bootstrap UI components extensions of Chart.js</Description>
</PropertyGroup>

View File

@ -132,6 +132,22 @@ const getChartOption = function (option) {
}
}
if (option.options.yScalesSuggestedMin) {
scale.y.suggestedMin = option.options.yScalesSuggestedMin;
}
if (option.options.yScalesSuggestedMax) {
scale.y.suggestedMax = option.options.yScalesSuggestedMax;
}
if (option.options.yScalesMin) {
scale.y.min = option.options.yScalesMin;
}
if (option.options.yScalesMax) {
scale.y.max = option.options.yScalesMax;
}
let legend = {
display: option.options.showLegend,
position: option.options.legendPosition

View File

@ -29,13 +29,11 @@ public class ChartOptions
/// <summary>
/// 获得 Y 坐标轴实例集合
/// </summary>
public ChartAxes Y { get; } = new ChartAxes();
/// <summary>
/// 获得 Y2 坐标轴实例集合
/// </summary>
public ChartAxes Y2 { get; } = new ChartAxes();
/// <summary>
@ -134,6 +132,30 @@ public class ChartOptions
/// </summary>
public string? YScalesBorderColor { get; set; }
/// <summary>
/// 获得/设置 Y轴边界建议最小值
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public int? YScalesSuggestedMin { get; set; }
/// <summary>
/// 获得/设置 Y轴边界建议最大值
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public int? YScalesSuggestedMax { get; set; }
/// <summary>
/// 获得/设置 Y轴边界最小值
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public int? YScalesMin { get; set; }
/// <summary>
/// 获得/设置 Y轴边界最大值
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public int? YScalesMax { get; set; }
/// <summary>
/// 获得/设置 X轴网格线颜色
/// </summary>