List of usage examples for org.jfree.chart ChartFactory createBarChart
public static JFreeChart createBarChart(String title, String categoryAxisLabel, String valueAxisLabel, CategoryDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls)
From source file:org.jrecruiter.web.actions.admin.ShowStatisticsAction.java
private static JFreeChart createChart(final CategoryDataset categorydataset, final String chartTitle) { final JFreeChart chart = ChartFactory.createBarChart(chartTitle, "Jobs", "Number of Hits", categorydataset, PlotOrientation.VERTICAL, true, true, false); final CategoryPlot categoryplot = (CategoryPlot) chart.getPlot(); categoryplot.setNoDataMessage("NO DATA!"); chart.setBackgroundPaint(new Color(245, 245, 255)); chart.setBorderPaint(new Color(204, 204, 204)); chart.setBorderStroke(new BasicStroke(1f)); final LegendTitle legend = chart.getLegend(); legend.setWidth(1000);//w w w . jav a 2s. c o m legend.setPosition(RectangleEdge.BOTTOM); final BlockBorder border = new BlockBorder(new Color(204, 204, 204)); legend.setBorder(border); final CategoryPlot categoryPlot = (CategoryPlot) chart.getPlot(); categoryPlot.setBackgroundPaint(Color.WHITE); categoryPlot.setRangeGridlinePaint(new Color(204, 204, 204)); categoryPlot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); final NumberAxis numberaxis = (NumberAxis) categoryPlot.getRangeAxis(); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); final BarRenderer renderer = (BarRenderer) categoryPlot.getRenderer(); renderer.setDrawBarOutline(true); final ItemLabelPosition itemlabelposition = new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER); renderer.setPositiveItemLabelPosition(itemlabelposition); renderer.setItemLabelGenerator(new StandardCategoryItemLabelGenerator()); renderer.setItemLabelsVisible(true); return chart; }
From source file:org.jfree.chart.demo.ThumbnailDemo1.java
private static JFreeChart createChart1(CategoryDataset categorydataset) { JFreeChart jfreechart = ChartFactory.createBarChart("Bar Chart Demo 1", "Category", "Value", categorydataset, PlotOrientation.VERTICAL, true, true, false); jfreechart.setBackgroundPaint(Color.white); CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot(); NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis(); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); BarRenderer barrenderer = (BarRenderer) categoryplot.getRenderer(); barrenderer.setDrawBarOutline(false); GradientPaint gradientpaint = new GradientPaint(0.0F, 0.0F, Color.blue, 0.0F, 0.0F, new Color(0, 0, 64)); GradientPaint gradientpaint1 = new GradientPaint(0.0F, 0.0F, Color.green, 0.0F, 0.0F, new Color(0, 64, 0)); GradientPaint gradientpaint2 = new GradientPaint(0.0F, 0.0F, Color.red, 0.0F, 0.0F, new Color(64, 0, 0)); barrenderer.setSeriesPaint(0, gradientpaint); barrenderer.setSeriesPaint(1, gradientpaint1); barrenderer.setSeriesPaint(2, gradientpaint2); barrenderer.setLegendItemToolTipGenerator(new StandardCategorySeriesLabelGenerator("Tooltip: {0}")); CategoryAxis categoryaxis = categoryplot.getDomainAxis(); categoryaxis.setCategoryLabelPositions( CategoryLabelPositions.createUpRotationLabelPositions(0.52359877559829882D)); return jfreechart; }
From source file:view.PrograssCharts.java
/** * Creates new form PrograssCharts/*from w ww . j a va2 s . c o m*/ */ public PrograssCharts(java.awt.Frame parent, boolean modal) { super(parent, modal); try { initComponents(); setSize(1400, 800); jPanel1.setVisible(false); jPanel2.setVisible(false); new Thread(new Runnable() { @Override public void run() { loading1(); loading2(); run(); } }).start(); DefaultCategoryDataset dataset = new DefaultCategoryDataset(); DefaultCategoryDataset dataset1 = new DefaultCategoryDataset(); dataset.setValue(QuestionLab.cat1, "gfdg", "Collectns"); dataset.setValue(QuestionLab.cat2, "gfdg", "Data"); dataset.setValue(QuestionLab.cat3, "gfdg", "Dev"); dataset.setValue(QuestionLab.cat4, "gfdg", "Excep"); dataset.setValue(QuestionLab.cat5, "gfdg", "File"); dataset.setValue(QuestionLab.cat6, "gfdg", "FlowCon"); dataset.setValue(QuestionLab.cat7, "gfdg", "Format"); dataset.setValue(QuestionLab.cat8, "gfdg", "GC"); dataset.setValue(QuestionLab.cat9, "gfdg", "IC"); dataset.setValue(QuestionLab.cat10, "gfdg", "VarArgs"); dataset.setValue(QuestionLab.cat11, "gfdg", "Fundamt"); dataset.setValue(QuestionLab.cat12, "gfdg", "Modif"); dataset.setValue(QuestionLab.cat13, "gfdg", "OOP"); dataset.setValue(QuestionLab.cat14, "gfdg", "Vari"); dataset.setValue(QuestionLab.cat15, "gfdg", "String"); dataset.setValue(QuestionLab.cat16, "gfdg", "Threads"); dataset.setValue(QuestionLab.cat17, "gfdg", "WC"); JFreeChart freeChart = ChartFactory.createBarChart("Exam Prograss by Subjects", "Subject", "Marks", dataset, PlotOrientation.VERTICAL, false, true, false); //JFreeChart freeChart1 = ChartFactory.createBarChart("Income", " Name", "Incomesss", dataset1, PlotOrientation.VERTICAL, false, true, false); TimeSeries pop = new TimeSeries("Population", Day.class); //JFreeChart chart=ChartFactory.create CategoryPlot plot = freeChart.getCategoryPlot(); plot.setRangeGridlinePaint(Color.BLUE); ChartFrame frame = new ChartFrame("Exam Prograss", freeChart); // frame.setVisible(true); // frame.setSize(550, 450); // JPanel jPanel1 = new JPanel(); jPanel1.setLayout(new java.awt.BorderLayout()); ChartPanel CP = new ChartPanel(freeChart); CP.setPreferredSize(new Dimension(785, 440)); CP.setMouseWheelEnabled(true); jPanel1.add(CP); jPanel1.revalidate(); ArrayList<Exam> setChartValue = ServerConnector.getServerConnector().getExamController() .getPreviousMarks(PracticeExamLogIn.studentNic); for (Exam exam : setChartValue) { //dataset1.setValue(exam.getMarks(), "gfdg9", exam.getDate()); pop.addOrUpdate(new Day(exam.getDate()), exam.getMarks()); System.out.println("mar" + exam.getMarks()); System.out.println("date" + exam.getDate()); } TimeSeriesCollection myDataset = new TimeSeriesCollection(); myDataset.addSeries(pop); JFreeChart myChart = ChartFactory.createTimeSeriesChart("Population Your Marks", "Date", "Population", myDataset, true, true, false); //try { //ChartUtilities.saveChartAsJPEG(new File("C:\\chart.jpg"), chart, 500, 300); //} catch (IOException e) { //System.err.println("Problem occurred creating chart."); //} //JFreeChart chart=ChartFactory.create CategoryPlot plot1 = freeChart.getCategoryPlot(); plot1.setRangeGridlinePaint(Color.BLUE); //ChartFrame frame1 = new ChartFrame("Exam Prograss", freeChart1); // frame.setVisible(true); // frame.setSize(550, 450); // JPanel jPanel1 = new JPanel(); jPanel2.setLayout(new java.awt.BorderLayout()); ChartPanel CP1 = new ChartPanel(myChart); CP1.setPreferredSize(new Dimension(785, 440)); CP1.setMouseWheelEnabled(true); jPanel2.add(CP1); jPanel2.revalidate(); } catch (RemoteException | ClassNotFoundException | SQLException | NotBoundException | MalformedURLException ex) { Logger.getLogger(PrograssCharts.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:org.gaixie.micrite.car.action.CarfileChartAction.java
/** * 2D//ww w .ja va 2 s. c o m * @return "success" */ public String getBarChart() { CategoryDataset dca = CarfileService.getCarDictionaryBarDataset(this.getQueryBean()); chart = ChartFactory.createBarChart(getText("?"), getText(""), getText(""), dca, PlotOrientation.VERTICAL, true, false, false); BarStyle.styleOne(chart); this.putChartResultList(chart); return SUCCESS; }
From source file:org.jfree.experimental.chart.swt.demo.SWTBarChartDemo1.java
/** * Creates a sample chart./*from www.j a va2s . c o m*/ * * @param dataset the dataset. * * @return The chart. */ private static JFreeChart createChart(CategoryDataset dataset) { // create the chart... JFreeChart chart = ChartFactory.createBarChart("SWTBarChartDemo1", // chart title "Category", // domain axis label "Value", // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips? false // URLs? ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... // get a reference to the plot for further customisation... CategoryPlot plot = (CategoryPlot) chart.getPlot(); // set the range axis to display integers only... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // disable bar outlines... BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setDrawBarOutline(false); // the SWTGraphics2D class doesn't handle GradientPaint well, so // replace the gradient painter from the default theme with a // standard painter... renderer.setBarPainter(new StandardBarPainter()); CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0)); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }
From source file:org.amanzi.awe.distribution.ui.widgets.DistributionChartWidget.java
private JFreeChart createChart(final DistributionChartDataset distributionDataset, final CategoryItemRenderer renderer) { final JFreeChart chart = ChartFactory.createBarChart("Distribution Chart", "Values", "Numbers", distributionDataset, PlotOrientation.VERTICAL, false, false, false); final CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setRenderer(renderer);/*from w w w. java 2s . c o m*/ plot.setBackgroundPaint(PLOT_BACKGROUND); chart.setBackgroundPaint(CHART_BACKGROUND); return chart; }
From source file:org.squale.squaleweb.util.graph.AuditsSizeMaker.java
/** * @return le diagramme JFreeChart/* ww w . j a v a2s . com*/ */ public JFreeChart getChart() { JFreeChart retChart = super.getChart(); if (null == retChart) { retChart = ChartFactory.createBarChart(mTitle, mXLabel, mYLabel, mDataSet, PlotOrientation.VERTICAL, true, false, false); final CategoryPlot plot = retChart.getCategoryPlot(); // Formate l'axe des X final CategoryAxis axis = (CategoryAxis) plot.getDomainAxis(); // dfinit des units entires pour l'axe de gauche plot.getRangeAxis().setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // gere les couleurs du graph BarRenderer renderer = (BarRenderer) plot.getRenderer(); // la panel au dimension par dfaut final ChartPanel chartPanel = new ChartPanel(retChart); chartPanel.setPreferredSize(new java.awt.Dimension(getDefaultHeight(), getDefaultWidth())); retChart.setBackgroundPaint(Color.WHITE); super.setChart(retChart); } return retChart; }
From source file:org.agmip.ui.afsirs.frames.GraphOutput.java
public void addGraph() { JFreeChart chart = ChartFactory.createBarChart("IRRIGATION REQUIREMENTS(INCHES)", "MONTH", "IRR", createDataset(0), PlotOrientation.VERTICAL, true, true, false); chart.setBackgroundPaint(Color.white); CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(600, 270)); jTabbedPane1.addTab("Irrigation Requirement", chartPanel); if (utils.getICODE() >= 0) { //JFreeChart chart1 = ChartFactory.createBarChart("IRRIGATION REQUIREMENTS(INCHES)", "BI-WEEK", "IRR", createDataset(1), PlotOrientation.VERTICAL, true, true, false); //JFreeChart chart2 = ChartFactory.createBarChart("IRRIGATION REQUIREMENTS(INCHES)", "WEEK", "IRR", createDataset(2), PlotOrientation.VERTICAL, true, true, false); JFreeChart chart1 = ChartFactory.createBarChart("IRRIGATION REQUIREMENTS(INCHES)", "1-In-10", "IRR", createDataset(1), PlotOrientation.VERTICAL, true, true, false); JFreeChart chart2 = ChartFactory.createBarChart("IRRIGATION REQUIREMENTS(INCHES)", "2-In-10", "IRR", createDataset(2), PlotOrientation.VERTICAL, true, true, false); chart1.setBackgroundPaint(Color.white); chart2.setBackgroundPaint(Color.white); plot = chart1.getCategoryPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot = chart2.getCategoryPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); ChartPanel chartPanel1 = new ChartPanel(chart1); chartPanel1.setPreferredSize(new java.awt.Dimension(600, 270)); //jTabbedPane1.addTab("Bi-Week Graph", chartPanel1); jTabbedPane1.addTab("1-In-10", chartPanel1); ChartPanel chartPanel2 = new ChartPanel(chart2); chartPanel2.setPreferredSize(new java.awt.Dimension(600, 270)); //jTabbedPane1.addTab("Weekly Graph", chartPanel2); jTabbedPane1.addTab("2-In-10", chartPanel2); }//from w w w .j a va 2 s.c o m }
From source file:script.imglib.analysis.BarChart.java
@SuppressWarnings("unchecked") static private final JFreeChart createChart(final Map<? extends Number, ? extends Number> data, final String title, final String xLabel, final String yLabel) { DefaultCategoryDataset dcd = new DefaultCategoryDataset(); for (final Map.Entry<? extends Number, ? extends Number> e : data.entrySet()) { dcd.addValue(e.getValue(), "", (Comparable) e.getKey()); }//from w w w . j a v a2s .co m boolean legend = false; boolean tooltips = true; boolean urls = false; JFreeChart chart = ChartFactory.createBarChart(title, xLabel, yLabel, dcd, PlotOrientation.VERTICAL, legend, tooltips, urls); setBarTheme(chart); return chart; }
From source file:org.gaixie.micrite.enterprise.action.EnterpriseChartAction.java
/** * 2D/*w ww . ja va 2 s . c o m*/ * @return "success" */ public String getBarChart() { CategoryDataset dca = enterpriseService.getEnterpriseSourceBarDataset(this.getQueryBean()); chart = ChartFactory.createBarChart(getText("?"), getText(""), getText("?"), dca, PlotOrientation.VERTICAL, true, false, false); BarStyle.styleOne(chart); this.putChartResultList(chart); return SUCCESS; }