Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Remi-Lerolle opened this issue Feb 26, 2024 · 1 comment
Closed

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

Remi-Lerolle opened this issue Feb 26, 2024 · 1 comment
Labels

Comments

@Remi-Lerolle
Copy link

Remi-Lerolle commented Feb 26, 2024

  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.

@mccartney mccartney added the Bug label Apr 13, 2024
timmolter added a commit that referenced this issue May 10, 2024
…ion was made to anchor min y axis to 0 for bar and stick category charts, but not for other category chart types.
@timmolter
Copy link
Member

fix pushed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants