erossini / BlazorChartjs

Creates beautiful charts in Blazor using Chart.js. Library for NET6, NET7 and NET8. Source code and demo available.
https://www.puresourcecode.com/dotnet/blazor/blazor-component-for-chartjs/
MIT License
116 stars 44 forks source link

Does OnChartClick and OnChartOver not fired? #35

Closed gmlloves closed 1 year ago

gmlloves commented 1 year ago

Hello :)

Is your feature request related to a problem? Please describe. I need to know when a bar on the Bar Chart is clicked. I tried with OnChartClick and OnChartOver events but it does not write nothing to the console. Can you help me?

<Chart Config="_config1" @ref="_chart1" Class="mt-2 ml-2" Width="100px" 
    OnChartClick="(i) => OnChartClick(i)"
    OnChartOver="() => OnChartOver()"></Chart>

@code {
...

    private void OnChartOver()
    {
        Console.WriteLine("ChartOver");
    }

    private void OnChartClick(int i)
    {
        Console.WriteLine("ChartClick " + i);
    }
}

Describe the solution you'd like I'd like the OnChartClick and OnChartOver work (with their parameters) .

https://www.chartjs.org/docs/2.8.0/general/interactions/events.html --> onHover: Called when any of the events fire. Called in the context of the chart and passed the event and an array of active elements (bars, points, etc).

OnClick: Called if the event is of type 'mouseup' or 'click'. Called in the context of the chart and passed the event and an array of active elements.

Thank you.

erossini commented 1 year ago

Hey! I have just release a new version of the component and I added a better OnClickChart. More info on PureSorceCode.com

Please let me know if it is working.

gmlloves commented 1 year ago

Hello, It woks very well :) Thank you!