List of usage examples for org.jfree.chart ChartFactory createAreaChart
public static JFreeChart createAreaChart(String title, String categoryAxisLabel, String valueAxisLabel, CategoryDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls)
From source file:org.adempiere.apps.graph.ChartBuilder.java
private JFreeChart createAreaChart() { // create the chart... JFreeChart chart = ChartFactory.createAreaChart(chartModel.get_Translation(MChart.COLUMNNAME_Name), // chart title chartModel.get_Translation(MChart.COLUMNNAME_DomainLabel), // domain axis label chartModel.get_Translation(MChart.COLUMNNAME_RangeLabel), // range axis label getCategoryDataset(), // data X_AD_Chart.CHARTORIENTATION_Horizontal.equals(chartModel.getChartOrientation()) ? PlotOrientation.HORIZONTAL : PlotOrientation.VERTICAL, // orientation chartModel.isDisplayLegend(), // include legend true, // tooltips? true // URLs? );//from w w w. j a v a 2 s .c o m setupCategoryChart(chart); return chart; }
From source file:net.sf.fspdfs.chartthemes.simple.SimpleChartTheme.java
/** * *//*from www . j a v a2s. c o m*/ protected JFreeChart createAreaChart() throws JRException { ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); JFreeChart jfreeChart = ChartFactory.createAreaChart( (String) evaluateExpression(getChart().getTitleExpression()), (String) evaluateExpression(((JRAreaPlot) getPlot()).getCategoryAxisLabelExpression()), (String) evaluateExpression(((JRAreaPlot) getPlot()).getValueAxisLabelExpression()), (CategoryDataset) getDataset(), getPlot().getOrientation(), isShowLegend(), true, false); configureChart(jfreeChart, getPlot()); JRAreaPlot areaPlot = (JRAreaPlot) getPlot(); // Handle the axis formating for the category axis configureAxis(((CategoryPlot) jfreeChart.getPlot()).getDomainAxis(), areaPlot.getCategoryAxisLabelFont(), areaPlot.getCategoryAxisLabelColor(), areaPlot.getCategoryAxisTickLabelFont(), areaPlot.getCategoryAxisTickLabelColor(), areaPlot.getCategoryAxisTickLabelMask(), areaPlot.getCategoryAxisVerticalTickLabels(), areaPlot.getOwnCategoryAxisLineColor(), getDomainAxisSettings(), (Comparable) evaluateExpression(areaPlot.getDomainAxisMinValueExpression()), (Comparable) evaluateExpression(areaPlot.getDomainAxisMaxValueExpression())); // Handle the axis formating for the value axis configureAxis(((CategoryPlot) jfreeChart.getPlot()).getRangeAxis(), areaPlot.getValueAxisLabelFont(), areaPlot.getValueAxisLabelColor(), areaPlot.getValueAxisTickLabelFont(), areaPlot.getValueAxisTickLabelColor(), areaPlot.getValueAxisTickLabelMask(), areaPlot.getValueAxisVerticalTickLabels(), areaPlot.getOwnValueAxisLineColor(), getRangeAxisSettings(), (Comparable) evaluateExpression(areaPlot.getRangeAxisMinValueExpression()), (Comparable) evaluateExpression(areaPlot.getRangeAxisMaxValueExpression())); return jfreeChart; }
From source file:net.sf.jasperreports.chartthemes.simple.SimpleChartTheme.java
/** * */// ww w .j a v a 2s . c o m protected JFreeChart createAreaChart() throws JRException { ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); JFreeChart jfreeChart = ChartFactory.createAreaChart( evaluateTextExpression(getChart().getTitleExpression()), evaluateTextExpression(((JRAreaPlot) getPlot()).getCategoryAxisLabelExpression()), evaluateTextExpression(((JRAreaPlot) getPlot()).getValueAxisLabelExpression()), (CategoryDataset) getDataset(), getPlot().getOrientationValue().getOrientation(), isShowLegend(), true, false); configureChart(jfreeChart, getPlot()); JRAreaPlot areaPlot = (JRAreaPlot) getPlot(); // Handle the axis formating for the category axis configureAxis(((CategoryPlot) jfreeChart.getPlot()).getDomainAxis(), areaPlot.getCategoryAxisLabelFont(), areaPlot.getCategoryAxisLabelColor(), areaPlot.getCategoryAxisTickLabelFont(), areaPlot.getCategoryAxisTickLabelColor(), areaPlot.getCategoryAxisTickLabelMask(), areaPlot.getCategoryAxisVerticalTickLabels(), areaPlot.getOwnCategoryAxisLineColor(), getDomainAxisSettings(), (Comparable<?>) evaluateExpression(areaPlot.getDomainAxisMinValueExpression()), (Comparable<?>) evaluateExpression(areaPlot.getDomainAxisMaxValueExpression())); // Handle the axis formating for the value axis configureAxis(((CategoryPlot) jfreeChart.getPlot()).getRangeAxis(), areaPlot.getValueAxisLabelFont(), areaPlot.getValueAxisLabelColor(), areaPlot.getValueAxisTickLabelFont(), areaPlot.getValueAxisTickLabelColor(), areaPlot.getValueAxisTickLabelMask(), areaPlot.getValueAxisVerticalTickLabels(), areaPlot.getOwnValueAxisLineColor(), getRangeAxisSettings(), (Comparable<?>) evaluateExpression(areaPlot.getRangeAxisMinValueExpression()), (Comparable<?>) evaluateExpression(areaPlot.getRangeAxisMaxValueExpression())); return jfreeChart; }
From source file:hudson.plugins.plot.PlotData.java
/** * Creates a Chart of the style indicated by getEffStyle() using the given dataset. * Defaults to using createLineChart.// w w w .j a va 2 s.c om */ private JFreeChart createChart(PlotCategoryDataset dataset) { String s = getUrlStyle(); if (s.equalsIgnoreCase("area")) { return ChartFactory.createAreaChart(getURLTitle(), /*categoryAxisLabel=*/null, getYaxis(), dataset, PlotOrientation.VERTICAL, hasLegend(), /*tooltips=*/true, /*url=*/false); } if (s.equalsIgnoreCase("bar")) { return ChartFactory.createBarChart(getURLTitle(), /*categoryAxisLabel=*/null, getYaxis(), dataset, PlotOrientation.VERTICAL, hasLegend(), /*tooltips=*/true, /*url=*/false); } if (s.equalsIgnoreCase("bar3d")) { return ChartFactory.createBarChart3D(getURLTitle(), /*categoryAxisLabel=*/null, getYaxis(), dataset, PlotOrientation.VERTICAL, hasLegend(), /*tooltips=*/true, /*url=*/false); } if (s.equalsIgnoreCase("line3d")) { return ChartFactory.createLineChart3D(getURLTitle(), /*categoryAxisLabel=*/null, getYaxis(), dataset, PlotOrientation.VERTICAL, hasLegend(), /*tooltips=*/true, /*url=*/false); } if (s.equalsIgnoreCase("stackedarea")) { return ChartFactory.createStackedAreaChart(getURLTitle(), /*categoryAxisLabel=*/null, getYaxis(), dataset, PlotOrientation.VERTICAL, hasLegend(), /*tooltips=*/true, /*url=*/false); } if (s.equalsIgnoreCase("stackedbar")) { return ChartFactory.createStackedBarChart(getURLTitle(), /*categoryAxisLabel=*/null, getYaxis(), dataset, PlotOrientation.VERTICAL, hasLegend(), /*tooltips=*/true, /*url=*/false); } if (s.equalsIgnoreCase("stackedbar3d")) { return ChartFactory.createStackedBarChart3D(getURLTitle(), /*categoryAxisLabel=*/null, getYaxis(), dataset, PlotOrientation.VERTICAL, hasLegend(), /*tooltips=*/true, /*url=*/false); } if (s.equalsIgnoreCase("waterfall")) { return ChartFactory.createWaterfallChart(getURLTitle(), /*categoryAxisLabel=*/null, getYaxis(), dataset, PlotOrientation.VERTICAL, hasLegend(), /*tooltips=*/true, /*url=*/false); } return ChartFactory.createLineChart(getURLTitle(), /*categoryAxisLabel=*/null, getYaxis(), dataset, PlotOrientation.VERTICAL, hasLegend(), /*tooltips=*/true, /*url=*/false); }
From source file:org.pentaho.chart.plugin.jfreechart.JFreeChartFactoryEngine.java
public JFreeChart makeAreaChart(ChartModel chartModel, MultiSeriesDataModel dataModel, IChartLinkGenerator linkGenerator) { DefaultCategoryDataset categoryDataset = createCategoryDataset(dataModel); org.pentaho.chart.model.TwoAxisPlot twoAxisPlot = (org.pentaho.chart.model.TwoAxisPlot) chartModel .getPlot();/*from w w w. ja v a 2s.c om*/ String title = ""; if ((chartModel.getTitle() != null) && (chartModel.getTitle().getText() != null) && (chartModel.getTitle().getText().trim().length() > 0)) { title = chartModel.getTitle().getText(); } AxesLabels axesLabels = getAxesLabels(chartModel); PlotOrientation plotOrientation = (twoAxisPlot.getOrientation() == Orientation.HORIZONTAL) ? PlotOrientation.HORIZONTAL : PlotOrientation.VERTICAL; boolean showLegend = (chartModel.getLegend() != null) && (chartModel.getLegend().getVisible()); JFreeChart chart = ChartFactory.createAreaChart(title, axesLabels.domainAxisLabel, axesLabels.rangeAxisLabel, categoryDataset, plotOrientation, showLegend, true, false); initCategoryPlot(chart, chartModel, linkGenerator); initChart(chart, chartModel); return chart; }
From source file:com.babynamesUI.java
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed String name = nameentered.getText(); String y = yearentered.getText(); String sex = null;//from w ww . j a v a2 s . c om if (male2.isSelected()) sex = "male"; else if (female2.isSelected()) sex = "female"; int[] Lvalue = new int[100]; int[] Lyear = new int[100]; int j = 0; try { int year = Integer.parseInt(y); int i = year; while (i <= 2013) { String filename = sex + "_cy" + i + "_top.csv"; InputStream is = babynamesUI.class.getResourceAsStream("/resourse/" + filename); BufferedReader br = null; String line = ""; String cvsSplitBy = ","; br = new BufferedReader(new InputStreamReader(is)); line = br.readLine(); while ((line = br.readLine()) != null) { int val; // use comma as separator String[] names = line.split(cvsSplitBy); String s1 = names[1].trim(); String s2 = names[0].trim(); //System.out.println("name:-"+s1); if (s1.charAt(0) == '"') { val = Integer.parseInt(s1.substring(1, s1.length() - 1)); } else { val = Integer.parseInt(s1); } if (s2.charAt(0) == '"') { s2 = s2.substring(1, s2.length() - 1); } //System.out.println("name:-"+s2); if (s2.equalsIgnoreCase(name)) { Lvalue[j] = val; Lyear[j] = i; j++; } } i++; } } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } catch (Exception e) { JOptionPane.showMessageDialog(null, "invalid entry"); e.printStackTrace(); } //graph grp =new graph(this,Lvalue,Lyear,j); //grp.setVisible(true); DefaultCategoryDataset dataset = new DefaultCategoryDataset(); String val = ""; //textArea1.setText("Year | Number of Birth"); for (int p = 0; p < j; p++) { val = Integer.toString(Lyear[p]); dataset.addValue(Lvalue[p], val, val); // textArea1.setText( textArea1.getText()+" \n"+year[i] +" | "+ value[i]); } JFreeChart chart = ChartFactory.createAreaChart("Name Trend", "year", "Number of Birth", dataset, PlotOrientation.VERTICAL, false, true, false); CategoryPlot p = chart.getCategoryPlot(); p.setRangeGridlinePaint(Color.BLACK); ChartFrame frame = new ChartFrame("Chart for Name Trend", chart); frame.setVisible(true); frame.setSize(1200, 700); frame.setLocationRelativeTo(null); setVisible(false); dispose(); }
From source file:net.sf.jasperreports.engine.fill.DefaultChartTheme.java
/** * *//*from ww w. ja va 2 s. c o m*/ protected JFreeChart createAreaChart() throws JRException { ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); JFreeChart jfreeChart = ChartFactory.createAreaChart( evaluateTextExpression(getChart().getTitleExpression()), evaluateTextExpression(((JRAreaPlot) getPlot()).getCategoryAxisLabelExpression()), evaluateTextExpression(((JRAreaPlot) getPlot()).getValueAxisLabelExpression()), (CategoryDataset) getDataset(), getPlot().getOrientationValue().getOrientation(), isShowLegend(), true, false); configureChart(jfreeChart); JRAreaPlot areaPlot = (JRAreaPlot) getPlot(); // Handle the axis formating for the category axis configureAxis(((CategoryPlot) jfreeChart.getPlot()).getDomainAxis(), areaPlot.getCategoryAxisLabelFont(), areaPlot.getCategoryAxisLabelColor(), areaPlot.getCategoryAxisTickLabelFont(), areaPlot.getCategoryAxisTickLabelColor(), areaPlot.getCategoryAxisTickLabelMask(), areaPlot.getCategoryAxisVerticalTickLabels(), areaPlot.getCategoryAxisLineColor(), false, (Comparable<?>) evaluateExpression(areaPlot.getDomainAxisMinValueExpression()), (Comparable<?>) evaluateExpression(areaPlot.getDomainAxisMaxValueExpression())); // Handle the axis formating for the value axis configureAxis(((CategoryPlot) jfreeChart.getPlot()).getRangeAxis(), areaPlot.getValueAxisLabelFont(), areaPlot.getValueAxisLabelColor(), areaPlot.getValueAxisTickLabelFont(), areaPlot.getValueAxisTickLabelColor(), areaPlot.getValueAxisTickLabelMask(), areaPlot.getValueAxisVerticalTickLabels(), areaPlot.getValueAxisLineColor(), true, (Comparable<?>) evaluateExpression(areaPlot.getRangeAxisMinValueExpression()), (Comparable<?>) evaluateExpression(areaPlot.getRangeAxisMaxValueExpression())); return jfreeChart; }
From source file:hudson.plugins.plot.Plot.java
/** * Creates a Chart of the style indicated by getEffStyle() using the given * dataset. Defaults to using createLineChart. *//*from w w w.j a v a 2s . com*/ private JFreeChart createChart(PlotCategoryDataset dataset) { String s = getUrlStyle(); if ("area".equalsIgnoreCase(s)) { return ChartFactory.createAreaChart(getURLTitle(), /* * categoryAxisLabel= */null, getYaxis(), dataset, PlotOrientation.VERTICAL, hasLegend(), /* * tooltips * = */ true, /* url= */false); } if ("bar".equalsIgnoreCase(s)) { return ChartFactory.createBarChart(getURLTitle(), /* * categoryAxisLabel= */null, getYaxis(), dataset, PlotOrientation.VERTICAL, hasLegend(), /* * tooltips * = */ true, /* url= */false); } if ("bar3d".equalsIgnoreCase(s)) { return ChartFactory.createBarChart3D(getURLTitle(), /* * categoryAxisLabel * = */null, getYaxis(), dataset, PlotOrientation.VERTICAL, hasLegend(), /* * tooltips * = */ true, /* url= */false); } if ("line3d".equalsIgnoreCase(s)) { return ChartFactory.createLineChart3D(getURLTitle(), /* * categoryAxisLabel * = */null, getYaxis(), dataset, PlotOrientation.VERTICAL, hasLegend(), /* * tooltips * = */ true, /* url= */false); } if ("lineSimple".equalsIgnoreCase(s)) { return ChartFactory.createLineChart(getURLTitle(), /*categoryAxisLabel=*/null, getYaxis(), dataset, PlotOrientation.VERTICAL, hasLegend(), /*tooltips=*/true, /*url=*/false); } if ("stackedarea".equalsIgnoreCase(s)) { return ChartFactory.createStackedAreaChart(getURLTitle(), /* * categoryAxisLabel * = */null, getYaxis(), dataset, PlotOrientation.VERTICAL, hasLegend(), /* * tooltips * = */ true, /* url= */false); } if ("stackedbar".equalsIgnoreCase(s)) { return ChartFactory.createStackedBarChart(getURLTitle(), /* * categoryAxisLabel * = */null, getYaxis(), dataset, PlotOrientation.VERTICAL, hasLegend(), /* * tooltips * = */ true, /* url= */false); } if ("stackedbar3d".equalsIgnoreCase(s)) { return ChartFactory.createStackedBarChart3D(getURLTitle(), /* * categoryAxisLabel * = */null, getYaxis(), dataset, PlotOrientation.VERTICAL, hasLegend(), /* * tooltips * = */ true, /* url= */false); } if ("waterfall".equalsIgnoreCase(s)) { return ChartFactory.createWaterfallChart(getURLTitle(), /* * categoryAxisLabel * = */null, getYaxis(), dataset, PlotOrientation.VERTICAL, hasLegend(), /* * tooltips * = */ true, /* url= */false); } return ChartFactory.createLineChart(getURLTitle(), /* categoryAxisLabel= */ null, getYaxis(), dataset, PlotOrientation.VERTICAL, hasLegend(), /* tooltips= */true, /* url= */false); }
From source file:ro.nextreports.engine.chart.JFreeChartExporter.java
private JFreeChart createAreaChart() throws QueryException { barDataset = new DefaultCategoryDataset(); String chartTitle = replaceParameters(chart.getTitle().getTitle()); chartTitle = StringUtil.getI18nString(chartTitle, I18nUtil.getLanguageByName(chart, language)); Object[] charts = new Object[chart.getYColumns().size()]; List<String> legends = chart.getYColumnsLegends(); boolean hasLegend = false; for (int i = 0; i < charts.length; i++) { String legend = ""; try {/* w w w. ja v a2 s. c o m*/ legend = replaceParameters(legends.get(i)); legend = StringUtil.getI18nString(legend, I18nUtil.getLanguageByName(chart, language)); } catch (IndexOutOfBoundsException ex) { // no legend set } // Important : must have default different legends used in barDataset.addValue if ((legend == null) || "".equals(legend.trim())) { legend = DEFAULT_LEGEND_PREFIX + String.valueOf(i + 1); } else { hasLegend = true; } charts[i] = legend; } String xLegend = StringUtil.getI18nString(replaceParameters(chart.getXLegend().getTitle()), I18nUtil.getLanguageByName(chart, language)); String yLegend = StringUtil.getI18nString(replaceParameters(chart.getYLegend().getTitle()), I18nUtil.getLanguageByName(chart, language)); byte style = chart.getType().getStyle(); JFreeChart jfreechart = ChartFactory.createAreaChart("Area Chart", // chart title xLegend, // x-axis Label yLegend, // y-axis Label barDataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips false // urls ); // hide legend if necessary if (!hasLegend) { jfreechart.removeLegend(); } // hide border jfreechart.setBorderVisible(false); // title setTitle(jfreechart); // chart colors & values shown on bars boolean showValues = (chart.getShowYValuesOnChart() == null) ? false : chart.getShowYValuesOnChart(); CategoryPlot plot = (CategoryPlot) jfreechart.getPlot(); plot.setForegroundAlpha(transparency); AreaRenderer renderer = (AreaRenderer) plot.getRenderer(); DecimalFormat decimalformat; DecimalFormat percentageFormat; if (chart.getYTooltipPattern() == null) { decimalformat = new DecimalFormat("#"); percentageFormat = new DecimalFormat("0.00%"); } else { decimalformat = new DecimalFormat(chart.getYTooltipPattern()); percentageFormat = decimalformat; } for (int i = 0; i < charts.length; i++) { renderer.setSeriesPaint(i, chart.getForegrounds().get(i)); if (showValues) { renderer.setSeriesItemLabelsVisible(i, true); renderer.setSeriesItemLabelGenerator(i, new StandardCategoryItemLabelGenerator("{2}", decimalformat, percentageFormat)); } } if (showValues) { // increase a little bit the range axis to view all item label values over bars plot.getRangeAxis().setUpperMargin(0.2); } // grid axis visibility & colors if ((chart.getXShowGrid() != null) && !chart.getXShowGrid()) { plot.setDomainGridlinesVisible(false); } else { if (chart.getXGridColor() != null) { plot.setDomainGridlinePaint(chart.getXGridColor()); } else { plot.setDomainGridlinePaint(Color.BLACK); } } if ((chart.getYShowGrid() != null) && !chart.getYShowGrid()) { plot.setRangeGridlinesVisible(false); } else { if (chart.getYGridColor() != null) { plot.setRangeGridlinePaint(chart.getYGridColor()); } else { plot.setRangeGridlinePaint(Color.BLACK); } } // chart background plot.setBackgroundPaint(chart.getBackground()); // labels color plot.getDomainAxis().setTickLabelPaint(chart.getXColor()); plot.getRangeAxis().setTickLabelPaint(chart.getYColor()); // legend color plot.getDomainAxis().setLabelPaint(chart.getXLegend().getColor()); plot.getRangeAxis().setLabelPaint(chart.getYLegend().getColor()); // legend font plot.getDomainAxis().setLabelFont(chart.getXLegend().getFont()); plot.getRangeAxis().setLabelFont(chart.getYLegend().getFont()); // axis color plot.getDomainAxis().setAxisLinePaint(chart.getxAxisColor()); plot.getRangeAxis().setAxisLinePaint(chart.getyAxisColor()); // hide labels if ((chart.getXShowLabel() != null) && !chart.getXShowLabel()) { plot.getDomainAxis().setTickLabelsVisible(false); plot.getDomainAxis().setTickMarksVisible(false); } if ((chart.getYShowLabel() != null) && !chart.getYShowLabel()) { plot.getRangeAxis().setTickLabelsVisible(false); plot.getRangeAxis().setTickMarksVisible(false); } // label orientation CategoryAxis domainAxis = plot.getDomainAxis(); if (chart.getXorientation() == Chart.VERTICAL) { domainAxis .setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 2)); } else if (chart.getXorientation() == Chart.DIAGONAL) { domainAxis .setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 4)); } else if (chart.getXorientation() == Chart.HALF_DIAGONAL) { domainAxis .setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 8)); } // labels fonts plot.getDomainAxis().setTickLabelFont(chart.getXLabelFont()); plot.getRangeAxis().setTickLabelFont(chart.getYLabelFont()); createChart(plot.getRangeAxis(), charts); return jfreechart; }
From source file:lucee.runtime.tag.Chart.java
private void chartArea() throws PageException, IOException { // create the chart... final JFreeChart chart = ChartFactory.createAreaChart(title, xaxistitle, yaxistitle, createDatasetCategory(), PlotOrientation.VERTICAL, false, true, false); Plot p = chart.getPlot();/*w w w . ja va 2 s. c om*/ Font _font = getFont(); // settings setMarker(chart, p); setBackground(chart, p); setBorder(chart, p); set3d(p); setFont(chart, _font); setLabelFormat(chart); setLegend(chart, p, _font); setTooltip(chart); setScale(chart); setAxis(chart); setColor(chart); writeOut(chart); }