Tubes2Ride Tubes2Ride - 4 months ago 8
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

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.setBase(10);
        plot.setRangeAxis(yAxis);
        yAxis.setTickUnit(new NumberTickUnit(1));
        yAxis.setMinorTickMarksVisible(true);
        yAxis.setAutoRange(true);
        plot.setRangeAxis(yAxis);
        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().setLowerBound(10);
        plot.getRangeAxis().setUpperBound(maximum * 1.6);
Comments