jfreechart的散点图竖轴数据反了是什么原因?

图片说明
********************代码*******************************
public class Panal_gong extends JPanel implements ActionListener{

private static final long serialVersionUID = -5628586708228044760L;
public   static DatePicker  field_wave =null ;
public   static DatePicker field2_wave=null;
private  JButton button_seasrch =null;//搜索按钮
private  static JFreeChart mChart =null;//图表
private static BorderLayout borderLayout = new BorderLayout();
private WellDynamics wd;

public static JFreeChart getmChart() {
    return Panal_gong.mChart;
}

public WellDynamics getWd() {
    return wd;
}

public void setWd(WellDynamics wd) {
    this.wd = wd;
}

public static void setmChart(JFreeChart mChart) {
    Panal_gong.mChart = mChart;
}



public Panal_gong() {
    initComponents();
    // 确保一个漂亮的外观风格
}

public Panal_gong(WellDynamics wave) throws HeadlessException {
    super();
    this.setLayout(borderLayout);//设置布局管理器
    this.setWd(wave);
    ChartPanel cf = new ChartPanel (createChart(""));
    /*ChartPanel添加节点鼠标点击事件,节点上没找到鼠标点击事件*/

// cf.addChartMouseListener(new MyXYLineChartListener(wave)); //MyXYLineChartListener
this.add(cf,BorderLayout.CENTER) ;
}

/**
 * 创建数据集合
 * @return dataSet
 */
private static XYDataset createDataset(List<Double> list1,List<Double> list2,List<Double> list3) {
    final XYSeries xyseries = new XYSeries("位移-载荷");
    final XYSeries maxSeries = new XYSeries("最大载荷:"+ Collections.max(list2)+"KN");
    final XYSeries minSeries = new XYSeries("最小载荷:"+Collections.min(list2)+"KN");
    XYSeries cc0Series = null;
    XYSeries cc1Series = null;
    if(list3.size()>0){
        cc0Series = new XYSeries("冲次:"+list3.get(list3.size()-2));
        cc1Series = new XYSeries("冲程:"+list3.get(list3.size()-1));
    }
    xyseries.add(0, null);//原点坐标的值
    if(null != list1){
        for (int i = 0; i < list1.size(); i++) {
            xyseries.add(list1.get(i), list2.get(i));
        }
    }
    final XYSeriesCollection xyseriescollection = new XYSeriesCollection();
    xyseriescollection.addSeries(xyseries);
    xyseriescollection.addSeries(maxSeries);
    xyseriescollection.addSeries(minSeries);
    if(null != cc0Series && null != cc1Series) {
        xyseriescollection.addSeries(cc0Series);
        xyseriescollection.addSeries(cc1Series);
    }

    return xyseriescollection;
}


/**
 * 初始化界面
 */
private void initComponents() {
    BorderLayout borderLayout = new BorderLayout();
    this.setLayout(borderLayout);
    //画功图
    this.add(initTime(),BorderLayout.NORTH);
    ChartPanel cf = new ChartPanel (createChart(""));
    this.add(cf,BorderLayout.CENTER) ;
}

/*
 * 初始化头部的时间控件
 * */
private  JPanel initTime (){
    FlowLayout flowLayout = new FlowLayout();
    JPanel panel_top = new JPanel(flowLayout);
    Label label = new Label("起止时间");
    Label label2 = new Label("终止时间");
    Panal_gong.field_wave = CreateDatePikerDilog.getDatePicker();
    Panal_gong.field2_wave = CreateDatePikerDilog.getDatePicker();
    this.button_seasrch = new JButton("搜索");
    this.button_seasrch.addActionListener(this);
    panel_top.add(label);
    panel_top.add(Panal_gong.field_wave);
    panel_top.add(label2);
    panel_top.add(Panal_gong.field2_wave);
    panel_top.add(button_seasrch);
    return panel_top;
}


// 返回char对象
private JFreeChart createChart(String title){
    //下面是代码
    StandardChartTheme mChartTheme = new StandardChartTheme("CN");
    mChartTheme.setExtraLargeFont(new Font("隶书", Font.BOLD, 25)); //设置标题字体  
    mChartTheme.setRegularFont(new Font("宋体", Font.PLAIN, 15)); //设置图例的字体  
    mChartTheme.setLargeFont(new Font("宋体", Font.PLAIN, 20)); //设置轴向的字体  
    ChartFactory.setChartTheme(mChartTheme);        
    XYDataset mDataset = createDataset(wd.getxList(),wd.getyList(),wd.getzList());
    Panal_gong.mChart = ChartFactory.createScatterPlot(
            title +"井口功图",
            "位移(m)",
            "载荷(KN)",
            mDataset,
            PlotOrientation.VERTICAL,
            true, 
            true, 
            false);
    /**
     * 影藏掉图列的位置
     */
    Panal_gong.mChart.getLegend().setBorder(0, 0, 0, 0);
    XYPlot mPlot = Panal_gong.mChart.getXYPlot();
    NumberAxis numberaxis = (NumberAxis) mPlot.getRangeAxis();
    numberaxis.setInverted(true); 
    mPlot.setDataset(1, null);//添加一个数据源
    mPlot.mapDatasetToRangeAxis(1, 1);  //默认在主轴显示数据,这个方法改变数据源显示轴的位置

    ValueAxis valueAxis = mPlot.getRangeAxis();// 设置数据轴对象
    valueAxis.setLabelFont(new Font("宋体", Font.PLAIN, 12));
    ValueAxis loadAxis = mPlot.getDomainAxis();
    loadAxis.setLabelFont(new Font("宋体", Font.PLAIN, 12));
    return mChart;

}

@Override
public void actionPerformed(ActionEvent e) {
    Object en = e.getSource();
    if (this.button_seasrch.equals(en)) { //搜索按钮
        QueryDatabyLeftAndContent.searchDynaPage(1);
    }

}

}

1个回答

numberaxis.setInverted(false//反转竖轴

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐