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

LineChart does not Update #4819

Closed
mikepasoglou opened this issue Jun 15, 2023 · 0 comments
Closed

LineChart does not Update #4819

mikepasoglou opened this issue Jun 15, 2023 · 0 comments
Labels
Status: Investigate Needs to investigate more to what can be done. Status: Not Planned Type: Bug 🐞 Something isn't working

Comments

@mikepasoglou
Copy link

mikepasoglou commented Jun 15, 2023

I dont know if the following is a bug or I made something wrong.

I use the following code to display a line chat in my app.
In case that i use method HandleRedraw_VER1() everything is ok but this way is not suitable for my progect .
In case that i use method HandleRedraw_VER2() nothing happens

Please check my code

@page "/"
@inject IVersionProvider VersionProvider

@using Blazorise.Charts

<Heading Size="HeadingSize.Is1" Margin="Margin.Is3.FromBottom">Blazorise</Heading>


<body>

    <Button Color="Color.Primary" Clicked="@(async () => await HandleRedraw_VER2())">Refresh</Button>

    <Div Class="Εxpenseschart">
        <Alert Color="Color.Info" Visible>
            <Paragraph>
                Εxpenses
            </Paragraph>
        </Alert>
        <LineChart @ref="lineChart" TItem="double" />
    </Div>

</body>



@code {

    private LineChart<double> lineChart;
    private List<string> LabelList = new List<string>() { "l1", "l2" };

    private static string[] XLabels = new string[] { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Okt", "Nob", "Dec" };
    private static string[] BackgroundColors = new string[12] { "#4bc1c0", "#36a2eb", "#ff3d88", "#4cc0c0",
                                                           "#30a2eb", "#ff3188", "#4bh0c0", "#31a2eb", "#fg3d88", "#f13d88", "#3212eb", "#f16d88" };

    private static string[] BorderColors = new string[12] { "#4bc0c0", "#36a2eb", "#ff3d88", "#4bc0c0",
                                                           "#36a2eb", "#ff3d88", "#4bc0c0", "#36a2eb", "#ff3d88", "#4bc0c0", "#36a2eb", "#ff3d88" };



    protected override async Task OnInitializedAsync()
    {
        base.OnInitialized();
    }



    protected override async Task OnAfterRenderAsync(bool firstRender)
    {
        if (firstRender)
        {
          //  await HandleRedraw_VER1();  //This is OK
              await HandleRedraw_VER2();
        }
    }

    /*/
    async Task HandleRedraw_VER1()  //  This is OK
    {
        await lineChart.Clear();
        await lineChart.AddLabelsDatasetsAndUpdate(XLabels
             , GetLineChartDataset1(0) , GetLineChartDataset2(1));

    }
    */

  
    async Task HandleRedraw_VER2()
    {
        await lineChart.Clear();
        await lineChart.AddLabels(LabelList);
        await lineChart.AddDataSet(GetLineChartDataset1(0));
        await lineChart.AddDataSet(GetLineChartDataset1(1));
        await lineChart.Update();

    }


    private LineChartDataset<double> GetLineChartDataset1(int colorIndex)
    {

        return new()
            {
                Label = LabelList[colorIndex],
                Data = new List<double> { 100,0,300,0,0, 450,0,100,0,0,0,0},
                BackgroundColor = BackgroundColors[colorIndex],
                BorderColor = BorderColors[colorIndex]
            };
    }



    private LineChartDataset<double> GetLineChartDataset2(int colorIndex)
    {

        return new()
            {
                Label = LabelList[colorIndex],
                Data = new List<double> { 10, 20, 30, 100, 100, 60, 0, 0, 100, 0, 450, 50 },
                BackgroundColor = BackgroundColors[colorIndex],
                BorderColor = BorderColors[colorIndex]
            };
    }


}

Thanks in advance for your support
Michalis

@mikepasoglou mikepasoglou added the Type: Bug 🐞 Something isn't working label Jun 15, 2023
@stsrki stsrki added the Status: Investigate Needs to investigate more to what can be done. label Jun 16, 2023
@stsrki stsrki added this to Support Aug 3, 2024
@stsrki stsrki moved this to 🔙 Backlog in Support Aug 3, 2024
@stsrki stsrki closed this as completed Feb 21, 2025
@github-project-automation github-project-automation bot moved this from 🔙 Backlog to ✔ Done in Support Feb 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Investigate Needs to investigate more to what can be done. Status: Not Planned Type: Bug 🐞 Something isn't working
Projects
Status: ✔ Done
Development

No branches or pull requests

2 participants