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)
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
here explanation w.r.t numbers.
- setlowermargin(double margin).
- setuppermargin(double margin).
- setcategorymargin(double margin).
- 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
Comments
Post a Comment