Open enver-haase opened 2 years ago
Related: #3741
It is not clear what should happen when label is clicked as there is three drill downs associated.
Just noting, the drill down works correctly by clicking the data series items themselves.
I can propose two alternative workarounds.
The first one is to disable drill down by label clicking.
@CssImport(value = "./vaadin-chart.css", themeFor = "vaadin-chart")
vaadin-chart.css
.highcharts-drilldown-axis-label {
pointer-events: none;
text-decoration: unset !important;
}
This will guide the user to use the functionality that works.
Alternatively you can filter out event on server side using
private static Series getPointDrilldown(
DrilldownCallback.DrilldownDetails event) {
if (event.getItem().getName().startsWith("Projekt")) {
return null;
}
...
The root cause of this problem is that the current drill down callback implementation assumes only one drill down event per user click. However, in the case of stacked columns when you click the category label under the column, you will actually get a drill down event for all the DataSeriesItems belonging to the category. This confuses the current implementation and it acts as the user would be drilling down to deeper levels of items (nested drill down). The potential fix would be that https://github.com/vaadin/flow-components/blob/643c992de9c3afa649e247ec277b382364a1d810/vaadin-charts-flow-parent/vaadin-charts-flow/src/main/java/com/vaadin/flow/component/charts/Chart.java#L661 will be refactored to handle multiple drilled down series at the same time (single stack is not sufficient). Also it should be expected that when the user drills up in this type of a scenario, there will be multiple drill up event callbacks as well respectively for each drilled down datapoint.
"one drill down event / user click"
The "/" reads "per" here.
From what I can see, the refactoring of the current implementation to support multiple drilled-down series can become a bit complex.
There isn't an easy way to tell from Highcharts drill-down events, which ones belong to the same action (when the user clicks on the category label, for instance).
There's a way, however, to tell if a click is made from the category by checking the points
(which returns false
or a list of points) and the category
(which returns undefined
or the category index) from the Highcharts drilldown
event.
Using this information, the right Series
could be given to the drill-down callback. That would "solve" the issue presented on the logs on this issue description, but it would still not solve it completely because if the drildown callback returns series for every call, then it wouldn't be able to add the 2nd+ series.
Let me try to explain the reason for that:
DrillCallbackHandler.onDrilldown
points
information from the event and passed to the callbackThat happens because the Highcharts' method used to add the drilldown only accepts one series. There's another undocumented but public method that will not draw the new series, until Charts#applyDrilldown()
is called. This could be used instead to support multiple drilldown series, but again, it falls into the issue of finding out which events belong to the same action.
@DiegoCardoso , yes. That describes in detail what I was also thinking. This is why I proposed as first alternative to disable drilling to multiple series at the same time with CSS, as it feels to me how it should work.
@TatuLund looks like the workaround https://github.com/vaadin/flow-components/issues/3742#issuecomment-1251012214 no longer works for com.vaadin:vaadin-charts-flow:jar:23.3.19 . @DiegoCardoso any profound solution on the horizon?
Which workaround stopped working? I can't remember any changes in Charts that would make the workaround no longer work.
As for a solution to this problem, I believe there are no plans to address it now. Drilldown in stacked series doesn't seem to be a well-supported use case in Highcharts and from my research, it would require us to use some methods that are not exactly public, and even so, I am not sure how the integration on the server side would work.
Description
Clicking the ITEM NAME UNDERNEATH THE BAR:
Interestingly, the number of call-backs is exactly the number of call-backs expected, but they are item Detsinyi Chrstian - series Change --- good! Item Projekt 1 - series Detsinyi Chrstian Change --- WTF??? Item Projekt 1 - series Projekt 1 Detsinyi Chrstian Change --- WTF!???
so the call-back event data somehow depends on events handled before the current one.
Expected outcome
If you click the item description, e.g. 'Detsinyi Chrstian', then I expect three callbacks:
item Detsinyi Chrstian - series Change item Detsinyi Chrstian - series Run item Detsinyi Chrstian - series Test
-- as if you were clicking all the three defined series one after another. Customer claims this is also what happened in Charts for Vaadin 8.
Minimal reproducible example
Steps to reproduce
If you click the item description, e.g. 'Detsinyi Chrstian', then I expect three callbacks:
item Detsinyi Chrstian - series Change item Detsinyi Chrstian - series Run item Detsinyi Chrstian - series Test
-- as if you were clicking all the three defined series one after another. Customer claims this is also what happened in Charts for Vaadin 8.
Interestingly, the number of call-backs is exactly the number of call-backs expected, but they are item Detsinyi Chrstian - series Change --- good! Item Projekt 1 - series Detsinyi Chrstian Change --- WTF??? Item Projekt 1 - series Projekt 1 Detsinyi Chrstian Change --- WTF!???
You can experimentally make the call-back function in the example code 'static' and thus prove that only copies are created, no old data manipulated. Somehow Flow messes up its internal data structures with the returned Series however.
Once things have gone wrong, even clicking a value no longer creates an expected good call-back, but some Frankenstein something that has to do with the handling of previous events.
Environment
Vaadin version(s): 23.2.1 OS: macOS latest
Browsers
Chrome, Issue is not browser related