List of usage examples for org.jfree.chart JFreeChart getCategoryPlot
public CategoryPlot getCategoryPlot()
From source file:com.sjsu.uidesign.ExecStatus.java
public ExecStatus() { super();/*from www . j a v a 2 s .c o m*/ super.setTitle("Task Execution Status"); super.setSize(500, 500); super.setResizable(true); super.setLocationRelativeTo(null); JLabel usageImage = new JLabel(); //usageImage.setIcon(new ImageIcon("Pie_3.png")); //usageImage.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/sjsu/uidesign/Bar_4.png"))); // NOI18N //add(usageImage); DefaultCategoryDataset barChartData = new DefaultCategoryDataset(); barChartData.setValue(6, "Cache Cleanup", "Cache Cleanup"); barChartData.setValue(8, "Antivirus Scan", "Antivirus Scan"); barChartData.setValue(7, "Empty Recycle Bin", "Empty Recycle Bin"); JFreeChart barChart = ChartFactory.createBarChart("Task Execution Status", "Task Name", "Status", createDataset(), PlotOrientation.VERTICAL, true, true, false); CategoryPlot barChar = barChart.getCategoryPlot(); barChar.setRangeGridlinePaint(Color.ORANGE); ChartPanel barPanel = new ChartPanel(barChart); JPanel panelChart = new JPanel(); panelChart.removeAll(); panelChart.add(barPanel, BorderLayout.CENTER); panelChart.validate(); add(panelChart); }
From source file:view.tankDepthDetails.BarrChart.java
/** * Creates new form BarrChart//from w w w.j a va 2s .co m */ public BarrChart() { initComponents(); DefaultCategoryDataset dcd = new DefaultCategoryDataset(); float s = 8; dcd.setValue(s, "Marks", "Dumindu"); dcd.setValue(88.80, "Marks", "lakal"); dcd.setValue(78.80, "Marks", "Charitha"); dcd.setValue(7.80, "Marks", "lahiru"); dcd.setValue(76.80, "Marks", "mahin"); dcd.setValue(90.80, "Marks", "gin"); JFreeChart Jchart = ChartFactory.createBarChart("Tank Level Records", "Time", "Tank Level", dcd, PlotOrientation.VERTICAL, true, true, false); CategoryPlot plot = Jchart.getCategoryPlot(); plot.setRangeGridlinePaint(java.awt.Color.black); ChartFrame chartfra = new ChartFrame("Tank Level Records", Jchart, true); // chartfra.setVisible(true); chartfra.setSize(400, 500); ChartPanel chartPanel = new ChartPanel(Jchart); jPanel2.removeAll(); jPanel2.add(chartPanel); jPanel2.updateUI(); }
From source file:net.sf.jasperreports.customizers.axis.RangeAxisCustomizer.java
@Override public void customize(JFreeChart jfc, JRChart jrc) { ValueAxis valueAxis = null;//from www . ja v a 2 s. c o m if ((jfc.getPlot() instanceof XYPlot)) { valueAxis = jfc.getXYPlot().getRangeAxis(); } else if (jfc.getPlot() instanceof CategoryPlot) { valueAxis = jfc.getCategoryPlot().getRangeAxis(); } if (valueAxis != null) { configValueAxis(valueAxis, PROPERTY_MIN_VALUE, PROPERTY_MAX_VALUE); if (valueAxis instanceof NumberAxis) { configNumberAxis((NumberAxis) valueAxis, PROPERTY_TICK_UNIT); } } }
From source file:br.upe.ecomp.dosa.controller.chart.FileBoxplotChartManager.java
private JFreeChart createChart(String title, String xLabel, String yLabel, BoxAndWhiskerCategoryDataset dataset, boolean logarithmicYAxis) { final CategoryAxis xAxis = new CategoryAxis("Sample"); final NumberAxis yAxis; if (logarithmicYAxis) { yAxis = new LogarithmicAxis("Fitness (Log10)"); ((LogarithmicAxis) yAxis).setExpTickLabelsFlag(true); } else {/*w w w . j ava2 s . c o m*/ yAxis = new NumberAxis("Fitness"); } yAxis.setAutoRangeIncludesZero(false); yAxis.setAutoRange(true); final BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer(); renderer.setFillBox(true); renderer.setBaseCreateEntities(true); // renderer.setArtifactPaint(Color.green); renderer.setBaseOutlinePaint(Color.blue); renderer.setToolTipGenerator(new BoxAndWhiskerToolTipGenerator()); final JFreeChart chart = ChartFactory.createBoxAndWhiskerChart(title, xAxis.getLabel(), yAxis.getLabel(), dataset, true); final CategoryPlot plot = chart.getCategoryPlot();// new CategoryPlot(dataset, xAxis, yAxis, // renderer); plot.setBackgroundPaint(Color.white); // chart.setBackgroundPaint(Color.white); plot.setRangeGridlinePaint(Color.lightGray); plot.setRenderer(renderer); plot.setRangeAxis(yAxis); yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); return chart; }
From source file:com.etest.view.tq.charts.GraphicalInventoryBarChart.java
public GraphicalInventoryBarChart() { setModal(true);/*from w ww. ja va 2s .co m*/ VerticalLayout v = new VerticalLayout(); v.setMargin(true); // Panel panel = new Panel(); DefaultCategoryDataset dataset = new DefaultCategoryDataset(); for (Curriculum c : cs.getAllCurriculum()) { for (int i = 0; i < 2; i++) { if (i == 0) { dataset.addValue(rs.getTotalCasesBySubject(c.getCurriculumId()), "Cases", c.getSubject()); } else { dataset.addValue(rs.getTotalItemsBySubject(c.getCurriculumId()), "Items", c.getSubject()); } } } JFreeChart chart = ChartFactory.createBarChart("Inventory of Items and Cases", "Subjects", "", dataset, PlotOrientation.VERTICAL, true, true, false); CategoryPlot plot = chart.getCategoryPlot(); BarRenderer renderer = (BarRenderer) plot.getRenderer(); Color color; for (int i = 0; i < dataset.getRowCount(); i++) { if (i % 2 == 0) { renderer.setSeriesPaint(i, new Color(0, 0, 255)); } else { renderer.setSeriesPaint(i, new Color(255, 0, 0)); } } // JFreeChartWrapper wrapper = new JFreeChartWrapper(chart){ // // @Override // public void attach(){ // super.attach(); // setResource("src", getSource()); // } // // }; v.addComponent(new ReportChartWrapper(chart, null, null)); v.setWidthUndefined(); v.setHeightUndefined(); setContent(v); getContent().setWidthUndefined(); getContent().setHeightUndefined(); center(); }
From source file:Demo.LineGraph.java
private void InitChart() { JFreeChart chart = ChartFactory.createLineChart("Yield", "sample NB", "Probability", dataSet, PlotOrientation.VERTICAL, false, false, false); CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.lightGray); plot.setRangeGridlinePaint(Color.lightGray); plot.setDomainGridlinesVisible(true); plot.setNoDataMessage("no data"); LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer(); renderer.setBaseItemLabelsVisible(true); renderer.setSeriesPaint(0, Color.BLUE); renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true);// w w w . ja v a 2 s . co m renderer.setBaseItemLabelsVisible(true); renderer.setBasePositiveItemLabelPosition( new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_LEFT)); renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator()); renderer.setBaseItemLabelFont(new Font("Times New Romain", 0, 10)); plot.setRenderer(renderer); CategoryAxis axis = plot.getDomainAxis(); axis.setCategoryLabelPositions(CategoryLabelPositions.createDownRotationLabelPositions(Math.PI / 6.0)); chartPane = new ChartPanel(chart); }
From source file:com.mycompany.task1.Chart.java
private JFreeChart displayChart(DefaultCategoryDataset dataSet) { JFreeChart chart; chart = ChartFactory.createBarChart("Irysy", "ilo", " ", dataSet, PlotOrientation.VERTICAL, true, true, true);//from w ww. j av a 2 s . c o m CategoryPlot plot = chart.getCategoryPlot(); //chart.removeLegend(); plot.setRangeGridlinePaint(Color.black); ChartFrame frame; frame = new ChartFrame("Irysy", chart); frame.setVisible(true); frame.setSize(700, 550); return chart; }
From source file:org.pentaho.plugin.jfreereport.reportcharts.LineChartExpression.java
protected JFreeChart computeCategoryChart(final CategoryDataset dataset) { final PlotOrientation orientation = computePlotOrientation(); if (isThreeD()) { final JFreeChart chart = ChartFactory.createLineChart3D(computeTitle(), getCategoryAxisLabel(), getValueAxisLabel(), dataset, orientation, isShowLegend(), false, false); chart.getCategoryPlot().setDomainAxis(new FormattedCategoryAxis3D(getCategoryAxisLabel(), getCategoricalAxisMessageFormat(), getRuntime().getResourceBundleFactory().getLocale())); final CategoryPlot plot = (CategoryPlot) chart.getPlot(); configureLogarithmicAxis(plot);/*from w ww . ja va2s.com*/ return chart; } else { final JFreeChart chart = ChartFactory.createLineChart(computeTitle(), getCategoryAxisLabel(), getValueAxisLabel(), dataset, orientation, isShowLegend(), false, false); chart.getCategoryPlot().setDomainAxis(new FormattedCategoryAxis(getCategoryAxisLabel(), getCategoricalAxisMessageFormat(), getRuntime().getResourceBundleFactory().getLocale())); final CategoryPlot plot = (CategoryPlot) chart.getPlot(); configureLogarithmicAxis(plot); return chart; } }
From source file:com.sonyericsson.jenkins.plugins.bfa.graphs.StackedBarChart.java
@Override protected JFreeChart createGraph() { DefaultCategoryDataset dataset = createDataset(); JFreeChart chart = ChartFactory.createStackedBarChart(getTitle(), getXAxisTitle(), getYAxisTitle(), dataset, PlotOrientation.VERTICAL, true, true, false); final CategoryPlot plot = chart.getCategoryPlot(); int index = dataset.getRowIndex(NO_FAILURE); if (index >= 0) { plot.getRenderer().setSeriesVisibleInLegend(index, false); }/* w w w . j a va 2 s .c o m*/ CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90); domainAxis.setCategoryMargin(0); final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); return chart; }
From source file:net.sf.dynamicreports.test.jasper.chart.PercentageChartDataTest.java
@Override public void test() { super.test(); numberOfPagesTest(1);//from ww w.ja va2 s . co m String[] categories = new String[] { "value1", "value2", "value3" }; String[] series = new String[] { "Column2", "Column3" }; Number[][] values = new Number[][] { { 2d / 6 * 100, 4d / 6 * 100 }, { 4d / 10 * 100, 6d / 10 * 100 }, { 6d / 14 * 100, 8d / 14 * 100 }, { 8d / 18 * 100, 10d / 18 * 100 } }; chartCountTest("summary.chart1", 1); chartCategoryCountTest("summary.chart1", 0, 4); chartSeriesCountTest("summary.chart1", 0, 2); chartDataTest("summary.chart1", 0, categories, series, values); DefaultCategoryDataset categoryDataset = new DefaultCategoryDataset(); categoryDataset.addValue(1.191, "row", "column"); JFreeChart chart = getChart("summary.chart1", 0); CategoryItemRenderer renderer1 = chart.getCategoryPlot().getRenderer(); Assert.assertNotNull(renderer1.getBaseItemLabelGenerator()); Assert.assertEquals("1.19", renderer1.getBaseItemLabelGenerator().generateLabel(categoryDataset, 0, 0)); Assert.assertTrue(renderer1.getBaseItemLabelsVisible()); chartCountTest("summary.chart2", 1); chartCategoryCountTest("summary.chart2", 0, 4); chartSeriesCountTest("summary.chart2", 0, 2); chartDataTest("summary.chart2", 0, categories, series, values); chart = getChart("summary.chart2", 0); renderer1 = chart.getCategoryPlot().getRenderer(); Assert.assertNotNull(renderer1.getBaseItemLabelGenerator()); Assert.assertEquals("1.2", renderer1.getBaseItemLabelGenerator().generateLabel(categoryDataset, 0, 0)); Assert.assertTrue(renderer1.getBaseItemLabelsVisible()); chartCountTest("summary.chart3", 1); chartCategoryCountTest("summary.chart3", 0, 4); chartSeriesCountTest("summary.chart3", 0, 2); chartDataTest("summary.chart3", 0, categories, series, values); chartCountTest("summary.chart4", 1); chartCategoryCountTest("summary.chart4", 0, 4); chartSeriesCountTest("summary.chart4", 0, 2); chartDataTest("summary.chart4", 0, categories, series, values); chartCountTest("summary.chart5", 1); chartCategoryCountTest("summary.chart5", 0, 4); chartSeriesCountTest("summary.chart5", 0, 2); chartDataTest("summary.chart5", 0, categories, series, values); chartCountTest("summary.chart6", 1); chartCategoryCountTest("summary.chart6", 0, 4); chartSeriesCountTest("summary.chart6", 0, 2); chartDataTest("summary.chart6", 0, categories, series, values); chartCountTest("summary.chart7", 1); chartCategoryCountTest("summary.chart7", 0, 4); chartSeriesCountTest("summary.chart7", 0, 2); chartDataTest("summary.chart7", 0, categories, series, values); chartCountTest("summary.chart8", 1); chartCategoryCountTest("summary.chart8", 0, 4); chartSeriesCountTest("summary.chart8", 0, 2); chartDataTest("summary.chart8", 0, categories, series, values); chart = getChart("summary.chart9", 0); StandardPieSectionLabelGenerator labelGenerator = (StandardPieSectionLabelGenerator) ((PiePlot) chart .getPlot()).getLabelGenerator(); String labelFormat = labelGenerator.getLabelFormat(); Assert.assertEquals("Label format", "{0} ({2})", labelFormat); DefaultPieDataset dataset = new DefaultPieDataset(); dataset.setValue("key1", 21); dataset.setValue("key2", 122); Assert.assertEquals("key1 (14.7%)", labelGenerator.generateSectionLabel(dataset, "key1")); }