本文整理汇总了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;
}