java - Closing up blank space in JFreeChart bar chart -


i using jfreechart , display bar chart of player's scores, score on y-axis , player's games grouped on x-axis.

e.g.

string[] {player name, score, game number} player 1, 10 , 1 player 1, 12 , 2 player 1, 15 , 3 player 2, 11 , 1 player 3, 18 , 1 

because players not have play same number of games, results in lot of blank space when dataset created, tries plot bar player 2 & 3 games 2 & 3.

data.addvalue(score, game number, player name); 

output: (the numbers dont quite match, quick test knocked up) note blank space in player 1 game 3 , player 3 games 1 , 2

can me how close blank space? in theory player 1 go on play 100s of games player 2 , 3 playing few, quite ridiculous! new jfreechart there obvious solution!

thank in advance help.

first @ picture enter image description here

here explanation w.r.t numbers.

  1. setlowermargin(double margin).
  2. setuppermargin(double margin).
  3. setcategorymargin(double margin).
  4. setitemmargin(double margin).

here how can use methods in chart

 categoryplot p = chart.getcategoryplot();    categoryaxis axis = p.getdomainaxis();  axis.setlowermargin(0.1);  axis.setuppermargin(0.1);  axis.setcategorymargin(0.1);  barrenderer renderer = (barrenderer) p.getrenderer();  renderer.setitemmargin(0.1);  

you can set value between 0.0 1.0 (example 0.1 means 10%)

hope helps

(update after comment) in case should use layered bar chart

enter image description here


Comments

Popular posts from this blog

Retrieving ETA (estimated time of arrival) with Google Distance Matrix API and public transit as transport mode -

javascript - Confirm a form & display message if form is valid with JQuery -

ionic framework - Meteor - Error: Failed to execute 'insertBefore' on 'Node' -