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

[Bug Report] 1.72之后piechart点击图例隐藏图表数据的功能失效了 #2299

Closed
bdon4000 opened this issue Dec 27, 2024 · 6 comments
Labels
component/ECharts status/resolved The issue has been fixed

Comments

@bdon4000
Copy link

Masa.Blazor version

1.72

Hosting model

Blazor Server

Describe the bug

测试过最新的好用的版本是1.71。1.72之后点击图例只会让饼状图内对应区域重新刷新

Expected Behavior

No response

Steps To Reproduce

No response

Reproduction code

No response

.NET version

.net9

@capdiem
Copy link
Contributor

capdiem commented Dec 27, 2024

@bdon4000 https://github.com/masastack/MASA.Blazor/releases/tag/1.7.2 似乎没有改动echarts相关的代码,你是用了点击事件吗?你能提供复现代码吗?

@bdon4000
Copy link
Author

bdon4000 commented Dec 27, 2024

@bdon4000 https://github.com/masastack/MASA.Blazor/releases/tag/1.7.2 似乎没有改动echarts相关的代码,你是用了点击事件吗?你能提供复现代码吗?
我用单独的一个chart页面测试的

@page "/pages/others/500"
@inherits ProComponentBase
@layout MainLayout


<MCard Class="ma-4">
    <MCardTitle>Test Pie Chart</MCardTitle>
    <MCardText>
        <div style="height: 400px">
            <MECharts Style="height: 100%; width: 100%"
                      Option="@GetChartOption()">
            </MECharts>
        </div>
    </MCardText>
</MCard>

@code {
    private object GetChartOption()
    {
        var data = new[]
        {
            new { value = 1048, name = "Category A", itemStyle = new { color = "#FF4560" } },
            new { value = 735, name = "Category B", itemStyle = new { color = "#FEB019" } },
            new { value = 580, name = "Category C", itemStyle = new { color = "#775DD0" } },
            new { value = 484, name = "Category D", itemStyle = new { color = "#00E396" } },
            new { value = 300, name = "Category E", itemStyle = new { color = "#008FFB" } }
        };

        return new
        {
            tooltip = new
            {
                trigger = "item",
                formatter = "{b}: {c} ({d}%)"
            },
            legend = new
            {
                type = "plain",
                orient = "vertical",
                right = "10%",
                top = "middle"
            },
            series = new[]
            {
                new
                {
                    name = "Test Data",
                    type = "pie",
                    radius = "70%",
                    center = new[] { "40%", "50%" },
                    data = data,
                    emphasis = new
                    {
                        itemStyle = new
                        {
                            shadowBlur = 10,
                            shadowOffsetX = 0,
                            shadowColor = "rgba(0, 0, 0, 0.5)"
                        }
                    }
                }
            }
        };
    }
}

<style>
    /* 可选:添加一些自定义样式 */
    ::deep .echarts {
        border-radius: 8px;
    }
</style>

@capdiem
Copy link
Contributor

capdiem commented Dec 27, 2024

@bdon4000 我觉得问题是 Option=@GetChartOption(),这样写每次渲染都会重新设置Option,你应该用一个变成保存option。

@capdiem capdiem added status/resolved The issue has been fixed and removed status/needs feedback labels Dec 27, 2024
@bdon4000
Copy link
Author

@bdon4000 我觉得问题是 Option=@GetChartOption(),这样写每次渲染都会重新设置Option,你应该用一个变成保存option。

@page "/pages/others/500"
@inherits ProComponentBase
@layout MainLayout

Test Pie Chart
直接把数据写进option也会出现。我的测试方法是新建一个MasaBlazor Server项目,直接用这段代码替换掉/Pages/Others/Error.razor。使用的是net8.0

@capdiem
Copy link
Contributor

capdiem commented Dec 28, 2024

@bdon4000 我测试过了,你原来的写法有问题,改成我说的那样就没问题了。

<MECharts Style="height: 100%; width: 100%"
          Option="@_option">
</MECharts>

@code {
    private object _option = null;

    protected override void OnInitialized()
    {
        base.OnInitialized();
        _option = GetChartOption();
    }
}

@bdon4000
Copy link
Author

解决了 非常感谢帮助

@capdiem capdiem closed this as completed Jan 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/ECharts status/resolved The issue has been fixed
Projects
None yet
Development

No branches or pull requests

2 participants