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

Added OnClick for charts #961

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

yannikHoeflich
Copy link

This PR adds an OnClick attribute for all charts here is an example for a pie chart:

<PieChart  @ref="pieChart" Width="500" OnClick="Clicked" />

@code{
    // Other stuff

    private void Clicked(string labelName){
        Console.WriteLine($"Clicked on: ${labelName}");
    }
}

The parameter for the event is the label name, sadly there is not really a better option.

@yannikHoeflich
Copy link
Author

I updated it to use the new ChartClickArgs. Now you can get the label name and index. So now it looks more like this:

<PieChart  @ref="pieChart" Width="500" OnClick="Clicked" />

@code{
    // Other stuff

    private void Clicked(ChartClickArgs args){
        Console.WriteLine($"Clicked on: {args.LabelName} with index {args.Index}");
    }
}

@gvreddy04
Copy link
Contributor

@yannikHoeflich Thank you for your time and the pull request. I'll take care of it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants