本文整理汇总了Java中org.jfree.chart.renderer.category.LineAndShapeRenderer.setSeriesPaint方法的典型用法代码示例。如果您正苦于以下问题:Java LineAndShapeRenderer.setSeriesPaint方法的具体用法?Java LineAndShapeRenderer.setSeriesPaint怎么用?Java LineAndShapeRenderer.setSeriesPaint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jfree.chart.renderer.category.LineAndShapeRenderer
的用法示例。
在下文中一共展示了LineAndShapeRenderer.setSeriesPaint方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createLineChart
import org.jfree.chart.renderer.category.LineAndShapeRenderer; //导入方法依赖的package包/类
@Override
protected JFreeChart createLineChart() throws JRException
{
JFreeChart jfreeChart = super.createLineChart();
CategoryPlot categoryPlot = (CategoryPlot)jfreeChart.getPlot();
LineAndShapeRenderer lineRenderer = (LineAndShapeRenderer)categoryPlot.getRenderer();
lineRenderer.setBaseStroke(new BasicStroke(2f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));
// Stroke stroke = new BasicStroke(2f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
for (int i = 0; i < lineRenderer.getRowCount(); i++)
{
lineRenderer.setSeriesOutlinePaint(i, ChartThemesConstants.TRANSPARENT_PAINT);
lineRenderer.setSeriesFillPaint(i, ChartThemesConstants.EYE_CANDY_SIXTIES_GRADIENT_PAINTS.get(i));
lineRenderer.setSeriesPaint(i, ChartThemesConstants.EYE_CANDY_SIXTIES_GRADIENT_PAINTS.get(i));
lineRenderer.setSeriesShapesVisible(i,true);
//it isn't applied at the moment
//lineRenderer.setSeriesStroke(i,stroke);
//line3DRenderer.setSeriesLinesVisible(i,lineRenderer.getSeriesVisible(i));
}
// configureChart(jfreeChart, getPlot());
return jfreeChart;
}
示例2: createChart
import org.jfree.chart.renderer.category.LineAndShapeRenderer; //导入方法依赖的package包/类
/**
* Creates a chart for recent time to fix.
*
*/
public void createChart(final SortedMap time, final String valueKey, final Color lineColor, final OutputStream out) throws IOException {
final DefaultCategoryDataset dataset = new DefaultCategoryDataset();
addTimeToDataSet(dataset, time, valueKey);
// create the chart object
// This generates a stacked bar - more suitable
final JFreeChart chart = ChartFactory.createLineChart(null,
"Recent builds", "Time", dataset,
PlotOrientation.VERTICAL,
true, false, false);
chart.setBackgroundPaint(Color.white);
// change the auto tick unit selection to integer units only
final CategoryPlot plot = chart.getCategoryPlot();
final NumberAxis rangeAxis = (NumberAxis)plot.getRangeAxis();
rangeAxis.setStandardTickUnits(StatisticsUtils.createWordedTimeTickUnits());
// rotate X dates
final CategoryAxis domainAxis = plot.getDomainAxis();
domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);
// set bar colors
final LineAndShapeRenderer line = (LineAndShapeRenderer)plot.getRenderer();
line.setSeriesPaint(0, lineColor);
line.setStroke(StatisticsUtils.DEFAULT_LINE_STROKE);
// write to reposnce
final ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
ChartUtilities.writeChartAsPNG(out, chart, StatisticsUtils.IMG_WIDTH, StatisticsUtils.IMG_HEIGHT, info);
}
示例3: createChart
import org.jfree.chart.renderer.category.LineAndShapeRenderer; //导入方法依赖的package包/类
public void createChart(final SortedMap stats, final OutputStream out) throws IOException {
final DefaultCategoryDataset dataset = new DefaultCategoryDataset();
for (final Iterator iter = stats.entrySet().iterator(); iter.hasNext();) {
final Map.Entry entry = (Map.Entry)iter.next();
final Integer buildNumber = (Integer)entry.getKey();
final Integer violations = (Integer)entry.getValue();
dataset.addValue(violations, categoryDescription, buildNumber);
}
// create the chart object
// This generates a stacked bar - more suitable
final JFreeChart chart = ChartFactory.createLineChart(null,
"Recent builds", valueAxisLabel, dataset,
PlotOrientation.VERTICAL,
true, false, false);
chart.setBackgroundPaint(Color.white);
// change the auto tick unit selection to integer units only
final CategoryPlot plot = chart.getCategoryPlot();
final NumberAxis rangeAxis = (NumberAxis)plot.getRangeAxis();
rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
// rotate X dates
final CategoryAxis domainAxis = plot.getDomainAxis();
domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);
// set bar colors
final LineAndShapeRenderer line = (LineAndShapeRenderer)plot.getRenderer();
line.setSeriesPaint(0, Color.RED);
line.setStroke(StatisticsUtils.DEFAULT_LINE_STROKE);
// write to reposnce
final ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
ChartUtilities.writeChartAsPNG(out, chart, StatisticsUtils.IMG_WIDTH, StatisticsUtils.IMG_HEIGHT, info);
}
示例4: createRecentBuildTimesChart
import org.jfree.chart.renderer.category.LineAndShapeRenderer; //导入方法依赖的package包/类
public static void createRecentBuildTimesChart(final SortedMap stats, final String categoryLabel, final OutputStream out) throws IOException {
final DefaultCategoryDataset dataset = new DefaultCategoryDataset();
for (final Iterator iter = stats.entrySet().iterator(); iter.hasNext();) {
final Map.Entry entry = (Map.Entry) iter.next();
final Integer buildNumber = (Integer) entry.getKey();
final Integer timeInSeconds = (Integer) entry.getValue();
dataset.addValue(timeInSeconds, "Build time", buildNumber);
}
// create the chart object
// This generates a stacked bar - more suitable
final JFreeChart chart = ChartFactory.createLineChart(null,
categoryLabel, "Build time", dataset,
PlotOrientation.VERTICAL,
true, false, false);
chart.setBackgroundPaint(Color.white);
// change the auto tick unit selection to integer units only
final CategoryPlot plot = chart.getCategoryPlot();
final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
rangeAxis.setStandardTickUnits(createWordedTimeTickUnits());
// rotate X dates
final CategoryAxis domainAxis = plot.getDomainAxis();
domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);
// set bar colors
final LineAndShapeRenderer line = (LineAndShapeRenderer) plot.getRenderer();
line.setSeriesPaint(0, Color.BLUE);
line.setStroke(DEFAULT_LINE_STROKE);
// write to reposnce
final ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
ChartUtilities.writeChartAsPNG(out, chart, IMG_WIDTH, IMG_HEIGHT, info);
}
示例5: getLineRenderer
import org.jfree.chart.renderer.category.LineAndShapeRenderer; //导入方法依赖的package包/类
/**
* Returns a line and shape renderer.
*/
private LineAndShapeRenderer getLineRenderer()
{
LineAndShapeRenderer renderer = new LineAndShapeRenderer();
for ( int i = 0; i < COLORS.length; i++ )
{
renderer.setSeriesPaint( i, COLORS[i] );
}
return renderer;
}
示例6: configureLineAndShapeRenderer
import org.jfree.chart.renderer.category.LineAndShapeRenderer; //导入方法依赖的package包/类
private static void configureLineAndShapeRenderer(LineAndShapeRenderer renderer, ValueSource valueSource, PlotInstance plotInstance) {
ValueSourceData valueSourceData = plotInstance.getPlotData().getValueSourceData(valueSource);
int seriesCount = valueSourceData.getSeriesCount();
SeriesFormat seriesFormat = valueSource.getSeriesFormat();
DimensionConfig domainConfig = valueSource.getDomainConfig();
DimensionConfig colorDimensionConfig = plotInstance.getCurrentPlotConfigurationClone().getDimensionConfig(PlotDimension.COLOR);
DimensionConfig shapeDimensionConfig = plotInstance.getCurrentPlotConfigurationClone().getDimensionConfig(PlotDimension.SHAPE);
renderer.setDefaultEntityRadius(4);
// loop all series and set series format
for(int seriesIdx = 0; seriesIdx < seriesCount; ++seriesIdx) {
// configure linestyle
if(seriesFormat.getLineStyle() != LineStyle.NONE) {
renderer.setSeriesLinesVisible(seriesIdx, true);
renderer.setSeriesStroke(seriesIdx, seriesFormat.getStroke(),false);
} else {
renderer.setSeriesLinesVisible(seriesIdx, false);
}
// configure series shape if necessary
if(!SeriesFormat.calculateIndividualFormatForEachItem(domainConfig, shapeDimensionConfig) ){
if(seriesFormat.getItemShape() != ItemShape.NONE) {
renderer.setSeriesShapesVisible(seriesIdx, true);
renderer.setSeriesShape(seriesIdx, seriesFormat.getItemShape().getShape());
} else {
renderer.setSeriesShapesVisible(seriesIdx, false);
}
}
// configure series color if necessary
if(!SeriesFormat.calculateIndividualFormatForEachItem(domainConfig, colorDimensionConfig) ){
Color itemColor = seriesFormat.getItemColor();
renderer.setSeriesPaint(seriesIdx, itemColor);
}
renderer.setSeriesOutlinePaint(seriesIdx, PlotConfiguration.DEFAULT_SERIES_OUTLINE_PAINT);
renderer.setUseOutlinePaint(true);
}
}
示例7: formatSeries
import org.jfree.chart.renderer.category.LineAndShapeRenderer; //导入方法依赖的package包/类
protected void formatSeries(LineAndShapeRenderer renderer) {
renderer.setBaseShapesVisible(true);
renderer.setDrawOutlines(true);
renderer.setUseFillPaint(true);
renderer.setBaseStroke(new BasicStroke(2));
int count = ((CategoryDataset) dataset).getRowCount();
ColorGenerator colors = format.getColors();
for(int i=0; i<count; i++) {
Paint color = colors.nextColor();
renderer.setSeriesPaint(i, color);
renderer.setSeriesFillPaint(i, color);
}
}
示例8: formatSeries
import org.jfree.chart.renderer.category.LineAndShapeRenderer; //导入方法依赖的package包/类
protected void formatSeries(LineAndShapeRenderer renderer) {
renderer.setBaseShapesVisible(true);
renderer.setDrawOutlines(true);
renderer.setUseFillPaint(true);
renderer.setBaseStroke(new BasicStroke(2));
int count = ((CategoryDataset) dataset).getRowCount();
ColorGenerator colors = format.getColors();
for(int i=0; i<count; i++) {
Color color = colors.nextColor();
renderer.setSeriesPaint(i, color);
renderer.setSeriesFillPaint(i, color);
}
}
示例9: createChart
import org.jfree.chart.renderer.category.LineAndShapeRenderer; //导入方法依赖的package包/类
private JFreeChart createChart() {
if (data.getItemCount() > 0) {
// get cumulative percentages
KeyedValues cumulative = DataUtilities.getCumulativePercentages(data);
CategoryDataset categoryDataset = DatasetUtilities.createCategoryDataset(
"Count for " + this.dataTable.getColumnName(this.countColumn) + " = " + countValue, data);
// create the chart...
final JFreeChart chart = ChartFactory.createBarChart(null, // chart title
this.dataTable.getColumnName(this.groupByColumn), // domain axis label
"Count", // range axis label
categoryDataset, // data
PlotOrientation.VERTICAL, true, // include legend
true, false);
// set the background color for the chart...
chart.setBackgroundPaint(Color.WHITE);
// get a reference to the plot for further customization...
CategoryPlot plot = chart.getCategoryPlot();
CategoryAxis domainAxis = plot.getDomainAxis();
domainAxis.setLowerMargin(0.02);
domainAxis.setUpperMargin(0.02);
domainAxis.setLabelFont(LABEL_FONT_BOLD);
domainAxis.setTickLabelFont(LABEL_FONT);
// set the range axis to display integers only...
NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits(Locale.US));
rangeAxis.setLabelFont(LABEL_FONT_BOLD);
rangeAxis.setTickLabelFont(LABEL_FONT);
// second data set (cumulative percentages)
CategoryDataset dataset2 = DatasetUtilities.createCategoryDataset("Cumulative (Percent)", cumulative);
LineAndShapeRenderer renderer2 = new LineAndShapeRenderer();
renderer2.setSeriesPaint(0, SwingTools.VERY_DARK_BLUE.darker());
NumberAxis axis2 = new NumberAxis("Percent of " + countValue);
axis2.setNumberFormatOverride(NumberFormat.getPercentInstance());
axis2.setLabelFont(LABEL_FONT_BOLD);
axis2.setTickLabelFont(LABEL_FONT);
plot.setRangeAxis(1, axis2);
plot.setDataset(1, dataset2);
plot.setRenderer(1, renderer2);
plot.mapDatasetToRangeAxis(1, 1);
axis2.setTickUnit(new NumberTickUnit(0.1));
// show grid lines
plot.setRangeGridlinesVisible(true);
// bring cumulative line to front
plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);
if (isLabelRotating()) {
domainAxis.setTickLabelsVisible(true);
domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 2.0d));
}
return chart;
} else {
return null;
}
}
示例10: configureLineAndShapeRenderer
import org.jfree.chart.renderer.category.LineAndShapeRenderer; //导入方法依赖的package包/类
private static void configureLineAndShapeRenderer(LineAndShapeRenderer renderer, ValueSource valueSource,
PlotInstance plotInstance) {
ValueSourceData valueSourceData = plotInstance.getPlotData().getValueSourceData(valueSource);
int seriesCount = valueSourceData.getSeriesCount();
SeriesFormat seriesFormat = valueSource.getSeriesFormat();
DimensionConfig domainConfig = valueSource.getDomainConfig();
DimensionConfig colorDimensionConfig = plotInstance.getCurrentPlotConfigurationClone().getDimensionConfig(
PlotDimension.COLOR);
DimensionConfig shapeDimensionConfig = plotInstance.getCurrentPlotConfigurationClone().getDimensionConfig(
PlotDimension.SHAPE);
renderer.setDefaultEntityRadius(4);
// loop all series and set series format
for (int seriesIdx = 0; seriesIdx < seriesCount; ++seriesIdx) {
// configure linestyle
if (seriesFormat.getLineStyle() != LineStyle.NONE) {
renderer.setSeriesLinesVisible(seriesIdx, true);
renderer.setSeriesStroke(seriesIdx, seriesFormat.getStroke(), false);
} else {
renderer.setSeriesLinesVisible(seriesIdx, false);
}
// configure series shape if necessary
if (!SeriesFormat.calculateIndividualFormatForEachItem(domainConfig, shapeDimensionConfig)) {
if (seriesFormat.getItemShape() != ItemShape.NONE) {
renderer.setSeriesShapesVisible(seriesIdx, true);
renderer.setSeriesShape(seriesIdx, seriesFormat.getItemShape().getShape());
} else {
renderer.setSeriesShapesVisible(seriesIdx, false);
}
}
// configure series color if necessary
if (!SeriesFormat.calculateIndividualFormatForEachItem(domainConfig, colorDimensionConfig)) {
Color itemColor = seriesFormat.getItemColor();
renderer.setSeriesPaint(seriesIdx, itemColor);
}
renderer.setSeriesOutlinePaint(seriesIdx, PlotConfiguration.DEFAULT_SERIES_OUTLINE_PAINT);
renderer.setUseOutlinePaint(true);
}
}
示例11: generate
import org.jfree.chart.renderer.category.LineAndShapeRenderer; //导入方法依赖的package包/类
public ImmutableImage generate(final List samples) {
try {
final DefaultCategoryDataset dataset = new DefaultCategoryDataset();
for (int i = 0; i < samples.size(); i++) {
final AgentStatusSample sample = (AgentStatusSample) samples.get(i);
dataset.addValue(sample.getBusyCounter(), "Load", new ColumnKey(i));
}
final JFreeChart chart = ChartFactory.createLineChart(null,
"Last 24 Hours", "Builds", dataset,
PlotOrientation.VERTICAL,
false, false, false);
chart.setBackgroundPaint(Color.white);
// Change the auto tick unit selection to integer units only
final CategoryPlot plot = chart.getCategoryPlot();
final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
// Rotate X dates
final CategoryAxis domainAxis = plot.getDomainAxis();
domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);
// Set bar colors
final LineAndShapeRenderer line = (LineAndShapeRenderer) plot.getRenderer();
line.setSeriesPaint(0, Color.BLUE);
line.setStroke(StatisticsUtils.DEFAULT_LINE_STROKE);
// Write to byte array
final ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
final ByteArrayOutputStream out = new ByteArrayOutputStream(1000);
ChartUtilities.writeChartAsPNG(out, chart, width, height, info);
out.flush();
out.close();
// Return result
return new ImmutableImage(out.toByteArray(), width, height);
} catch (IOException e) {
final ErrorManager errorManager = ErrorManagerFactory.getErrorManager();
final Error error = new Error("Error generating agent status chart: " + StringUtils.toString(e), e);
errorManager.reportSystemError(error);
return ImmutableImage.ZERO_SIZE_IMAGE;
}
}
示例12: createGraph
import org.jfree.chart.renderer.category.LineAndShapeRenderer; //导入方法依赖的package包/类
@Override
protected JFreeChart createGraph() {
int size = results.size();
final String[] rowKeys = {"Statement Coverage", "Branch Coverage"};
final String[] columnKeys = new String[size];
double[][] data = new double[2][size];
for (int i = 0; i < size; i++) {
columnKeys[size - i - 1] = "#" + results.get(i).getNum();
data[0][size - i - 1] = results.get(i).getStatement();
data[1][size - i - 1] = results.get(i).getCondition();
}
final CategoryDataset dataset = DatasetUtilities.createCategoryDataset(rowKeys, columnKeys, data);
final JFreeChart chart = ChartFactory.createLineChart(
null, // chart title
null, // unused
"%", // range axis label
dataset, // data
PlotOrientation.VERTICAL, // orientation
true, // include legend
true, // tooltips
false // urls
);
chart.setBackgroundPaint(Color.white);
final CategoryPlot plot = chart.getCategoryPlot();
plot.setBackgroundPaint(Color.WHITE);
plot.setOutlinePaint(null);
plot.setRangeGridlinesVisible(true);
plot.setRangeGridlinePaint(Color.black);
CategoryAxis domainAxis = new ShiftedCategoryAxis(null);
plot.setDomainAxis(domainAxis);
domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90);
domainAxis.setLowerMargin(0.0);
domainAxis.setUpperMargin(0.0);
domainAxis.setCategoryMargin(0.0);
final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
rangeAxis.setUpperBound(100);
rangeAxis.setLowerBound(0);
rangeAxis.setTickUnit(new NumberTickUnit(10));
final LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer();
renderer.setBaseStroke(new BasicStroke(2.0f));
renderer.setSeriesPaint(0, Color.BLUE);
renderer.setSeriesPaint(1, Color.RED);
plot.setRenderer(renderer);
plot.setInsets(new RectangleInsets(5.0, 0, 0, 5.0));
return chart;
}
示例13: createChart
import org.jfree.chart.renderer.category.LineAndShapeRenderer; //导入方法依赖的package包/类
private JFreeChart createChart() {
if (data.getItemCount() > 0) {
// get cumulative percentages
KeyedValues cumulative = DataUtilities.getCumulativePercentages(data);
CategoryDataset categoryDataset = DatasetUtilities.createCategoryDataset("Count for " + this.dataTable.getColumnName(this.countColumn) + " = " + countValue, data);
// create the chart...
final JFreeChart chart = ChartFactory.createBarChart(null, // chart title
this.dataTable.getColumnName(this.groupByColumn), // domain axis label
"Count", // range axis label
categoryDataset, // data
PlotOrientation.VERTICAL, true, // include legend
true, false);
// set the background color for the chart...
chart.setBackgroundPaint(Color.WHITE);
// get a reference to the plot for further customization...
CategoryPlot plot = chart.getCategoryPlot();
CategoryAxis domainAxis = plot.getDomainAxis();
domainAxis.setLowerMargin(0.02);
domainAxis.setUpperMargin(0.02);
domainAxis.setLabelFont(LABEL_FONT_BOLD);
domainAxis.setTickLabelFont(LABEL_FONT);
// set the range axis to display integers only...
NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits(Locale.US));
rangeAxis.setLabelFont(LABEL_FONT_BOLD);
rangeAxis.setTickLabelFont(LABEL_FONT);
// second data set (cumulative percentages)
CategoryDataset dataset2 = DatasetUtilities.createCategoryDataset("Cumulative (Percent)", cumulative);
LineAndShapeRenderer renderer2 = new LineAndShapeRenderer();
renderer2.setSeriesPaint(0, SwingTools.VERY_DARK_BLUE.darker());
NumberAxis axis2 = new NumberAxis("Percent of " + countValue);
axis2.setNumberFormatOverride(NumberFormat.getPercentInstance());
axis2.setLabelFont(LABEL_FONT_BOLD);
axis2.setTickLabelFont(LABEL_FONT);
plot.setRangeAxis(1, axis2);
plot.setDataset(1, dataset2);
plot.setRenderer(1, renderer2);
plot.mapDatasetToRangeAxis(1, 1);
axis2.setTickUnit(new NumberTickUnit(0.1));
// show grid lines
plot.setRangeGridlinesVisible(true);
// bring cumulative line to front
plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);
if (isLabelRotating()) {
domainAxis.setTickLabelsVisible(true);
domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 2.0d));
}
return chart;
} else {
return null;
}
}
示例14: 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;
}
示例15: createPlotComponent
import org.jfree.chart.renderer.category.LineAndShapeRenderer; //导入方法依赖的package包/类
private Component createPlotComponent() {
boolean legend = true;
boolean tooltips = false;
boolean urls = false;
chart = ChartFactory.createLineChart(null, null, null,
dataSet, PlotOrientation.VERTICAL, legend, tooltips, urls);
CategoryPlot plot = chart.getCategoryPlot();
plot.setBackgroundPaint(Color.GRAY);
plot.setRangeGridlinesVisible(true);
plot.setDomainGridlinesVisible(true);
plot.setRangeGridlinePaint(Color.WHITE);
plot.setDomainGridlinePaint(Color.WHITE);
NumberAxis axis = (NumberAxis) plot.getRangeAxis();
axis.setAutoRangeIncludesZero(false);
axis.setAutoRangeStickyZero(true);
renderer = plot.getRenderer();
if(renderer instanceof LineAndShapeRenderer) {
LineAndShapeRenderer lasr = (LineAndShapeRenderer) renderer;
lasr.setBaseShapesVisible(true);
lasr.setDrawOutlines(true);
lasr.setUseFillPaint(true);
lasr.setBaseStroke(new BasicStroke(2));
ColorGenerator colors = new DefaultColorGenerator();
int count = dataSet.getRowCount();
int r = 3;
Shape circle = new Ellipse2D.Float(-r, -r, 2*r, 2*r);
for(int i=0; i<count; i++) {
Paint color = colors.nextColor();
lasr.setSeriesPaint(i, color);
lasr.setSeriesFillPaint(i, color);
lasr.setSeriesShape(i, circle);
}
}
return new ChartPanel(chart);
}