knowm / XChart

XChart is a light-weight Java library for plotting data.
http://knowm.org/open-source/xchart
Apache License 2.0
1.48k stars 394 forks source link

CategoryChart y axis wrong on 3.8.7 while bars are correct #826

Closed Remi-Lerolle closed 1 month ago

Remi-Lerolle commented 4 months ago
  final CategoryChart chart = new CategoryChartBuilder()
      .width(600)
      .height(400)
      .xAxisTitle("X")
      .yAxisTitle("Y")
      .build();

  ArrayList<String> years =  new ArrayList<String>( Arrays.asList( new String[]{"2012", "2013","2014","2015","2016","2017","2018", "2019", "2020", "2021", "2022"} ) );

  ArrayList<Number> yAData =  new ArrayList<Number>( Arrays.asList( new Number[]{ 4438887, 4365843, 4050498, 4757380, 4429130, 4692889, 4354087, 4530343, 4572770, 4150489, 4487793} ) );

  ArrayList<Number> yBData =  new ArrayList<Number>( Arrays.asList( new Number[]{ 3198714, 3144079, 2859215, 3430605, 3839149, 4042579, 3741823, 3890162, 3731367, 3751216, 4008249} ) );

  chart.getStyler().setOverlapped(true);
  chart.getStyler().setYAxisDecimalPattern( "###,###.##" );

  chart.addSeries("A", years, yAData);
  chart.addSeries("B", years, yBData);

   chart.getStyler().setYAxisMin( 2600000.0 );
   chart.setTitle( Double.toString(2600000.0) );

   try{
     new SwingWrapper<>(chart).displayChart();
    }catch(Exception e){
      System.out.println(e);
    }

works fine with

    <dependency>
      <groupId>org.knowm.xchart</groupId>
      <artifactId>xchart</artifactId>
      <version>3.6.5</version>
    </dependency>

image

while the most recent version of the lib, the bars are OK but the y axis is wrong:

    <dependency>
      <groupId>org.knowm.xchart</groupId>
      <artifactId>xchart</artifactId>
      <version>3.8.7</version>
    </dependency>

image

The opacity of the ultimate bar is also different from the others without reason.

timmolter commented 1 month ago

fix pushed.