背景
项目应用中整理纪要,用于参数说明。后抽部分简码以用例,特此纪要!
问题
Java Swing中JFreeChart如何构建双纵轴(双Y轴)图表
说明
JFreeChart是一个工厂类,是Swing中主要图表构建入口。
样例Demo
下面是应用Demo的样例代码,可以直接运行参考:
package com.company.swing.jfreechart.barChart; import org.jfree.chart.ChartFactory; import org.jfree.chart.ChartPanel; import org.jfree.chart.JFreeChart; import org.jfree.chart.axis.CategoryAxis; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.labels.ItemLabelAnchor; import org.jfree.chart.labels.ItemLabelPosition; import org.jfree.chart.labels.StandardCategoryItemLabelGenerator; import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.plot.DatasetRenderingOrder; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.renderer.category.LineAndShapeRenderer; import org.jfree.data.category.DefaultCategoryDataset; import org.jfree.data.general.DatasetGroup; import org.jfree.ui.ApplicationFrame; import org.jfree.ui.RefineryUtilities; import org.jfree.ui.TextAnchor; import java.awt.*; public class DoubleBarChar3 extends ApplicationFrame { public static void main(String[] args) { DoubleBarChar3 bar = new DoubleBarChar3("Bar Chart Demo"); bar.pack(); RefineryUtilities.centerFrameOnScreen(bar); bar.setVisible(true); } public DoubleBarChar3(String title) { super(title); setContentPane(n