ant-design-blazor / ant-design-blazor/ant-design-charts-blazor

Pie chart not show when load data from api

未关闭
#35 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
C#
星标
186
派生
44
PR 合并指标
30 天内没有已合并 PR

描述

Hi, like [this issue](https://github.com/ant-design-blazor/ant-design-charts-blazor/issues/28), but this case is Pie chart, and can't use `ChangeData `method to load data. Pie chart only run when initialize data manual

This is code when load data from api

``

`IChartComponent pie1;`
`object[] data_pie = new object[10];`

```
protected override async Task OnInitializedAsync()
{
var dataApi = await client.GetFromJsonAsync("api/data");
if (dataApi.Data!= null && dataApi.Data.Count > 0)
{
data_pie = new object[dataApi.Data.Count];
for (var i = 0; i < dataApi.Data.Count; i++)
{
tmp = dataApi.Data[i];
data_pie [i] = new { value = tmp.A, type = tmp.B};
}
pie1.ChangeData(data_pie , true);
}
}
```
```
readonly PieConfig pieconfig = new PieConfig
{
ForceFit = true,
Title = new AntDesign.Charts.Title
{
Visible = true,
Text = "Multicolor Pie Chart"
},
Description = new Description
{
Visible = true,
Text = "Specify the color mapping field (colorField), and the pie slice will be displayed in different colors according to the field data. To specify the color, you need to configure the color as an array. \nWhen the pie chart label type is set to inner, the label will be displayed inside the slice. Set the offset value of the offset control label."
},
Radius = 0.8,
AngleField = "value",
ColorField = "type",
Label = new PieLabelConfig
{
Visible = true,
Type = "inner"
}
};
```

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。