List of usage examples for org.jfree.chart JFreeChart getCategoryPlot
public CategoryPlot getCategoryPlot()
From source file:UserInterface.CustomerRole.ViewProfileJPanel.java
private void purchasingBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_purchasingBtnActionPerformed DefaultCategoryDataset dataset = new DefaultCategoryDataset(); String series1 = "Purchases"; for (Order o : network.getMasterOrderCatalog().getOrderCatalog()) { if (o.getBuyer().equals(account)) { for (OrderItem oi : o.getOrderItemList()) { dataset.addValue(oi.getQuantity(), series1, o.getDate()); }//w w w.j av a 2 s . com } } String chartTitle = "Purchase History"; String categoryAxisLabel = "TimeStamp"; String valueAxisLabel = "Values"; JFreeChart chart = ChartFactory.createLineChart(chartTitle, categoryAxisLabel, valueAxisLabel, dataset); chart.setBackgroundPaint(Color.white); chart.getTitle().setPaint(Color.BLACK); CategoryPlot p = chart.getCategoryPlot(); p.setRangeGridlinePaint(Color.BLUE); ChartFrame frame = new ChartFrame("Graph of Purchase Habit", chart); frame.setVisible(true); frame.setSize(450, 350); }
From source file:cz.cvut.kbe.crypthelper.ui.MainPanel.java
private void styleChart(JFreeChart chart) { chart.getTitle().setPaint(Color.BLACK); chart.setBackgroundPaint(new Color(1f, 1f, 1f, 0f)); CategoryPlot p = chart.getCategoryPlot(); p.setRangeGridlinePaint(Color.red); }
From source file:userInterface.CustomerWorkArea.CustomerWorkAreaJPanel.java
private void createChart() { DefaultCategoryDataset CarInspectionDataset = new DefaultCategoryDataset(); ArrayList<CarInspection> carInspectionList = userAccount.getPerson().getCarInspectionHistory() .getCarInspectionHistory();/* w w w. j a va2 s . com*/ /*At least 2 vital sign records needed to show chart */ if (carInspectionList.isEmpty() || carInspectionList.size() == 1) { JOptionPane.showMessageDialog(this, " At least 2 car Inspection records needed to show chart!", "Warning", JOptionPane.INFORMATION_MESSAGE); return; } for (CarInspection carList : carInspectionList) { CarInspectionDataset.addValue(carList.getAlignment(), "RR", carList.getTimestamp()); CarInspectionDataset.addValue(carList.getBattery(), "HR", carList.getTimestamp()); CarInspectionDataset.addValue(carList.getBrakingSys(), "BP", carList.getTimestamp()); CarInspectionDataset.addValue(carList.getOilCheck(), "WT", carList.getTimestamp()); } JFreeChart carInspectionChart = ChartFactory.createBarChart3D("Car Inspection Chart", "Time Stamp", "Values", CarInspectionDataset, PlotOrientation.VERTICAL, true, false, false); carInspectionChart.setBackgroundPaint(Color.white); CategoryPlot carChartPlot = carInspectionChart.getCategoryPlot(); carChartPlot.setBackgroundPaint(Color.lightGray); CategoryAxis vitalSignDomainAxis = carChartPlot.getDomainAxis(); vitalSignDomainAxis .setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0)); NumberAxis vitalSignRangeAxis = (NumberAxis) carChartPlot.getRangeAxis(); vitalSignRangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); ChartFrame chartFrame = new ChartFrame("Chart", carInspectionChart); chartFrame.setVisible(true); chartFrame.setSize(500, 500); }
From source file:userinterface.PatientRole.PatientLikeMeJPanel.java
private void tblPatientsMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tblPatientsMouseClicked frameLineGraph.setVisible(false);//from w w w . j a va 2s. c o m int selectedRow = tblPatients.getSelectedRow(); if (selectedRow < 0) { return; } selectedPatient = (Patient) tblPatients.getValueAt(selectedRow, 0); selectedUA = selectedPatient.getUserAccount(); //JOptionPane.showMessageDialog(null, selectedPatient + " " +selectedPatient.vitalSignHistory.getVitalSignHistory()); if (selectedPatient.vitalSignHistory.getVitalSignHistory().size() > 0) { String legend = null; DefaultCategoryDataset dataset = new DefaultCategoryDataset(); for (VitalSign vs : selectedPatient.vitalSignHistory.getVitalSignHistory()) { /*if(vs.getState().equalsIgnoreCase("ABNORMAL")) legend=vs.getTimestamp().concat(" (" +vs.getState()+")"); else*/ legend = vs.getTimestamp(); ///JOptionPane.showMessageDialog(null,vs); dataset.addValue(vs.getRespiratoryRate(), legend, "Respiratory Rate"); dataset.addValue(vs.getHeartRate(), legend, "Heart Rate"); dataset.addValue(vs.getSystolicBloodPressure(), legend, "Blood Pressure"); dataset.addValue(vs.getWeight(), legend, "Weight"); } JFreeChart chart = ChartFactory.createLineChart3D("Vital Signs", "Vital Signs", "Values", dataset, PlotOrientation.VERTICAL, true, true, true); CategoryPlot P = chart.getCategoryPlot(); P.setRangeGridlinePaint(Color.BLACK); frameLineGraph.getContentPane().removeAll(); //ChartFrame frame = new ChartFrame("Bar Charts",chart); ChartPanel cp = new ChartPanel(chart); frameLineGraph.getContentPane().add(cp); //frameLineGraph.repaint(); //frameLineGraph.setSize(650, 550); frameLineGraph.setVisible(true); } else { JOptionPane.showMessageDialog(null, "There's no Vital Sign reported for this patient"); return; } }
From source file:edu.ucla.stat.SOCR.chart.demo.BarChart3DDemo3.java
/** * Creates a chart./*from ww w . ja va 2 s . co m*/ * * @param dataset the dataset. * * @return The chart. */ protected JFreeChart createChart(CategoryDataset dataset) { JFreeChart chart = ChartFactory.createBarChart3D(chartTitle, // chart title domainLabel, // domain axis label rangeLabel, // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation !legendPanelOn, // include legend true, // tooltips false // urls ); CategoryPlot plot = chart.getCategoryPlot(); CategoryAxis axis = plot.getDomainAxis(); axis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 8.0)); CategoryItemRenderer renderer = plot.getRenderer(); renderer.setBaseItemLabelsVisible(true); BarRenderer r = (BarRenderer) renderer; r.setMaximumBarWidth(0.05); r.setLegendItemLabelGenerator(new SOCRCategorySeriesLabelGenerator()); setCategorySummary(dataset); return chart; }
From source file:userInterface.doctor.ReportingPatientVitalHistJPanel.java
private void respJButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_respJButtonActionPerformed DefaultTableModel dtm = (DefaultTableModel) vitalJTable.getModel(); DefaultCategoryDataset respBarChartSet = new DefaultCategoryDataset(); for (VitalSignInfo vhl : patient.getVitalHistory().getVitalHistory()) { respBarChartSet.setValue(vhl.getRespRate(), "Resp rate", vhl.getCurrentTime()); }//from w w w. j a va2s . c o m JFreeChart respChart = ChartFactory.createBarChart3D("Vital History", "Time", "Resp Rate", respBarChartSet, PlotOrientation.VERTICAL, false, true, false); CategoryPlot p = respChart.getCategoryPlot(); p.setRangeGridlinePaint(Color.BLUE); ChartFrame frame = new ChartFrame("Bar Chart for Respiratory Vital Sign", respChart); frame.setVisible(true); frame.setSize(450, 350); }
From source file:userInterface.doctor.ReportingPatientVitalHistJPanel.java
private void heartJButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_heartJButtonActionPerformed // TODO add your handling code here: DefaultTableModel dtm = (DefaultTableModel) vitalJTable.getModel(); DefaultCategoryDataset heartBarChartSet = new DefaultCategoryDataset(); for (VitalSignInfo vhl : patient.getVitalHistory().getVitalHistory()) { heartBarChartSet.setValue(vhl.getHeartRate(), "Heart rate", vhl.getCurrentTime()); }/*ww w. j ava 2s . c om*/ JFreeChart respChart = ChartFactory.createBarChart3D("Vital History", "Time", "Heart Rate", heartBarChartSet, PlotOrientation.VERTICAL, false, true, false); CategoryPlot p = respChart.getCategoryPlot(); p.setRangeGridlinePaint(Color.BLUE); ChartFrame frame = new ChartFrame("Bar Chart for Heart rate Vital Information", respChart); frame.setVisible(true); frame.setSize(450, 350); }
From source file:userInterface.doctor.ReportingPatientVitalHistJPanel.java
private void sysBPJButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_sysBPJButtonActionPerformed // TODO add your handling code here: DefaultTableModel dtm = (DefaultTableModel) vitalJTable.getModel(); DefaultCategoryDataset sysBPbarChartSet = new DefaultCategoryDataset(); for (VitalSignInfo vhl : patient.getVitalHistory().getVitalHistory()) { sysBPbarChartSet.setValue(vhl.getSystolicBP(), "Systonic BP rate", vhl.getCurrentTime()); }/* w ww .j a va2 s. com*/ JFreeChart respChart = ChartFactory.createBarChart3D("Vital History", "Time", "Systonic BP Rate", sysBPbarChartSet, PlotOrientation.VERTICAL, false, true, false); CategoryPlot p = respChart.getCategoryPlot(); p.setRangeGridlinePaint(Color.BLUE); ChartFrame frame = new ChartFrame("Bar Chart for Systonic BP Vital Sign", respChart); frame.setVisible(true); frame.setSize(450, 350); }
From source file:j2se.jfreechart.barchart.BarChart3DDemo2.java
/** * Creates a chart.//from www . j a v a2 s . co m * * @param dataset the dataset. * * @return The chart. */ private JFreeChart createChart(final CategoryDataset dataset) { final JFreeChart chart = ChartFactory.createBarChart3D("3D Bar Chart Demo 2", // chart title "Category", // domain axis label "Value", // range axis label dataset, // data PlotOrientation.HORIZONTAL, // orientation true, // include legend true, // tooltips false // urls ); final CategoryPlot plot = chart.getCategoryPlot(); plot.setForegroundAlpha(1.0f); // left align the category labels... final CategoryAxis axis = plot.getDomainAxis(); final CategoryLabelPositions p = axis.getCategoryLabelPositions(); final CategoryLabelPosition left = new CategoryLabelPosition(RectangleAnchor.LEFT, TextBlockAnchor.CENTER_LEFT, TextAnchor.CENTER_LEFT, 0.0, CategoryLabelWidthType.RANGE, 0.30f); axis.setCategoryLabelPositions(CategoryLabelPositions.replaceLeftPosition(p, left)); return chart; }
From source file:com.mergano.core.GraphChart.java
private JFreeChart createChart(final CategoryDataset dataset) { final JFreeChart chart = ChartFactory.createBarChart("Revenue", "Monthly", "Amount", dataset, PlotOrientation.VERTICAL, false, true, false); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... // set the background color for the chart... chart.setBackgroundPaint(Color.white); // get a reference to the plot for further customisation... final CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); // set the range axis to display integers only... final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setUpperMargin(0.15);/*from ww w . j a v a2 s .co m*/ // disable bar outlines... final CategoryItemRenderer renderer = plot.getRenderer(); renderer.setSeriesItemLabelsVisible(0, Boolean.TRUE); final CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_90); return chart; }