當前位置: 首頁>>代碼示例>>Java>>正文


Java LineAndShapeRenderer.setSeriesItemLabelsVisible方法代碼示例

本文整理匯總了Java中org.jfree.chart.renderer.category.LineAndShapeRenderer.setSeriesItemLabelsVisible方法的典型用法代碼示例。如果您正苦於以下問題:Java LineAndShapeRenderer.setSeriesItemLabelsVisible方法的具體用法?Java LineAndShapeRenderer.setSeriesItemLabelsVisible怎麽用?Java LineAndShapeRenderer.setSeriesItemLabelsVisible使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.jfree.chart.renderer.category.LineAndShapeRenderer的用法示例。


在下文中一共展示了LineAndShapeRenderer.setSeriesItemLabelsVisible方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: addLineChartOverBar

import org.jfree.chart.renderer.category.LineAndShapeRenderer; //導入方法依賴的package包/類
private JFreeChart addLineChartOverBar(JFreeChart jfreechart, Object[] lineCharts, String lineLegend) throws QueryException {
	// first we read data for bar series, so we have to go back at the start of the result set
	try {
		result.getResultSet().beforeFirst();
	} catch (SQLException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	isLineCombo = true;
	lineBarDataset =  new DefaultCategoryDataset();						
	boolean hasLegend = false;
	for (int i = 0; i < lineCharts.length; i++) {
		String legend = "";
		try {
			legend = replaceParameters(lineLegend);
		} catch (IndexOutOfBoundsException ex){
			// no legend set
		}
		if ((legend != null) && !"".equals(legend.trim())) {
			hasLegend = true;
		}						
		lineCharts[i] = legend;			
	}
								
	int index = chart.getYColumns().size()-1;
	CategoryPlot plot = jfreechart.getCategoryPlot();  		
       final LineAndShapeRenderer renderer2 = new LineAndShapeRenderer();       
       plot.setRenderer(1, renderer2);
       renderer2.setSeriesPaint(0, chart.getForegrounds().get(index));
                 		     		     		
    final ValueAxis axis2 = new NumberAxis("");	    
    plot.setRangeAxis(1, axis2);
    plot.setDataset(1, lineBarDataset);
    plot.mapDatasetToRangeAxis(1, 1);
    plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);
    
    boolean showValues = (chart.getShowYValuesOnChart() == null) ? false : chart.getShowYValuesOnChart();
		DecimalFormat decimalFormat;
		DecimalFormat percentageFormat;
		if (chart.getYTooltipPattern() == null) {
			decimalFormat = new DecimalFormat("#");
			percentageFormat = new DecimalFormat("0.00%");
		} else {
			decimalFormat = new DecimalFormat(chart.getYTooltipPattern());
			percentageFormat = decimalFormat;
		}
		if (showValues) {
			renderer2.setSeriesItemLabelsVisible(0, true); 
			renderer2.setSeriesItemLabelGenerator(0, new StandardCategoryItemLabelGenerator("{2}", decimalFormat, percentageFormat));
		// increase a little bit the range axis to view all item label values over points
		plot.getRangeAxis(1).setUpperMargin(0.2);
	}
				                
       final HashMap<String, String> formatValues = createChart(chart.getYColumns().subList(index, index+1), plot.getRangeAxis(1), lineCharts);                        
       
       isLineCombo = false;
       return jfreechart;               
}
 
開發者ID:nextreports,項目名稱:nextreports-engine,代碼行數:59,代碼來源:JFreeChartExporter.java


注:本文中的org.jfree.chart.renderer.category.LineAndShapeRenderer.setSeriesItemLabelsVisible方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。