/** * Create a horizontal bar chart with sample data in the range -3 to +3. * * @return The chart. */ private static JFreeChart createChart() { // create a dataset... XYSeries series1 = new XYSeries("Series 1"); series1.add(1.0, 1.0); series1.add(2.0, 2.0); series1.add(3.0, 3.0); IntervalXYDataset dataset = new XYBarDataset(new XYSeriesCollection( series1), 1.0); // create the chart... return ChartFactory.createXYBarChart( "XY Bar Chart", // chart title "Domain", false, "Range", dataset, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips true // urls ); }
/** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { DefaultXYDataset d1 = new DefaultXYDataset(); double[] x1 = new double[] {1.0, 2.0, 3.0}; double[] y1 = new double[] {4.0, 5.0, 6.0}; double[][] data1 = new double[][] {x1, y1}; d1.addSeries("S1", data1); DefaultXYDataset d2 = new DefaultXYDataset(); double[] x2 = new double[] {1.0, 2.0, 3.0}; double[] y2 = new double[] {4.0, 5.0, 6.0}; double[][] data2 = new double[][] {x2, y2}; d2.addSeries("S1", data2); XYBarDataset bd1 = new XYBarDataset(d1, 5.0); XYBarDataset bd2 = new XYBarDataset(d2, 5.0); assertTrue(bd1.equals(bd2)); assertTrue(bd2.equals(bd1)); }
protected void initComponents() { setLayout(new BorderLayout()); // create chart theDataset = new DefaultXYDataset(); theIsotopesDataset = new DefaultXYDataset(); theChart = org.jfree.chart.ChartFactory.createScatterPlot("PeakList", "m/z ratio", "Intensity", new XYBarDataset(theDataset,0.001), org.jfree.chart.plot.PlotOrientation.VERTICAL, false, false, false); thePlot = (XYPlot)theChart.getPlot(); thePlot.setRenderer(new XYBarRenderer()); thePlot.setDataset(1, theIsotopesDataset); thePlot.setRenderer(1,new StandardXYItemRenderer(StandardXYItemRenderer.LINES)); theChartPanel = new ChartPanel(theChart); theChartPanel.setDomainZoomable(false); theChartPanel.setRangeZoomable(false); theChartPanel.setPopupMenu(null); add(theChartPanel,BorderLayout.CENTER); // create toolbar theToolBar = createToolBar(); add(theToolBar,BorderLayout.SOUTH); }
/** * Creates and initializes the chart panel. */ public ChartPanel createChartPanel() { XYBarDataset barDataset = new XYBarDataset(dataset, BAR_WIDTH); NumberAxis xaxis = new NumberAxis(I18n.get("statistic.queryTimeHistoryPanel.time")); NumberAxis yaxis = new NumberAxis(I18n.get("statistic.queryTimeHistoryPanel.averageQueryTime")); xaxis.setStandardTickUnits(new ChartUtils.LowerBoundedTickUnitSource(xaxis.getStandardTickUnits(), LOWER_TICK_UNIT)); XYPlot plot = new XYPlot(barDataset, xaxis, yaxis, new XYBarRenderer()); JFreeChart chart = new JFreeChart(I18n.get("statistic.queryTimeHistoryPanel.queryHistory"), null, plot, false); ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setBorder(CHART_BORDER); chartPanel.setMinimumDrawHeight(0); chartPanel.setMinimumDrawWidth(0); chartPanel.setMaximumDrawHeight(Integer.MAX_VALUE); chartPanel.setMaximumDrawWidth(Integer.MAX_VALUE); return chartPanel; }
private Component createChartPanel() { XYBarDataset xyBarDataset = new XYBarDataset(xyDataset, BAR_WIDTH); NumberAxis xaxis = new NumberAxis(I18n.get("statistic.histogramChartPanel.time")); NumberAxis yaxis = new NumberAxis(I18n.get("statistic.histogramChartPanel.numberOfQueries")); xaxis.setStandardTickUnits(new ChartUtils.LowerBoundedTickUnitSource(xaxis.getStandardTickUnits(), LOWER_TICK_UNIT)); XYPlot plot = new XYPlot(xyBarDataset, xaxis, yaxis, new XYBarRenderer()); JFreeChart chart = new JFreeChart(I18n.get( "statistic.histogramChartPanel.title"), null, plot, false); ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setBorder(CHART_BORDER); chartPanel.setMinimumDrawHeight(0); chartPanel.setMinimumDrawWidth(0); chartPanel.setMaximumDrawHeight(Integer.MAX_VALUE); chartPanel.setMaximumDrawWidth(Integer.MAX_VALUE); return chartPanel; }
/** * Create a horizontal bar chart with sample data in the range -3 to +3. * * @return The chart. */ private static JFreeChart createChart() { // create a dataset... XYSeries series1 = new XYSeries("Series 1"); series1.add(1.0, 1.0); series1.add(2.0, 2.0); series1.add(3.0, 3.0); IntervalXYDataset dataset = new XYBarDataset(new XYSeriesCollection( series1), 1.0); // create the chart... return ChartFactory.createXYBarChart("XY Bar Chart", "Domain", false, "Range", dataset, true); }
/** * Create a horizontal bar chart with sample data in the range -3 to +3. * * @return The chart. */ private static JFreeChart createChart() { XYSeries series1 = new XYSeries("Series 1"); series1.add(1.0, 1.0); series1.add(2.0, 2.0); series1.add(3.0, 3.0); IntervalXYDataset dataset = new XYBarDataset(new XYSeriesCollection( series1), 1.0); return ChartFactory.createXYBarChart("XY Bar Chart", "Domain", false, "Range", dataset); }
/** * A check for the datasetIndex and seriesIndex fields in the LegendItem * returned by the getLegendItem() method. */ @Test public void testGetLegendItemSeriesIndex() { XYSeriesCollection d1 = new XYSeriesCollection(); XYSeries s1 = new XYSeries("S1"); s1.add(1.0, 1.1); XYSeries s2 = new XYSeries("S2"); s2.add(1.0, 1.1); d1.addSeries(s1); d1.addSeries(s2); XYSeriesCollection d2 = new XYSeriesCollection(); XYSeries s3 = new XYSeries("S3"); s3.add(1.0, 1.1); XYSeries s4 = new XYSeries("S4"); s4.add(1.0, 1.1); XYSeries s5 = new XYSeries("S5"); s5.add(1.0, 1.1); d2.addSeries(s3); d2.addSeries(s4); d2.addSeries(s5); XYBarRenderer r = new XYBarRenderer(); XYPlot plot = new XYPlot(new XYBarDataset(d1, 1.0), new NumberAxis("x"), new NumberAxis("y"), r); plot.setDataset(1, new XYBarDataset(d2, 2.0)); /*JFreeChart chart =*/ new JFreeChart(plot); LegendItem li = r.getLegendItem(1, 2); assertEquals("S5", li.getLabel()); assertEquals(1, li.getDatasetIndex()); assertEquals(2, li.getSeriesIndex()); }
public void processNode(Object name, Map map, Object value) throws Exception { if(value != null && value instanceof XYBarDataset) { this.xyDataset = (XYBarDataset)value; }else { // TODO } }
public static JFreeChart generateTimeSeriesChart(String title, List<HistoryAggregateItem> history, String timespan, Calendar cal) throws ParseException { TimeSeries series = initializeSeries(timespan, cal, history); TimeSeriesCollection dataset = new TimeSeriesCollection(); dataset.addSeries(series); IntervalXYDataset idataset = new XYBarDataset(dataset, 1); JFreeChart chart = org.jfree.chart.ChartFactory.createXYBarChart( title, // Title "Date/time", // X-axis Label true, "Hits", // Y-axis Label idataset, // Dataset PlotOrientation.VERTICAL, true, // Show legend true, // Use tooltips false // Generate URLs ); chart.setBackgroundPaint(Color.WHITE); chart.setBorderPaint(Color.BLACK); XYPlot plot = (XYPlot)chart.getPlot(); plot.setBackgroundPaint(Color.LIGHT_GRAY); plot.getRenderer().setSeriesPaint(0, Color.BLUE); plot.setDomainGridlinePaint(Color.GRAY); plot.setRangeGridlinePaint(Color.GRAY); chart.removeLegend(); return chart; }
private void updateChart() { String x_label = "m/z ratio"; String y_label = (theDocument.isShowRelativeIntensities()) ?"Intensity %" :"Intensity"; theDataset = new DefaultXYDataset(); if( theDocument.getPeakData()!=null ) { theChart = org.jfree.chart.ChartFactory.createScatterPlot(null, x_label, y_label, theDataset, org.jfree.chart.plot.PlotOrientation.VERTICAL, false, false, false); thePlot = (XYPlot)theChart.getPlot(); thePlot.setRenderer(new StandardXYItemRenderer(StandardXYItemRenderer.LINES)); } else { theChart = org.jfree.chart.ChartFactory.createScatterPlot(null, x_label, y_label, new XYBarDataset(theDataset,0.001), org.jfree.chart.plot.PlotOrientation.VERTICAL, false, false, false); thePlot = (XYPlot)theChart.getPlot(); thePlot.setRenderer(new XYBarRenderer()); } if( theDocument.isShowRelativeIntensities() && theOptions.SHOW_MAX_INTENSITY ) { // set second axis ValueAxis second_axis = new NumberAxis(""); thePlot.setRangeAxis(1, second_axis); // set dataset maxIntensityDataset = new DefaultXYDataset(); thePlot.setDataset(1, maxIntensityDataset); thePlot.mapDatasetToRangeAxis(1, 1); // set invisible renderer StandardXYItemRenderer r = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES); r.setBaseShapesVisible(false); thePlot.setRenderer(1,r); } theChart.setBackgroundPaint(Color.white); theChart.setBorderVisible(false); thePlot.getRenderer().setPaint(theOptions.SPECTRUM_COLOR); thePlot.setOutlinePaint(null); thePlot.setDomainGridlinesVisible(false); thePlot.setRangeGridlinesVisible(false); }
/** * A check for the datasetIndex and seriesIndex fields in the LegendItem * returned by the getLegendItem() method. */ public void testGetLegendItemSeriesIndex() { XYSeriesCollection d1 = new XYSeriesCollection(); XYSeries s1 = new XYSeries("S1"); s1.add(1.0, 1.1); XYSeries s2 = new XYSeries("S2"); s2.add(1.0, 1.1); d1.addSeries(s1); d1.addSeries(s2); XYSeriesCollection d2 = new XYSeriesCollection(); XYSeries s3 = new XYSeries("S3"); s3.add(1.0, 1.1); XYSeries s4 = new XYSeries("S4"); s4.add(1.0, 1.1); XYSeries s5 = new XYSeries("S5"); s5.add(1.0, 1.1); d2.addSeries(s3); d2.addSeries(s4); d2.addSeries(s5); XYBarRenderer r = new XYBarRenderer(); XYPlot plot = new XYPlot(new XYBarDataset(d1, 1.0), new NumberAxis("x"), new NumberAxis("y"), r); plot.setDataset(1, new XYBarDataset(d2, 2.0)); /*JFreeChart chart =*/ new JFreeChart(plot); LegendItem li = r.getLegendItem(1, 2); assertEquals("S5", li.getLabel()); assertEquals(1, li.getDatasetIndex()); assertEquals(2, li.getSeriesIndex()); }
/** * Verify that this class implements {@link PublicCloneable}. */ public void testPublicCloneable() { DefaultXYDataset d1 = new DefaultXYDataset(); double[] x1 = new double[] {1.0, 2.0, 3.0}; double[] y1 = new double[] {4.0, 5.0, 6.0}; double[][] data1 = new double[][] {x1, y1}; d1.addSeries("S1", data1); XYBarDataset bd1 = new XYBarDataset(d1, 5.0); assertTrue(bd1 instanceof PublicCloneable); }
/** * Getter for property xyDataset. * @return Value of property xyDataset. */ public XYBarDataset getXyDataset() { return this.xyDataset; }
/** * Setter for property xyDataset. * @param xyDataset New value of property xyDataset. */ public void setXyDataset(XYBarDataset xyDataset) { this.xyDataset = xyDataset; }