use of org.jfree.data.category.CategoryDataset in project processdash by dtuma.
the class DiscChart method createDiscChart.
public static JFreeChart createDiscChart(ResultSet data, Map parameters) {
// data.sortBy(1, true);
CategoryDataset catData = data.catDataSource();
PieDataset pieData = null;
if (catData.getColumnCount() == 1)
pieData = DatasetUtilities.createPieDatasetForColumn(catData, 0);
else
pieData = DatasetUtilities.createPieDatasetForRow(catData, 0);
DiscPlot plot = new DiscPlot(pieData);
plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0));
plot.setDrawingSupplier(DRAWING_SUPPLIER_FACTORY.newDrawingSupplier());
JFreeChart chart = new JFreeChart(null, JFreeChart.DEFAULT_TITLE_FONT, plot, false);
if (parameters.get("skipItemLabels") != null || parameters.get("skipDiscLabels") != null)
plot.setLabelGenerator(null);
else if (parameters.get("discLabelFontSize") != null)
try {
float fontSize = Float.parseFloat((String) parameters.get("discLabelFontSize"));
plot.setLabelFont(plot.getLabelFont().deriveFont(fontSize));
} catch (Exception lfe) {
}
if (parameters.get("ellipse") != null)
((StandardDiscItemDistributor) plot.getDiscDistributor()).setCircular(false);
String interiorGap = (String) parameters.get("interiorGap");
if (interiorGap != null)
try {
plot.setInteriorGap(Integer.parseInt(interiorGap) / 100.0);
} catch (NumberFormatException e) {
}
String interiorSpacing = (String) parameters.get("interiorSpacing");
if (interiorSpacing != null)
try {
plot.setInteriorGap(Integer.parseInt(interiorSpacing) / 200.0);
} catch (NumberFormatException e) {
}
return chart;
}
use of org.jfree.data.category.CategoryDataset in project processdash by dtuma.
the class PieChart method createChart.
/** Create a line chart. */
@Override
public JFreeChart createChart() {
CategoryDataset catData = data.catDataSource();
PieDataset pieData = null;
if (catData.getColumnCount() == 1)
pieData = DatasetUtilities.createPieDatasetForColumn(catData, 0);
else
pieData = DatasetUtilities.createPieDatasetForRow(catData, 0);
JFreeChart chart = null;
if (get3DSetting()) {
chart = ChartFactory.createPieChart3D(null, pieData, true, true, false);
chart.getPlot().setForegroundAlpha(ALPHA);
} else {
chart = ChartFactory.createPieChart(null, pieData, true, true, false);
}
PiePlot plot = (PiePlot) chart.getPlot();
if (parameters.get("skipItemLabels") != null || parameters.get("skipWedgeLabels") != null)
plot.setLabelGenerator(null);
else if (parameters.get("wedgeLabelFontSize") != null)
try {
float fontSize = Float.parseFloat((String) parameters.get("wedgeLabelFontSize"));
plot.setLabelFont(plot.getLabelFont().deriveFont(fontSize));
} catch (Exception lfe) {
}
if (parameters.get("ellipse") != null)
plot.setCircular(true);
else
plot.setCircular(false);
Object colorScheme = parameters.get("colorScheme");
if ("byPhase".equals(colorScheme))
maybeConfigurePhaseColors(plot, pieData);
else if ("consistent".equals(colorScheme))
// since 2.0.9
configureConsistentColors(plot, pieData);
else if (parameters.containsKey("c1"))
configureIndividualColors(plot, pieData);
String interiorGap = (String) parameters.get("interiorGap");
if (interiorGap != null)
try {
plot.setInteriorGap(Integer.parseInt(interiorGap) / 100.0);
} catch (NumberFormatException e) {
}
String interiorSpacing = (String) parameters.get("interiorSpacing");
if (interiorSpacing != null)
try {
plot.setInteriorGap(Integer.parseInt(interiorSpacing) / 200.0);
} catch (NumberFormatException e) {
}
if (!parameters.containsKey("showZeroValues")) {
plot.setIgnoreZeroValues(true);
plot.setIgnoreNullValues(true);
}
return chart;
}
use of org.jfree.data.category.CategoryDataset in project hudson-2.x by hudson.
the class AbstractTestResultAction method createChart.
private JFreeChart createChart(StaplerRequest req, CategoryDataset dataset) {
final String relPath = getRelPath(req);
final JFreeChart chart = ChartFactory.createStackedAreaChart(// chart title
null, // unused
null, // range axis label
"count", // data
dataset, // orientation
PlotOrientation.VERTICAL, // include legend
false, // tooltips
true, // urls
false);
// NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...
// set the background color for the chart...
// final StandardLegend legend = (StandardLegend) chart.getLegend();
// legend.setAnchor(StandardLegend.SOUTH);
chart.setBackgroundPaint(Color.white);
final CategoryPlot plot = chart.getCategoryPlot();
// plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0));
plot.setBackgroundPaint(Color.WHITE);
plot.setOutlinePaint(null);
plot.setForegroundAlpha(0.8f);
// plot.setDomainGridlinesVisible(true);
// plot.setDomainGridlinePaint(Color.white);
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());
StackedAreaRenderer ar = new StackedAreaRenderer2() {
@Override
public String generateURL(CategoryDataset dataset, int row, int column) {
NumberOnlyBuildLabel label = (NumberOnlyBuildLabel) dataset.getColumnKey(column);
return relPath + label.build.getNumber() + "/testReport/";
}
@Override
public String generateToolTip(CategoryDataset dataset, int row, int column) {
NumberOnlyBuildLabel label = (NumberOnlyBuildLabel) dataset.getColumnKey(column);
AbstractTestResultAction a = label.build.getAction(AbstractTestResultAction.class);
switch(row) {
case 0:
return String.valueOf(Messages.AbstractTestResultAction_fail(label.build.getDisplayName(), a.getFailCount()));
case 1:
return String.valueOf(Messages.AbstractTestResultAction_skip(label.build.getDisplayName(), a.getSkipCount()));
default:
return String.valueOf(Messages.AbstractTestResultAction_test(label.build.getDisplayName(), a.getTotalCount()));
}
}
};
plot.setRenderer(ar);
// Failures.
ar.setSeriesPaint(0, ColorPalette.RED);
// Skips.
ar.setSeriesPaint(1, ColorPalette.YELLOW);
// Total.
ar.setSeriesPaint(2, ColorPalette.BLUE);
// crop extra space around the graph
plot.setInsets(new RectangleInsets(0, 0, 0, 5.0));
return chart;
}
use of org.jfree.data.category.CategoryDataset in project libresonic by Libresonic.
the class UserChartController method handleRequest.
@RequestMapping(method = RequestMethod.GET)
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
String type = request.getParameter("type");
CategoryDataset dataset = createDataset(type);
JFreeChart chart = createChart(dataset, request);
int imageHeight = Math.max(IMAGE_MIN_HEIGHT, 15 * dataset.getColumnCount());
ChartUtilities.writeChartAsPNG(response.getOutputStream(), chart, IMAGE_WIDTH, imageHeight);
return null;
}
use of org.jfree.data.category.CategoryDataset in project adempiere by adempiere.
the class MChart method getCategoryDataset.
public CategoryDataset getCategoryDataset() {
dataset = new DefaultCategoryDataset();
loadData();
return (CategoryDataset) dataset;
}
Aggregations