Tubes2Ride Tubes2Ride - 1 year ago 139
Java Question

How to control the increments of values on the Y-Axis of BarChart

I am attempting to make uniform my barchart which ranges in a wide number of values. I have attempted to adjust the tick and other ranges. Essentially, I would like to increase the increments on the yAxis to fit all the bars proportionately. Any ideas?

Also, I should note that instead of NumberAxis, I get ValueAxis.

Thanks in advance.enter image description here

Answer Source

So this is how I ended up getting the values to square up including setting the RangeAxis range dynamically. I also removed the 3d elements on suggestion of @FredK. I am using a DefaultCategoryDataSet, so the code below is appropriate for these conditions...

  LogAxis yAxis = new LogAxis("Transaction Time (ms)");

        yAxis.setTickUnit(new NumberTickUnit(1));
        plot.getRangeAxis().setLabelFont(new Font("SansSerif", Font.BOLD, 14));
        plot.getRangeAxis().setTickLabelFont(new Font("SansSerif", Font.BOLD, 12));

        Double maximum = (Double) DatasetUtilities.findMaximumRangeValue(dataset);

        plot.getRangeAxis().setUpperBound(maximum * 1.6);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download