List of usage examples for org.jfree.chart ChartFactory createLineChart
public static JFreeChart createLineChart(String title, String categoryAxisLabel, String valueAxisLabel, CategoryDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls)
From source file:View.DialogoEstadisticas.java
private void creaGraficaHistorico(int[] selectedIndices) { // Fuente de Datos DefaultCategoryDataset line_chart_dataset = new DefaultCategoryDataset(); String[] periodos;/*from ww w .j av a 2 s . c o m*/ EdoRes e; for (int j = 0; j < selectedIndices.length; j++) { switch (selectedIndices[j]) { case 0://ventas for (Cuenta c : cuentas) { if (c.getId().equals("IN000")) { if (combrobarIntervalo(c.getPeriodo())) { line_chart_dataset.addValue(c.getSaldo(), c.getNombre(), formatPeriodo(c.getPeriodo())); } } } break; case 1: //clientes for (Cuenta c : cuentas) { if (c.getId().equals("AC003")) { if (combrobarIntervalo(c.getPeriodo())) { line_chart_dataset.addValue(c.getSaldo(), c.getNombre(), formatPeriodo(c.getPeriodo())); } } } break; case 2: //gastosadmin for (Cuenta c : cuentas) { if (c.getId().equals("GA001")) { if (combrobarIntervalo(c.getPeriodo())) { line_chart_dataset.addValue(c.getSaldo(), c.getNombre(), formatPeriodo(c.getPeriodo())); } } } break; case 3://costos for (Cuenta c : cuentas) { if (c.getId().equals("CO000")) { if (combrobarIntervalo(c.getPeriodo())) { line_chart_dataset.addValue(c.getSaldo(), c.getNombre(), formatPeriodo(c.getPeriodo())); } } } break; case 4://almacen for (Cuenta c : cuentas) { if (c.getId().equals("AC002")) { if (combrobarIntervalo(c.getPeriodo())) { line_chart_dataset.addValue(c.getSaldo(), c.getNombre(), formatPeriodo(c.getPeriodo())); } } } break; case 5://efectivo for (Indicador i : indicadores) { if (i.getNombre().equals("Efectivo")) { if (combrobarIntervalo(i.getPeriodo())) { line_chart_dataset.addValue(i.getValor(), i.getNombre(), formatPeriodo(i.getPeriodo())); } } } break; case 6://utilidad for (Cuenta c : cuentas) { if (c.getId().equals("CC001")) { if (combrobarIntervalo(c.getPeriodo())) { line_chart_dataset.addValue(c.getSaldo(), c.getNombre(), formatPeriodo(c.getPeriodo())); } } } break; case 7://gastosop for (Cuenta c : cuentas) { if (c.getId().equals("GA002")) { if (combrobarIntervalo(c.getPeriodo())) { line_chart_dataset.addValue(c.getSaldo(), c.getNombre(), formatPeriodo(c.getPeriodo())); } } } break; case 8://deudiv for (Cuenta c : cuentas) { if (c.getId().equals("AC004")) { if (combrobarIntervalo(c.getPeriodo())) { line_chart_dataset.addValue(c.getSaldo(), c.getNombre(), formatPeriodo(c.getPeriodo())); } } } break; case 9://pagos periodo for (Indicador i : indicadores) { if (i.getNombre().equals("Pagos del periodo")) { if (combrobarIntervalo(i.getPeriodo())) { line_chart_dataset.addValue(i.getValor(), i.getNombre(), formatPeriodo(i.getPeriodo())); } } } break; case 10://utilidadNeta periodo h.buscaPeriodos(); periodos = h.getPeriodos(); for (String p : periodos) { if (combrobarIntervalo(p)) { e = new EdoRes(p); line_chart_dataset.addValue(e.getUtN(), "Utilidad N", formatPeriodo(p)); } } break; case 11://utilidadBruta periodo h.buscaPeriodos(); periodos = h.getPeriodos(); for (String p : periodos) { if (combrobarIntervalo(p)) { e = new EdoRes(p); line_chart_dataset.addValue(e.getUtB(), "Utilidad B", formatPeriodo(p)); } } break; } } JFreeChart chart = ChartFactory.createLineChart("Estadsticas", "periodos", "monto ($)", line_chart_dataset, PlotOrientation.VERTICAL, true, true, false); if (chartPanel != null) { panelG.remove(chartPanel); } //grosor de linea de fx CategoryPlot p = chart.getCategoryPlot(); for (int j = 0; j < selectedIndices.length; j++) { p.getRenderer().setSeriesStroke(j, new BasicStroke(4)); } //color y grosor de grid chart.getCategoryPlot().setDomainGridlinesVisible(true); //grid visible p.setRangeGridlinePaint(Color.black); p.setDomainGridlinePaint(Color.black); p.setRangeGridlineStroke(new BasicStroke(1)); p.setDomainGridlineStroke(new BasicStroke(1)); //titulos de eje y en vertical CategoryAxis domainAxis = ((CategoryPlot) p).getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90); chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(723, 456)); chartPanel.setVisible(true); chartPanel.setSize(723, 456); panelG.add(chartPanel); panelG.revalidate(); panelG.repaint(); }
From source file:pr.ui.InputForm.java
private void showErrorsBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_showErrorsBtnActionPerformed DefaultCategoryDataset categorydataset = new DefaultCategoryDataset(); for (int i = 0; i < algorithm.getErrorLog().size(); i++) { categorydataset.addValue(algorithm.getErrorLog().get(i), "Global error", "" + i); }/* w ww .j ava 2 s. c o m*/ JFreeChart jfreechart = ChartFactory.createLineChart("Error Graph", null, "Error Graph", categorydataset, PlotOrientation.VERTICAL, false, true, false); CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot(); categoryplot.setRangePannable(true); categoryplot.setRangeGridlinesVisible(false); NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis(); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); ChartUtilities.applyCurrentTheme(jfreechart); ChartPanel chartpanel = new ChartPanel(jfreechart); chartpanel.setMouseWheelEnabled(true); Utils.showDialoj("Error Graph", chartpanel, this); }
From source file:lucee.runtime.tag.Chart.java
private void chartLine() throws PageException, IOException { // create the chart... final JFreeChart chart = show3d ? ChartFactory.createLineChart3D(title, xaxistitle, yaxistitle, createDatasetCategory(), PlotOrientation.VERTICAL, false, true, false) : ChartFactory.createLineChart(title, xaxistitle, yaxistitle, createDatasetCategory(), PlotOrientation.VERTICAL, false, true, false); Plot p = chart.getPlot();/*w w w . j ava 2 s . c o m*/ 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); }
From source file:org.ala.spatial.web.services.GDMWSController.java
public static void generateChartByType(String title, String xLabel, String yLabel, Dataset dataset, String outputdir, String type, String filename) throws IOException { JFreeChart jChart = null;/*w w w .j a va 2 s .c o m*/ if ("line".equalsIgnoreCase(type)) { jChart = ChartFactory.createLineChart(title, xLabel, yLabel, (CategoryDataset) dataset, PlotOrientation.VERTICAL, false, false, false); } else if ("bar".equalsIgnoreCase(type)) { System.out.println("Setting up jChart"); jChart = ChartFactory.createBarChart(title, xLabel, yLabel, (CategoryDataset) dataset, PlotOrientation.VERTICAL, false, false, false); System.out.println("Writing image...."); } else if ("xyline".equalsIgnoreCase(type)) { jChart = ChartFactory.createXYLineChart(title, xLabel, yLabel, (XYDataset) dataset, PlotOrientation.VERTICAL, false, false, false); } if ("xyline".equalsIgnoreCase(type)) { XYPlot plot = (XYPlot) jChart.getPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setRangeZeroBaselineVisible(true); plot.setRangeGridlinesVisible(true); plot.setRangeGridlinePaint(Color.LIGHT_GRAY); plot.setRangeGridlineStroke(new BasicStroke(0.5F, 0, 1)); NumberAxis domain = (NumberAxis) plot.getDomainAxis(); domain.setAxisLineVisible(false); domain.setLabelFont(new Font(Font.MONOSPACED, Font.PLAIN, 12)); domain.setAutoRangeIncludesZero(false); NumberAxis range = (NumberAxis) plot.getRangeAxis(); range.setAutoRangeIncludesZero(false); range.setAxisLineVisible(false); range.setLabelFont(new Font(Font.MONOSPACED, Font.PLAIN, 12)); //System.out.println("dataset.getColumnCount(): " + dataset.getColumnCount()); //System.out.println("dataset.getRowCount(): " + dataset.getRowCount()); } else { CategoryPlot plot = (CategoryPlot) jChart.getPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setRangeZeroBaselineVisible(true); plot.setRangeGridlinesVisible(true); plot.setRangeGridlinePaint(Color.LIGHT_GRAY); plot.setRangeGridlineStroke(new BasicStroke(0.5F, 0, 1)); CategoryAxis domain = (CategoryAxis) plot.getDomainAxis(); domain.setAxisLineVisible(false); domain.setLabelFont(new Font(Font.MONOSPACED, Font.PLAIN, 12)); NumberAxis range = (NumberAxis) plot.getRangeAxis(); range.setAutoRangeIncludesZero(false); range.setAxisLineVisible(false); range.setLabelFont(new Font(Font.MONOSPACED, Font.PLAIN, 12)); //System.out.println("dataset.getColumnCount(): " + dataset.getColumnCount()); //System.out.println("dataset.getRowCount(): " + dataset.getRowCount()); } jChart.getTitle().setFont(new Font(Font.MONOSPACED, Font.PLAIN, 14)); ChartUtilities.saveChartAsPNG(new File(outputdir + "plots/" + filename + ".png"), jChart, 900, 500); }
From source file:org.jfree.chart.demo.JFreeChartDemoBase.java
/** * Creates and returns a sample line chart. * * @return a line chart./* w ww .j a v a 2 s .c om*/ */ public JFreeChart createLineChart() { // create a default chart based on some sample data... final String title = this.resources.getString("other.line.title"); final String domain = this.resources.getString("other.line.domain"); final String range = this.resources.getString("other.line.range"); final CategoryDataset data = DemoDatasetFactory.createCategoryDataset(); final JFreeChart chart = ChartFactory.createLineChart(title, domain, range, data, PlotOrientation.VERTICAL, true, true, false); // then customise it a little... chart.setBackgroundImage(JFreeChart.INFO.getLogo()); chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 0, 1000, Color.green)); final CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setBackgroundAlpha(0.65f); return chart; }
From source file:net.sf.fspdfs.chartthemes.spring.GenericChartTheme.java
protected JFreeChart createLineChart() throws JRException { ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); JFreeChart freeChart = ChartFactory.createLineChart( (String) evaluateExpression(getChart().getTitleExpression()), (String) evaluateExpression(((JRLinePlot) getPlot()).getCategoryAxisLabelExpression()), (String) evaluateExpression(((JRLinePlot) getPlot()).getValueAxisLabelExpression()), (CategoryDataset) getDataset(), getPlot().getOrientation(), isShowLegend(), true, false); configureChart(freeChart, getPlot()); CategoryPlot categoryPlot = (CategoryPlot) freeChart.getPlot(); JRLinePlot linePlot = (JRLinePlot) getPlot(); LineAndShapeRenderer lineRenderer = (LineAndShapeRenderer) categoryPlot.getRenderer(); boolean isShowShapes = linePlot.getShowShapes() == null ? true : linePlot.getShowShapes().booleanValue(); boolean isShowLines = linePlot.getShowLines() == null ? true : linePlot.getShowLines().booleanValue(); lineRenderer.setBaseShapesVisible(isShowShapes);//FIXMECHART check this lineRenderer.setBaseLinesVisible(isShowLines); //FIXME labels? // Handle the axis formating for the category axis configureAxis(categoryPlot.getDomainAxis(), linePlot.getCategoryAxisLabelFont(), linePlot.getCategoryAxisLabelColor(), linePlot.getCategoryAxisTickLabelFont(), linePlot.getCategoryAxisTickLabelColor(), linePlot.getCategoryAxisTickLabelMask(), linePlot.getCategoryAxisVerticalTickLabels(), linePlot.getOwnCategoryAxisLineColor(), false, (Comparable) evaluateExpression(linePlot.getDomainAxisMinValueExpression()), (Comparable) evaluateExpression(linePlot.getDomainAxisMaxValueExpression())); // Handle the axis formating for the value axis configureAxis(categoryPlot.getRangeAxis(), linePlot.getValueAxisLabelFont(), linePlot.getValueAxisLabelColor(), linePlot.getValueAxisTickLabelFont(), linePlot.getValueAxisTickLabelColor(), linePlot.getValueAxisTickLabelMask(), linePlot.getValueAxisVerticalTickLabels(), linePlot.getOwnValueAxisLineColor(), true, (Comparable) evaluateExpression(linePlot.getRangeAxisMinValueExpression()), (Comparable) evaluateExpression(linePlot.getRangeAxisMaxValueExpression())); return freeChart; }
From source file:charts.Chart.java
public static void LineChart(DefaultCategoryDataset dataset, String title, String x_axis_label, String y_axis_label, boolean showlegend, float maxvalue, float minvalue) { JFrame chartwindow = new JFrame(title); JFreeChart jfreechart = ChartFactory.createLineChart(title, x_axis_label, y_axis_label, dataset, PlotOrientation.VERTICAL, showlegend, // include legend true, // tooltips true // urls );/* w ww. jav a 2 s.c o m*/ CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot(); categoryplot.setBackgroundPaint(Color.white); categoryplot.setRangeGridlinePaint(Color.black); NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis(); numberaxis.setStandardTickUnits(NumberAxis.createStandardTickUnits()); CategoryPlot plot = (CategoryPlot) jfreechart.getPlot(); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); if (minvalue == 0 && maxvalue == 0) { rangeAxis.setAutoRangeIncludesZero(true); } else { rangeAxis.setRange(minvalue, maxvalue); } LineAndShapeRenderer lineandshaperenderer = (LineAndShapeRenderer) categoryplot.getRenderer(); lineandshaperenderer.setBaseStroke(new BasicStroke(2.0f)); lineandshaperenderer.setShapesVisible(true); lineandshaperenderer.setDrawOutlines(true); lineandshaperenderer.setUseFillPaint(true); lineandshaperenderer.setFillPaint(Color.white); //GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.MAGENTA, 0.0f, 0.0f, Color.MAGENTA); //lineandshaperenderer.setSeriesPaint(0, gp1); //ou lineandshaperenderer.setSeriesPaint(0, Color.RED); JPanel jpanel = new ChartPanel(jfreechart); jpanel.setPreferredSize(new Dimension(defaultwidth, defaultheight)); chartwindow.setContentPane(jpanel); chartwindow.pack(); RefineryUtilities.centerFrameOnScreen(chartwindow); chartwindow.setVisible(true); }
From source file:net.sf.fspdfs.chartthemes.simple.SimpleChartTheme.java
protected JFreeChart createLineChart() throws JRException { ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); JFreeChart freeChart = ChartFactory.createLineChart( (String) evaluateExpression(getChart().getTitleExpression()), (String) evaluateExpression(((JRLinePlot) getPlot()).getCategoryAxisLabelExpression()), (String) evaluateExpression(((JRLinePlot) getPlot()).getValueAxisLabelExpression()), (CategoryDataset) getDataset(), getPlot().getOrientation(), isShowLegend(), true, false); configureChart(freeChart, getPlot()); CategoryPlot categoryPlot = (CategoryPlot) freeChart.getPlot(); JRLinePlot linePlot = (JRLinePlot) getPlot(); LineAndShapeRenderer lineRenderer = (LineAndShapeRenderer) categoryPlot.getRenderer(); boolean isShowShapes = linePlot.getShowShapes() == null ? true : linePlot.getShowShapes().booleanValue(); boolean isShowLines = linePlot.getShowLines() == null ? true : linePlot.getShowLines().booleanValue(); lineRenderer.setBaseShapesVisible(isShowShapes);//FIXMECHART check this lineRenderer.setBaseLinesVisible(isShowLines); //FIXME labels? // Handle the axis formating for the category axis configureAxis(categoryPlot.getDomainAxis(), linePlot.getCategoryAxisLabelFont(), linePlot.getCategoryAxisLabelColor(), linePlot.getCategoryAxisTickLabelFont(), linePlot.getCategoryAxisTickLabelColor(), linePlot.getCategoryAxisTickLabelMask(), linePlot.getCategoryAxisVerticalTickLabels(), linePlot.getOwnCategoryAxisLineColor(), getDomainAxisSettings(),/* ww w . j av a2 s . c o m*/ (Comparable) evaluateExpression(linePlot.getDomainAxisMinValueExpression()), (Comparable) evaluateExpression(linePlot.getDomainAxisMaxValueExpression())); // Handle the axis formating for the value axis configureAxis(categoryPlot.getRangeAxis(), linePlot.getValueAxisLabelFont(), linePlot.getValueAxisLabelColor(), linePlot.getValueAxisTickLabelFont(), linePlot.getValueAxisTickLabelColor(), linePlot.getValueAxisTickLabelMask(), linePlot.getValueAxisVerticalTickLabels(), linePlot.getOwnValueAxisLineColor(), getRangeAxisSettings(), (Comparable) evaluateExpression(linePlot.getRangeAxisMinValueExpression()), (Comparable) evaluateExpression(linePlot.getRangeAxisMaxValueExpression())); return freeChart; }
From source file:net.sf.jasperreports.chartthemes.spring.GenericChartTheme.java
protected JFreeChart createLineChart() throws JRException { ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); JFreeChart freeChart = ChartFactory.createLineChart(evaluateTextExpression(getChart().getTitleExpression()), evaluateTextExpression(((JRLinePlot) getPlot()).getCategoryAxisLabelExpression()), evaluateTextExpression(((JRLinePlot) getPlot()).getValueAxisLabelExpression()), (CategoryDataset) getDataset(), getPlot().getOrientationValue().getOrientation(), isShowLegend(), true, false);/* w w w . ja v a 2 s . c o m*/ configureChart(freeChart, getPlot()); CategoryPlot categoryPlot = (CategoryPlot) freeChart.getPlot(); JRLinePlot linePlot = (JRLinePlot) getPlot(); LineAndShapeRenderer lineRenderer = (LineAndShapeRenderer) categoryPlot.getRenderer(); boolean isShowShapes = linePlot.getShowShapes() == null ? true : linePlot.getShowShapes(); boolean isShowLines = linePlot.getShowLines() == null ? true : linePlot.getShowLines(); lineRenderer.setBaseShapesVisible(isShowShapes);//FIXMECHART check this lineRenderer.setBaseLinesVisible(isShowLines); //FIXME labels? // Handle the axis formating for the category axis configureAxis(categoryPlot.getDomainAxis(), linePlot.getCategoryAxisLabelFont(), linePlot.getCategoryAxisLabelColor(), linePlot.getCategoryAxisTickLabelFont(), linePlot.getCategoryAxisTickLabelColor(), linePlot.getCategoryAxisTickLabelMask(), linePlot.getCategoryAxisVerticalTickLabels(), linePlot.getOwnCategoryAxisLineColor(), false, (Comparable<?>) evaluateExpression(linePlot.getDomainAxisMinValueExpression()), (Comparable<?>) evaluateExpression(linePlot.getDomainAxisMaxValueExpression())); // Handle the axis formating for the value axis configureAxis(categoryPlot.getRangeAxis(), linePlot.getValueAxisLabelFont(), linePlot.getValueAxisLabelColor(), linePlot.getValueAxisTickLabelFont(), linePlot.getValueAxisTickLabelColor(), linePlot.getValueAxisTickLabelMask(), linePlot.getValueAxisVerticalTickLabels(), linePlot.getOwnValueAxisLineColor(), true, (Comparable<?>) evaluateExpression(linePlot.getRangeAxisMinValueExpression()), (Comparable<?>) evaluateExpression(linePlot.getRangeAxisMaxValueExpression())); return freeChart; }
From source file:com.smanempat.controller.ControllerEvaluation.java
private void showChart(int nilaiK, double[][] evalValue, JPanel panelChart, JPanel panelChart1, JPanel panelChart2) {/*from ww w . j a va 2 s .c o m*/ DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.addValue(evalValue[0][0], "Kriteria", "Accuracy"); dataset.addValue(evalValue[1][0], "Kriteria", "Recall"); dataset.addValue(evalValue[2][0], "Kriteria", "Precision"); JFreeChart lineChart = ChartFactory.createLineChart("Grafik Hasil Pengujian Single Test", "Kriteria", "Persentase", dataset, PlotOrientation.VERTICAL, false, true, false); CategoryPlot linePlot = lineChart.getCategoryPlot(); LineAndShapeRenderer lineRender = new LineAndShapeRenderer(); lineRender.setBaseShapesVisible(true); lineRender.setDrawOutlines(true); lineRender.setUseFillPaint(true); lineRender.setBaseFillPaint(Color.white); lineRender.setSeriesStroke(0, new BasicStroke(1.0f)); lineRender.setSeriesOutlineStroke(0, new BasicStroke(5.0f)); lineRender.setSeriesShape(0, new Ellipse2D.Double(-5.0, -5.0, 10.0, 10.0)); linePlot.setRenderer(lineRender); ChartPanel cp = new ChartPanel(lineChart); panelChart.removeAll(); panelChart.add(cp); panelChart.validate(); }