On Wed, 19 Jun 2024 10:21:52 GMT, Markus Mack <mm...@openjdk.org> wrote:
> This PR provides the test case given in the JBS issue, and a simple fix for > the index calculation when inserting data after previous data with duplicate > categories. > > Also, I've added a comment to `BarChart`s javadoc, clarifying the behavior > that was apparently assumed (but broken) previously. > > The index lookup is skipped for performance reasons if there are no > duplicates, corresponding to the previous implementation. > Further optimizations would be possible, but probably are not really helpful > without more extensive changes. The previous code already loops over all > categories to check if they are present, typically nested in a loop adding > many data items, thus already scaling quadratically when adding lots of > mostly unique data points. modules/javafx.controls/src/main/java/javafx/scene/chart/BarChart.java line 64: > 62: * which axis is a category axis. > 63: * > 64: * Adding data with multiple occurences of a category to a series shows > the last occurence. you probably want to add <p> on line 63 this PR does not require CSR as the change in javadoc is mere clarification rather than a substantial API change. modules/javafx.controls/src/main/java/javafx/scene/chart/BarChart.java line 215: > 213: if (!categoryAxis.getCategories().contains(category)) { > 214: // find category index in case data contains duplicate > categories > 215: int i = series.getData().size() != > categoryAxis.getCategories().size() ? series.getItemIndex(item) : this is clever: little impact on performance in the case of non-duplicate categories (the most common case). ------------- PR Review Comment: https://git.openjdk.org/jfx/pull/1476#discussion_r1647849149 PR Review Comment: https://git.openjdk.org/jfx/pull/1476#discussion_r1647851273