use of org.jfree.chart.JFreeChart in project processdash by dtuma.
the class EVXYChartPanel method adjustStyle.
private void adjustStyle(int width) {
int style;
if (width > medium_window_width)
style = FULL;
else if (width > short_window_width)
style = MED;
else
style = SHORT;
JFreeChart chart = getChart();
chart.removeLegend();
if (style == FULL)
chart.addLegend(legend);
adjustAxis(chart.getXYPlot().getRangeAxis(), style != FULL, yLabel);
adjustAxis(chart.getXYPlot().getDomainAxis(), style == SHORT, xLabel);
}
use of org.jfree.chart.JFreeChart in project processdash by dtuma.
the class EstErrorScatterChart method createChart.
@Override
public JFreeChart createChart() {
JFreeChart chart = super.createChart();
// set minimum/maximum bounds on the two axes
XYPlot xyPlot = chart.getXYPlot();
double cutoff = getPercentParam("cut", 100, 200, 5000);
xyPlot.setDomainAxis(truncAxis(xyPlot.getDomainAxis(), cutoff));
xyPlot.setRangeAxis(truncAxis(xyPlot.getRangeAxis(), cutoff));
xyPlot.setRenderer(new TruncatedItemRenderer(xyPlot.getRenderer()));
// add a box illustrating the target range
if (data.numRows() > 0) {
double box = getPercentParam("pct", 0, 50, 100);
xyPlot.addAnnotation(new XYBoxAnnotation(-box, -box, box, box));
xyPlot.addAnnotation(new XYLineAnnotation(-box, 0, box, 0));
xyPlot.addAnnotation(new XYLineAnnotation(0, -box, 0, box));
}
return chart;
}
use of org.jfree.chart.JFreeChart in project processdash by dtuma.
the class XYChart method createChart.
/** Create a scatter plot. */
@Override
public JFreeChart createChart() {
JFreeChart chart;
String xLabel = null, yLabel = null;
if (!chromeless) {
xLabel = Translator.translate(data.getColName(1));
yLabel = getSetting("yLabel");
if (yLabel == null && data.numCols() == 2)
yLabel = data.getColName(2);
if (yLabel == null)
yLabel = getSetting("units");
if (yLabel == null)
yLabel = "Value";
yLabel = Translator.translate(yLabel);
}
Object autoZero = parameters.get("autoZero");
boolean firstColumnContainsDate = data.numRows() > 0 && data.numCols() > 0 && data.getData(1, 1) instanceof DateData;
if (firstColumnContainsDate || parameters.get("xDate") != null) {
chart = ChartFactory.createTimeSeriesChart(null, xLabel, yLabel, data.xyDataSource(), true, true, false);
if (firstColumnContainsDate && ((DateData) data.getData(1, 1)).isFormatAsDateOnly())
chart.getXYPlot().getRenderer().setBaseToolTipGenerator(new StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT, DateFormat.getDateInstance(DateFormat.SHORT), NumberFormat.getInstance()));
} else {
XYDataset src = data.xyDataSource();
chart = ChartFactory.createScatterPlot(null, xLabel, yLabel, src, PlotOrientation.VERTICAL, true, true, false);
if (src instanceof XYToolTipGenerator) {
chart.getXYPlot().getRenderer().setBaseToolTipGenerator((XYToolTipGenerator) src);
}
String trendLine = getParameter("trend");
if ("none".equalsIgnoreCase(trendLine))
;
else if ("average".equalsIgnoreCase(trendLine))
addTrendLine(chart, XYDataSourceTrendLine.getAverageLine(src, 0, autoZero != null && !autoZero.equals("y")));
else
addTrendLine(chart, XYDataSourceTrendLine.getRegressionLine(src, 0, autoZero != null && !autoZero.equals("y")));
}
if (autoZero != null) {
if (!"x".equals(autoZero))
((NumberAxis) chart.getXYPlot().getRangeAxis()).setAutoRangeIncludesZero(true);
if (!"y".equals(autoZero))
((NumberAxis) chart.getXYPlot().getDomainAxis()).setAutoRangeIncludesZero(true);
}
if (data.numCols() == 2)
chart.removeLegend();
return chart;
}
use of org.jfree.chart.JFreeChart in project dhis2-core by dhis2.
the class ChartController method getChart.
//--------------------------------------------------------------------------
// Get data
//--------------------------------------------------------------------------
@RequestMapping(value = { "/{uid}/data", "/{uid}/data.png" }, method = RequestMethod.GET)
public void getChart(@PathVariable("uid") String uid, @RequestParam(value = "date", required = false) Date date, @RequestParam(value = "ou", required = false) String ou, @RequestParam(value = "width", defaultValue = "800", required = false) int width, @RequestParam(value = "height", defaultValue = "500", required = false) int height, @RequestParam(value = "attachment", required = false) boolean attachment, HttpServletResponse response) throws IOException, WebMessageException {
Chart chart = chartService.getChartNoAcl(uid);
if (chart == null) {
throw new WebMessageException(WebMessageUtils.notFound("Chart does not exist: " + uid));
}
OrganisationUnit unit = ou != null ? organisationUnitService.getOrganisationUnit(ou) : null;
JFreeChart jFreeChart = chartService.getJFreeChart(chart, date, unit, i18nManager.getI18nFormat());
String filename = CodecUtils.filenameEncode(chart.getName()) + ".png";
contextUtils.configureResponse(response, ContextUtils.CONTENT_TYPE_PNG, CacheStrategy.RESPECT_SYSTEM_SETTING, filename, attachment);
ChartUtilities.writeChartAsPNG(response.getOutputStream(), jFreeChart, width, height);
}
use of org.jfree.chart.JFreeChart in project dhis2-core by dhis2.
the class ChartController method getChart.
@RequestMapping(value = { "/data", "/data.png" }, method = RequestMethod.GET)
public void getChart(@RequestParam(value = "in") String indicatorUid, @RequestParam(value = "ou") String organisationUnitUid, @RequestParam(value = "periods", required = false) boolean periods, @RequestParam(value = "width", defaultValue = "800", required = false) int width, @RequestParam(value = "height", defaultValue = "500", required = false) int height, @RequestParam(value = "skipTitle", required = false) boolean skipTitle, @RequestParam(value = "attachment", required = false) boolean attachment, HttpServletResponse response) throws IOException {
Indicator indicator = indicatorService.getIndicator(indicatorUid);
OrganisationUnit unit = organisationUnitService.getOrganisationUnit(organisationUnitUid);
JFreeChart chart;
if (periods) {
chart = chartService.getJFreePeriodChart(indicator, unit, !skipTitle, i18nManager.getI18nFormat());
} else {
chart = chartService.getJFreeOrganisationUnitChart(indicator, unit, !skipTitle, i18nManager.getI18nFormat());
}
contextUtils.configureResponse(response, ContextUtils.CONTENT_TYPE_PNG, CacheStrategy.RESPECT_SYSTEM_SETTING, "chart.png", attachment);
ChartUtilities.writeChartAsPNG(response.getOutputStream(), chart, width, height);
}
Aggregations