⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 chartfactory.java

📁 OLAP 的客户端代码
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
														   CategoryDataset data,
														   PlotOrientation orientation,
														   boolean legend,
														   boolean tooltips,
														   boolean urls,
														CategoryURLGenerator urlGenerator) {
        
		CategoryAxis categoryAxis = new CategoryAxis(domainAxisLabel);
		ValueAxis valueAxis = new NumberAxis(rangeAxisLabel);

		// create the renderer...
		StackedBarRenderer renderer = new StackedBarRenderer();
		if (tooltips) {
			renderer.setToolTipGenerator(new StandardCategoryToolTipGenerator());
		}
		if (urls) {
			renderer.setItemURLGenerator(urlGenerator);
		}

		CategoryPlot plot = new CategoryPlot(data, categoryAxis, valueAxis, renderer);
		plot.setOrientation(orientation);
		JFreeChart chart = new JFreeChart(title, titleFont, plot, legend);

		return chart;
            
	}
                                                             
	/**
	 * Creates a stacked vertical bar chart with default settings.
	 *
	 * @param title  the chart title.
	 * @param categoryAxisLabel  the label for the category axis.
	 * @param valueAxisLabel  the label for the value axis.
	 * @param data  the dataset for the chart.
	 * @param legend  a flag specifying whether or not a legend is required.
	 * @param tooltips  configure chart to generate tool tips?
	 * @param urls  configure chart to generate URLs?
	 *
	 * @return a stacked vertical bar chart.
	 */
	public static JFreeChart createStackedBarChart3D(String title,
															java.awt.Font titleFont,
															 String categoryAxisLabel, 
															 String valueAxisLabel, 
															 CategoryDataset data,
															 PlotOrientation orientation,
															 boolean legend,
															 boolean tooltips,
															 boolean urls,
															CategoryURLGenerator urlGenerator) {

		// create the axes...
		CategoryAxis categoryAxis = new CategoryAxis3D(categoryAxisLabel);
		ValueAxis valueAxis = new NumberAxis3D(valueAxisLabel);

		// create the renderer...
		CategoryItemRenderer renderer = new StackedBarRenderer3D();
		CategoryToolTipGenerator toolTipGenerator = null;
		if (tooltips) {
			toolTipGenerator = new StandardCategoryToolTipGenerator();
		}
		if ( urls ) {
			renderer.setItemURLGenerator(urlGenerator);
		}
		renderer.setToolTipGenerator(toolTipGenerator);
		
		// create the plot...
		CategoryPlot plot = new CategoryPlot(data, categoryAxis, valueAxis, renderer);
		plot.setOrientation(orientation);

		// create the chart...
		JFreeChart chart = new JFreeChart(title, titleFont, plot, legend);

		return chart;

	}


	/**
	 * Creates a line chart with default settings.
	 *
	 * @param title  the chart title.
	 * @param categoryAxisLabel  the label for the category axis.
	 * @param valueAxisLabel  the label for the value axis.
	 * @param data  the dataset for the chart.
	 * @param legend  a flag specifying whether or not a legend is required.
	 * @param tooltips  configure chart to generate tool tips?
	 * @param urls  configure chart to generate URLs?
	 *
	 * @return a line chart.
	 */
	public static JFreeChart createLineChart(String title,
											java.awt.Font titleFont,
											 String categoryAxisLabel,
											 String valueAxisLabel,
											 CategoryDataset data,
											 PlotOrientation orientation,
											 boolean legend,
											 boolean tooltips,
											 boolean urls,
											CategoryURLGenerator urlGenerator) {

		CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel);
		ValueAxis valueAxis = new NumberAxis(valueAxisLabel);

		LineAndShapeRenderer renderer = new LineAndShapeRenderer();
		renderer.setLinesVisible(true);
		renderer.setShapesVisible(false);
		if (tooltips) {
			renderer.setToolTipGenerator(new StandardCategoryToolTipGenerator());
		}
		if (urls) {
			renderer.setItemURLGenerator(urlGenerator);
		}
		CategoryPlot plot = new CategoryPlot(data, categoryAxis, valueAxis, renderer);
		plot.setOrientation(orientation);
		JFreeChart chart = new JFreeChart(title, titleFont, plot, legend);

		return chart;

	}

	/**
	 * Creates an area chart with default settings.
	 *
	 * @param title  the chart title.
	 * @param categoryAxisLabel  the label for the category axis.
	 * @param valueAxisLabel  the label for the value axis.
	 * @param data  the dataset for the chart.
	 * @param legend  a flag specifying whether or not a legend is required.
	 * @param tooltips  configure chart to generate tool tips?
	 * @param urls  configure chart to generate URLs?
	 *
	 * @return an area chart.
	 */
	public static JFreeChart createAreaChart(String title,
											java.awt.Font titleFont,
											 String categoryAxisLabel,
											 String valueAxisLabel,
											 CategoryDataset data,
											 PlotOrientation orientation,
											 boolean legend,
											 boolean tooltips,
											 boolean urls,
											 CategoryURLGenerator urlGenerator) {

		CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel);
		categoryAxis.setCategoryMargin(0.0);
		ValueAxis valueAxis = new NumberAxis(valueAxisLabel);
		AreaRenderer renderer = new AreaRenderer();
		if (tooltips) {
			renderer.setToolTipGenerator(new StandardCategoryToolTipGenerator());
                }
		if (urls) {
			renderer.setItemURLGenerator(urlGenerator);
		}
		CategoryPlot plot = new CategoryPlot(data, categoryAxis, valueAxis, renderer);
		plot.setOrientation(orientation);
		JFreeChart chart = new JFreeChart(title, titleFont, plot, legend);

		return chart;

	}

	/**
	 * Creates a stacked area chart with default settings.
	 *
	 * @param title  the chart title.
	 * @param categoryAxisLabel  the label for the category axis.
	 * @param valueAxisLabel  the label for the value axis.
	 * @param data  the dataset for the chart.
	 * @param legend  a flag specifying whether or not a legend is required.
	 * @param tooltips  configure chart to generate tool tips?
	 * @param urls  configure chart to generate URLs?
	 *
	 * @return an area chart.
	 */
	public static JFreeChart createStackedAreaChart(String title,
													java.awt.Font titleFont,
													String categoryAxisLabel,
													String valueAxisLabel,
													CategoryDataset data,
													PlotOrientation orientation,
													boolean legend,
													boolean tooltips,
													boolean urls,
	CategoryURLGenerator urlGenerator) {

		CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel);
		ValueAxis valueAxis = new NumberAxis(valueAxisLabel);

		StackedAreaRenderer renderer = new StackedAreaRenderer();
		if (tooltips) {
			renderer.setToolTipGenerator(new StandardCategoryToolTipGenerator());
		}
		if (urls) {
			renderer.setItemURLGenerator(urlGenerator);
		}

		CategoryPlot plot = new CategoryPlot(data, categoryAxis, valueAxis, renderer);
		plot.setOrientation(orientation);
		JFreeChart chart = new JFreeChart(title, titleFont, plot, legend);

		return chart;

	}


	/**
	 * Creates and returns a time series chart.
	 * <P>
	 * A time series chart is an XYPlot with a date axis (horizontal) and a number axis (vertical),
	 * and each data item is connected with a line.
	 * <P>
	 * Note that you can supply a TimeSeriesCollection to this method, as it implements the
	 * XYDataset interface.
	 *
	 * @param title  the chart title.
	 * @param timeAxisLabel  a label for the time axis.
	 * @param valueAxisLabel  a label for the value axis.
	 * @param data  the dataset for the chart.
	 * @param legend  a flag specifying whether or not a legend is required.
	 * @param tooltips  configure chart to generate tool tips?
	 * @param urls  configure chart to generate URLs?
	 *
	 * @return a time series chart.
	 */
	public static JFreeChart createTimeSeriesChart(String title,
												java.awt.Font titleFont,
												   String timeAxisLabel,
												   String valueAxisLabel,
												   XYDataset data,
												   boolean legend,
												   boolean tooltips,
												   boolean urls) {

		ValueAxis timeAxis = new DateAxis(timeAxisLabel);
		timeAxis.setLowerMargin(0.02);  // reduce the default margins on the time axis
		timeAxis.setUpperMargin(0.02);
		NumberAxis valueAxis = new NumberAxis(valueAxisLabel);
		valueAxis.setAutoRangeIncludesZero(false);  // override default
		XYPlot plot = new XYPlot(data, timeAxis, valueAxis, null);

		XYToolTipGenerator tooltipGenerator = null;
		if (tooltips) {
			tooltipGenerator = StandardXYToolTipGenerator.getTimeSeriesInstance();
                            //new StandardXYToolTipGenerator(DateFormat.getDateInstance());                                                
		}

		XYURLGenerator urlGenerator = null;
		if (urls) {
			urlGenerator = new StandardXYURLGenerator();
		}
                
                plot.setRenderer(new StandardXYItemRenderer(StandardXYItemRenderer.LINES, tooltipGenerator, urlGenerator));
		
                JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend);

		return chart;

	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -