Jpfcan
Jpfcan

Reputation: 137

Ranges in bar graph JFreeChart

I have created a graph with JFreeChart and I've been trying to change the ranges on the Y-axis. I need it to go from 1 to 10, but with intervals of 1 unit. (1,2,3,...,9,10) I haven't been able to find a way for that, can anyone help me?

Upvotes: 0

Views: 65

Answers (1)

Naren
Naren

Reputation: 1477

Try this it will work

    CategoryPlot p = chart.getCategoryPlot();
    final NumberAxis rangeAxis = (NumberAxis) p.getRangeAxis();
    rangeAxis.setTickUnit(new NumberTickUnit(10)); 
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

Upvotes: 1

Related Questions