/** * Returns the primary dataset for the plot. * * @return The primary dataset (possibly <code>null</code>). * * @see #setDataset(CategoryDataset) */ public CategoryDataset getDataset() { return getDataset(0); }
/** * Returns the primary dataset for the plot. * * @return The primary dataset (possibly {@code null}). * * @see #setDataset(CategoryDataset) */ public CategoryDataset getDataset() { return getDataset(0); }
/** * Returns a list of the categories in the plot's primary dataset. * * @return A list of the categories in the plot's primary dataset. * * @see #getCategoriesForAxis(CategoryAxis) */ public List getCategories() { List result = null; if (getDataset() != null) { result = Collections.unmodifiableList(getDataset().getColumnKeys()); } return result; }
/** * Returns a list of the categories in the plot's primary dataset. * * @return A list of the categories in the plot's primary dataset. * * @see #getCategoriesForAxis(CategoryAxis) */ public List getCategories() { List result = null; if (getDataset() != null) { result = Collections.unmodifiableList(getDataset().getColumnKeys()); } return result; }
public String render(Comparable key) { GroupedCategoryDataset dataset = (GroupedCategoryDataset)chart.getCategoryPlot().getDataset(); Comparable orgRowKey = dataset.getOriginalRowKey(key); return orgRowKey.toString(); } }
public String getCSV() { StringBuilder output = new StringBuilder(); DefaultCategoryDataset d = (DefaultCategoryDataset) chart.getCategoryPlot().getDataset(); for (int i = 0; i < d.getRowCount(); i++) { output.append(d.getRowKey(i) + "," + d.getValue(d.getRowKey(i), Integer.valueOf(0)) + "\n"); } return output.toString(); }
/** * Maps the specified dataset to the axes in the list. Note that the * conversion of data values into Java2D space is always performed using * the first axis in the list. * * @param index the dataset index (zero-based). * @param axisIndices the axis indices (<code>null</code> permitted). * * @since 1.0.12 */ public void mapDatasetToDomainAxes(int index, List axisIndices) { if (index < 0) { throw new IllegalArgumentException("Requires 'index' >= 0."); } checkAxisIndices(axisIndices); Integer key = new Integer(index); this.datasetToDomainAxesMap.put(key, new ArrayList(axisIndices)); // fake a dataset change event to update axes... datasetChanged(new DatasetChangeEvent(this, getDataset(index))); }
/** * Maps the specified dataset to the axes in the list. Note that the * conversion of data values into Java2D space is always performed using * the first axis in the list. * * @param index the dataset index (zero-based). * @param axisIndices the axis indices (<code>null</code> permitted). * * @since 1.0.12 */ public void mapDatasetToRangeAxes(int index, List axisIndices) { if (index < 0) { throw new IllegalArgumentException("Requires 'index' >= 0."); } checkAxisIndices(axisIndices); Integer key = new Integer(index); this.datasetToRangeAxesMap.put(key, new ArrayList(axisIndices)); // fake a dataset change event to update axes... datasetChanged(new DatasetChangeEvent(this, getDataset(index))); }
/** * Add a value to a specific series of the chart. * @param seriesname The series name. * @param valx The x value. * @param valy The y value. * @param data The data table. * @param row The current data row. */ protected void addValue(Comparable seriesname, Object valx, Object valy, DataTable data, Object[] row) { DefaultCategoryDataset dataset = (DefaultCategoryDataset)((CategoryPlot)getChart().getPlot()).getDataset(); dataset.addValue(((Double)valy).doubleValue(), seriesname, (Comparable)valx); } }
/** * Maps the specified dataset to the axes in the list. Note that the * conversion of data values into Java2D space is always performed using * the first axis in the list. * * @param index the dataset index (zero-based). * @param axisIndices the axis indices ({@code null} permitted). * * @since 1.0.12 */ public void mapDatasetToDomainAxes(int index, List axisIndices) { Args.requireNonNegative(index, "index"); checkAxisIndices(axisIndices); this.datasetToDomainAxesMap.put(index, new ArrayList(axisIndices)); // fake a dataset change event to update axes... datasetChanged(new DatasetChangeEvent(this, getDataset(index))); }
/** * Maps the specified dataset to the axes in the list. Note that the * conversion of data values into Java2D space is always performed using * the first axis in the list. * * @param index the dataset index (zero-based). * @param axisIndices the axis indices ({@code null} permitted). * * @since 1.0.12 */ public void mapDatasetToRangeAxes(int index, List axisIndices) { Args.requireNonNegative(index, "index"); checkAxisIndices(axisIndices); this.datasetToRangeAxesMap.put(index, new ArrayList(axisIndices)); // fake a dataset change event to update axes... datasetChanged(new DatasetChangeEvent(this, getDataset(index))); }
/** * Returns the paint from the paint maps for a specific series (row index). * * @param series The row index * @return The color for the row index */ public Paint lookupSeriesPaint(int series) { // first get the group rowkeyget from the dataset (e.g. inform_sent) GroupedCategoryDataset dataset = (GroupedCategoryDataset)getPlot().getDataset(); Comparable rowKey = dataset.getRowKey(series); // get the original key value (e.g. inform) Comparable key = dataset.getOriginalRowKey(rowKey); // lookup the color return lookupSeriesPaint(key); }
protected JFreeChart createBarChart() throws JRException { JFreeChart jfreeChart = super.createBarChart(); CategoryPlot categoryPlot = (CategoryPlot) jfreeChart.getPlot(); // categoryPlot.setOrientation(PlotOrientation.HORIZONTAL); BarRenderer barRenderer = (BarRenderer) categoryPlot.getRenderer(); barRenderer.setItemMargin(0); barRenderer.setGradientPaintTransformer(new StandardGradientPaintTransformer(GradientPaintTransformType.HORIZONTAL)); CategoryDataset categoryDataset = categoryPlot.getDataset(); if (categoryDataset != null) { for (int i = 0; i < categoryDataset.getRowCount(); i++) { barRenderer.setSeriesPaint(i, ChartThemesConstants.EYE_CANDY_SIXTIES_GRADIENT_PAINTS.get(i)); <-- Here is point } } return jfreeChart; }
/** * {@inheritDoc} */ @Override public void customize(JFreeChart chart, ReportParameters reportParameters) { if (chart.getPlot() instanceof CategoryPlot) { CategoryDataset dataset = new SeriesOrderCategoryDataset(chart.getCategoryPlot().getDataset(), seriesOrderBy, seriesOrderType); chart.getCategoryPlot().setDataset(dataset); } } }
public void updateValues(String seriesName, double value) { if (!lock) { DefaultCategoryDataset dataset = (DefaultCategoryDataset) chart.getCategoryPlot().getDataset(); dataset.addValue(value, seriesName, Integer.valueOf(0)); if (value < lowerBound) { lowerBound = value; } if (value > upperBound) { upperBound = value; } CategoryPlot plot = chart.getCategoryPlot(); plot.getRangeAxis().setLowerBound(lowerBound); plot.getRangeAxis().setUpperBound(upperBound); } }
/** * {@inheritDoc} */ @Override public void customize(JFreeChart chart, ReportParameters reportParameters) { if (chart.getPlot() instanceof CategoryPlot) { if (chart.getCategoryPlot().getDataset() != null) { CategoryDataset dataset; if (!(chart.getCategoryPlot().getRenderer() instanceof GroupedStackedBarRenderer)) { dataset = new PercentageCategoryDataset(chart.getCategoryPlot().getDataset()); } else { dataset = new PercentageGroupedCategoryDataset(chart.getCategoryPlot().getDataset()); } chart.getCategoryPlot().setDataset(dataset); } if (StringUtils.isBlank(chart.getCategoryPlot().getRangeAxis().getLabel())) { chart.getCategoryPlot().getRangeAxis().setLabel("%"); } } } }
/** * Returns the paint from the paint maps used to fill data items. * * @param row the row (or series) index (zero-based). * @param column the column (or category) index (zero-based). * * @return The paint (never <code>null</code>). */ public Paint getItemPaint(int row, int column) { GroupedCategoryDataset dataset = (GroupedCategoryDataset)getPlot().getDataset(); // if message distribution get key for column (agentname) if(paintMode == PaintMaps.COLOR_COMPONENT) { Comparable key = dataset.getColumnKey(column); // lookup color return lookupSeriesPaint(key); } else { // get original row key value from the group key Comparable rowKey = dataset.getRowKey(row); Comparable key = dataset.getOriginalRowKey(rowKey); // lookup color return lookupSeriesPaint(key); } }
/** * Returns a (possibly empty) collection of legend items for the series * that this renderer is responsible for drawing. * * @return The legend item collection (never <code>null</code>). * * @see #getLegendItem(int, int) */ public LegendItemCollection getLegendItems() { if (this.plot == null) { return new LegendItemCollection(); } LegendItemCollection result = new LegendItemCollection(); int index = this.plot.getIndexOf(this); CategoryDataset dataset = this.plot.getDataset(index); if (dataset != null) { int seriesCount = dataset.getRowCount(); for (int i = 0; i < seriesCount; i++) { if (isSeriesVisibleInLegend(i)) { LegendItem item = getLegendItem(index, i); if (item != null) { result.add(item); } } } } return result; }
CategoryDataset dataset = getDataset(); if (dataset == null) { return;
/** * Sets the type of the chart. * * @param chartType The chart type. */ public void setChartType(int chartType) { this.chartType = chartType; // first cleanup for gc if(chart.getPlot() instanceof CategoryPlot) { GroupedCategoryDataset dataset = (GroupedCategoryDataset)chart.getCategoryPlot().getDataset(); dataset.cleanup(); // needed for circle references ((CategoryPlot)chart.getPlot()).setDataset(null); } if(chart.getPlot() instanceof MultiplePiePlot) { ((MultiplePiePlot)chart.getPlot()).setDataset(null); } chart = chartType == CHARTTYPE_PIECHART ? createPieChart() : createBarChart(); chartPanel.setChart(chart); }