zoomRange()如何工作? [英] how does zoomRange() works?

查看:20
本文介绍了zoomRange()如何工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要缩小 jFreeChart 中的rangeAxis,所以我使用了

I need to zoom out from rangeAxis in jFreeChart, so I've used zoomRange for this purpose.

但是我不明白什么是 lowerPercent upperPercent ?

But I didn't understand what is lowerPercent and upperPercent?

我要如下图所示设置rangeAxis.我该怎么办?

I want to set the rangeAxis as shown below in the image. How can i do that?

我已经尝试过了,但是不知道 rangeAxis.zoomRange(0,?)

I've tried this but don't know what should be the value of 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() {
        }
    }
}

推荐答案

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

By default, ValueAxis automatically adjusts its range to accommodate the dataset. You can adopt an explicit range, such as shown in the image above, using one of the setRange() methods.

rangeAxis.setRange(-8, 12);

这篇关于zoomRange()如何工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆