Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: bullet chart cannot be rended #144

Closed
wants to merge 9 commits into from
17 changes: 3 additions & 14 deletions src/AntDesign.Charts.Docs/Demos/Bubble/Bubble_Chart.razor
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@page "/Bubble_Chart"

Check warning on line 1 in src/AntDesign.Charts.Docs/Demos/Bubble/Bubble_Chart.razor

View workflow job for this annotation

GitHub Actions / build

'ScatterConfig.PointSize' is obsolete: 'No longer supported, use Size instead' [/home/runner/work/ant-design-charts-blazor/ant-design-charts-blazor/src/AntDesign.Charts.Docs/AntDesign.Charts.Docs.csproj]

Check warning on line 1 in src/AntDesign.Charts.Docs/Demos/Bubble/Bubble_Chart.razor

View workflow job for this annotation

GitHub Actions / build

'ScatterConfig.PointSize' is obsolete: 'No longer supported, use Size instead' [/home/runner/work/ant-design-charts-blazor/ant-design-charts-blazor/src/AntDesign.Charts.Docs/AntDesign.Charts.Docs.csproj]

Check warning on line 1 in src/AntDesign.Charts.Docs/Demos/Bubble/Bubble_Chart.razor

View workflow job for this annotation

GitHub Actions / build

'ScatterConfig.Trendline' is obsolete: 'No longer supported, use RegressionLine instead' [/home/runner/work/ant-design-charts-blazor/ant-design-charts-blazor/src/AntDesign.Charts.Docs/AntDesign.Charts.Docs.csproj]

Check warning on line 1 in src/AntDesign.Charts.Docs/Demos/Bubble/Bubble_Chart.razor

View workflow job for this annotation

GitHub Actions / build

'ScatterConfig.PointSize' is obsolete: 'No longer supported, use Size instead' [/home/runner/work/ant-design-charts-blazor/ant-design-charts-blazor/src/AntDesign.Charts.Docs/AntDesign.Charts.Docs.csproj]
@inject NavigationManager NavigationManager
@inject HttpClient HttpClient

Expand All @@ -6,21 +6,10 @@
<TabPane Key="1" Tab="Sample 1">
<Scatter Config="config1" OnFirstRender="Chart1_FirstRender" />
</TabPane>
@* <TabPane Key="2" Tab="Sample 2"> *@
@* <Scatter Config="config2" OnFirstRender="Chart2_FirstRender" /> *@
@* </TabPane> *@
@*<TabPane Key="3">
<Tab>示例3</Tab>
<ChildContent>
<Bubble @ref="chart3" Data="data3" Config="config3" />
</ChildContent>

<TabPane Key="2" Tab="Sample 2">
<Scatter Config="config2" OnFirstRender="Chart2_FirstRender" />
</TabPane>
<TabPane Key="4">
<Tab>示例4</Tab>
<ChildContent>
<Bubble @ref="chart4" Data="data4" Config="config4" />
</ChildContent>
</TabPane>*@
</Tabs>

<Divider>动手实验</Divider>
Expand Down
21 changes: 14 additions & 7 deletions src/AntDesign.Charts.Docs/Demos/Bullet/Bullet_Chart.razor
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,19 @@
BulletConfig config1 = new BulletConfig()
{
Data = new BulletViewConfigData[]
{
{
new BulletViewConfigData()
{
Title = "满意度",
Measures = new int[]{83 },
Targets = new int[]{90 },
},
Title = "满意度",
Measures = new int[]{83 },
Targets = new int[]{90 },
Ranges = new double[]{100},
},
RangeMax = 100,
},
TargetField = "target",
RangeField = "ranges",
MeasureField = "measures",
XField = "title"
};


Expand Down Expand Up @@ -136,7 +140,10 @@
Ranges = new double[] {0,0.6,0.9,1},
},
},
RangeMax = 100,
TargetField = "target",
RangeField = "ranges",
MeasureField = "measures",
XField = "title",
RangeColors = new string[] { "#FFB1AC", "#FFDBA2", "#B4EBBF" },


Expand Down
20 changes: 10 additions & 10 deletions src/AntDesign.Charts.Docs/Demos/Violin/Violin_Chart.razor
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@

<Tabs>
<TabPane Key="1" Tab="Sample 1">
<Violin Data="Data" Config="_config1" />
<Violin Data="Data" Config="_config1" OnFirstRender="onChart1_FirstRender" />
</TabPane>
<TabPane Key="2" Tab="Sample 2">
<Violin Data="Data" Config="_config2" />
<Violin Data="Data" Config="_config2" OnFirstRender="onChart1_FirstRender" />
</TabPane>
<TabPane Key="3" Tab="Sample 3">
<Violin Data="Data" Config="_config3" />
<Violin Data="Data" Config="_config3" OnFirstRender="onChart1_FirstRender" />
</TabPane>
<TabPane Key="4" Tab="Sample 4">
<Violin Data="Data" Config="_config4" />
<Violin Data="Data" Config="_config4" OnFirstRender="onChart1_FirstRender" />
</TabPane>
</Tabs>

Expand All @@ -28,16 +28,16 @@
private DynamicExample _example;
private object[] Data { get; set; }

protected override void OnAfterRender(bool firstRender)
private async Task onChart1_FirstRender(IChartComponent chart)
{
base.OnAfterRender(firstRender);
_example.Chart = Chart;
var data1 = await DemoData.ViolinDataAsync(NavigationManager, HttpClient);
await chart.ChangeData(data1);
}

protected override async Task OnInitializedAsync()
protected override void OnAfterRender(bool firstRender)
{
Data = await DemoData.ViolinDataAsync(NavigationManager, HttpClient);
await base.OnInitializedAsync();
base.OnAfterRender(firstRender);
_example.Chart = Chart;
}

#region Basic violin plot
Expand Down
8 changes: 4 additions & 4 deletions src/AntDesign.Charts/Components/Base/ChartComponentBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -285,10 +285,10 @@ public async Task AfterChartRender()
{
IsCreated = true;

if (Data != null)
{
await JS.InvokeVoidAsync(InteropChangeData, Ref.Id, Data, true);
}
//if (Data != null)
//{
// await JS.InvokeVoidAsync(InteropChangeData, Ref.Id, Data, true);
//}

if (OnCreateAfter.HasDelegate)
await OnCreateAfter.InvokeAsync(this);
Expand Down
11 changes: 10 additions & 1 deletion src/AntDesign.Charts/Components/Plots/Bullet/BulletConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,15 @@ public class BulletConfig : IBulletViewConfig, IPlotConfig
public int? AppendPadding { get; set; }
[JsonPropertyName("autoFit")]
public bool? AutoFit { get; set; }

[JsonPropertyName("targetField")]
public string TargetField { get; set; }

[JsonPropertyName("rangeField")]
public string RangeField { get; set; }

[JsonPropertyName("measureField")]
public string MeasureField { get; set; }
}

public interface IBulletViewConfig : IViewConfig
Expand Down Expand Up @@ -163,7 +172,7 @@ public class BulletViewConfigData
/// <summary>
/// 目标值,array类型。支持多目标设置
/// </summary>
[JsonPropertyName("targets")]
[JsonPropertyName("target")]
public int[] Targets { get; set; }

[JsonPropertyName("markerStyle")]
Expand Down
Loading