diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 004d77ad31..a63d63f755 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -64,7 +64,7 @@ junit-testng = "1.0.5" junit4 = "4.13.2" junit5 = "5.11.0" jvm-dependency-conflict-resolution = "2.1.2" -kotlin = "2.0.10" +kotlin = "2.0.20" lincheck = "2.33" mockito = "5.12.0" nexus-publish = "2.0.0" diff --git a/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/report/csv/PlotCsv.java b/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/report/csv/PlotCsv.java index 55130a2f09..890aa63679 100644 --- a/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/report/csv/PlotCsv.java +++ b/simulator/src/main/java/com/github/benmanes/caffeine/cache/simulator/report/csv/PlotCsv.java @@ -39,6 +39,7 @@ import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.plot.DefaultDrawingSupplier; import org.jfree.chart.ui.RectangleInsets; +import org.jfree.data.Range; import org.jfree.data.category.CategoryDataset; import org.jfree.data.category.DefaultCategoryDataset; @@ -109,11 +110,30 @@ private void configurePlot(JFreeChart chart) { configureAxis(plot.getRangeAxis()); configureGrid(plot); + plot.getRangeAxis().setAutoRange(false); + plot.getRangeAxis().setRange(calculateRange(plot)); + for (int i = 0; i < plot.getCategories().size(); i++) { plot.getRenderer().setSeriesStroke(i, new BasicStroke(3.0f)); } } + private Range calculateRange(CategoryPlot plot) { + double upperBound = 0; + double lowerBound = 100; + for (int series = 0; series < plot.getDataset().getRowCount(); series++) { + for (int item = 0; item < plot.getDataset().getColumnCount(); item++) { + var value = plot.getDataset().getValue(series, item); + if (value != null) { + lowerBound = Math.min(lowerBound, value.doubleValue()); + upperBound = Math.max(upperBound, value.doubleValue()); + } + } + } + double margin = 0.1 * (upperBound - lowerBound); + return new Range(Math.max(0, lowerBound - margin), Math.min(100, upperBound + margin)); + } + private void applyTheme(JFreeChart chart) { var theme = (StandardChartTheme) StandardChartTheme.createJFreeTheme(); theme.setDrawingSupplier(new DefaultDrawingSupplier(getWheelColors(),