0

我需要从 rangeAxis in 缩小jFreeChart,所以我为此目的使用了 zoomRange 。

但我不明白什么是lowerPercentand upperPercent

我想设置 rangeAxis,如下图所示。我怎样才能做到这一点?

我试过这个,但不知道应该是什么价值rangeAxis.zoomRange(0,?)

public class Profilee  {



    double last=0;
    ChartFrame frame1;

    JFreeChart chart;
    ChartUtilities cu=new ChartUtilitiesImpl();

    public void generateProfile(double[] pointValue,double[] distance){
        ArrayList pv=new ArrayList();
        ArrayList dist=new ArrayList();

        pv.add(pointValue);
        dist.add(distance);

        XYSeries series = new XYSeries("");
        for(int i=0;i<pointValue.length-1;i++){

              series.add(last,pointValue[i]);
              last=distance[i];
         }



      XYDataset xyDataset = new XYSeriesCollection(series);
      chart= ChartFactory.createXYAreaChart("Profile View Of Contour", "Distance", "Contour Value", xyDataset, PlotOrientation.VERTICAL, true, true, false);

      ValueAxis rangeAxis = chart.getXYPlot().getRangeAxis();

      //rangeAxis.setLowerBound(-3);
      rangeAxis.zoomRange(0,?);     //What should be Value over here?
      frame1=new ChartFrame("XYLine Chart",chart);

      frame1.setVisible(true);
      frame1.setSize(1300,700);
    }


    public static void main(String ar[]){
        Profilee pro=new Profilee();
        double[] pv={3,2,3,0,5,-2,10};
        double[] dist={1,4,8,12,14,20,24};
        pro.generateProfile(pv, dist);



    }

    private static class ChartUtilitiesImpl extends ChartUtilities {

        public ChartUtilitiesImpl() {
        }
    }
}

在此处输入图像描述

4

1 回答 1

2

默认情况下,ValueAxis自动调整其范围以适应数据集。您可以使用其中一种方法采用显式范围,如上图所示setRange()

rangeAxis.setRange(-8, 12);
于 2012-04-21T21:28:04.677 回答