After Search
I found this sample how to display bar value on top of bar javafx, But that when bar separated on the category axis so each
category data has a single bar
and Listener can be added to that data (Category).But with
StackedBarChart
each category consists of StackedBar.I try that code simple based on the @jewelsea code.
That solution work prefect if all series are symmetric and contain all the categories.
But with non-symmetric series
ObservableList<StackedBarChart.Series> barChartData = FXCollections.observableArrayList( new StackedBarChart.Series("Region 1", FXCollections.observableArrayList( new StackedBarChart.Data(years[0], 567d), new StackedBarChart.Data(years[1], 1292d), new StackedBarChart.Data(years[2], 1292d))), new StackedBarChart.Series("Region 2", FXCollections.observableArrayList( new StackedBarChart.Data(years[0], 956), new StackedBarChart.Data(years[1], 1665), new StackedBarChart.Data(years[2], 2559))), new StackedBarChart.Series("Region 3", FXCollections.observableArrayList( new StackedBarChart.Data(years[0], 1154), //new StackedBarChart.Data(years[1], 1927),// series names Region 3(which is the last series on the chart data) doesn't exist category years[1] "2008". new StackedBarChart.Data(years[2], 2774))));
We will miss Text on top of category 2008.
Any help are welcome.