Closed taylorjimbo closed 4 years ago
@taylorjimbo this is odd. I will look into this during the weekend. Is this an urgent issue for you right now?
Not urgent. Thanks for the quick response.
I don't know if this is related, but I also noticed that for Bar Charts you can only display a single Label and not a Legend.
I add the following and left the Label in the BarDataset empty, but the Legend was not displayed.
Options = new BarOptions { Legend = new Legend { Position = Position.Left, Labels = new LegendLabelConfiguration { UsePointStyle = true }, Display = true },
I have changed some of my Bar Charts to doughnut/pie charts and I noticed that whenever I call the Chart Update method that I lose the On Click Handler.
_doughnutChartJs.Update();
Hi there
I think you saw two different bugs. One had to do with the Update() method wiping out any registered click/hover handlers (Issue 54) and the other is a serialization exception while marshaling the click/hover event args from the JS Runtime to Mono.
The second bug was caused by a circular reference which broke the serialization.
Both should be fixed and I just released a new NuGet package.
As always, please feel free to open the issue again if you believe the problem isn't really fixed.
Sweet! Just tested on the bar charts and the On Click works.
Another issue in the same area is that the On Click handler args from TimeBarChart does not have a label in the _model or _view. This makes is impossible to know which bar they clicked on.
Update: It is NOT impossible to know which bar they clicked on in a TimeBarChart. It is just a little extra work.
I had to reference it by the Index in the args.
The defined OnClick handler is not being fired when the bar is click, but when the legend is clicked
Code example
@page
"/test"@using ChartJs.Blazor.Charts @using ChartJs.Blazor.ChartJS.Common.Properties @using ChartJs.Blazor.Util @using ChartJs.Blazor.ChartJS.BarChart @using ChartJs.Blazor.ChartJS.BarChart.Axes @using ChartJs.Blazor.ChartJS.Common.Axes @using ChartJs.Blazor.ChartJS.Common.Wrappers @using ChartJs.Blazor.ChartJS.Common.Axes.Ticks @using ChartJs.Blazor.ChartJS.Common.Handlers.OnClickHandler @using Newtonsoft.Json
<ChartJsBarChart @ref="barChartJs" Config="@_config" Height="250" />
<button type="button" class="btn btn-outline-danger" @onclick="OnClear">Clear
<textarea rows="@Rows" @bind-value="@EventArgs" @bind-value:event="oninput" style="width: 100%; resize: both; height:auto ">
@code {
}`