List of usage examples for org.jfree.chart.axis NumberAxis setRange
public void setRange(double lower, double upper)
From source file:de.hs.mannheim.modUro.controller.diagram.BoxAndWhiskerPlotController.java
/** * Plots Data for Chart//from w w w . ja v a2 s . c o m */ private void boxWhiskerPlot() { BoxAndWhiskerCategoryDataset dataset = createDataset(); CategoryAxis xAxis = new CategoryAxis("Model"); NumberAxis yAxis = new NumberAxis("Fitness"); yAxis.setRange(0.0, 1.0); BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer(); renderer.setFillBox(false); renderer.setMaximumBarWidth(0.2); renderer.setItemMargin(0.5); renderer.setToolTipGenerator(new BoxAndWhiskerToolTipGenerator()); CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer); plot.setOrientation(PlotOrientation.HORIZONTAL); final JFreeChart chart = new JFreeChart("Model comparison", new Font("Palatino", Font.BOLD, 14), plot, true); chart.removeLegend(); ChartViewer viewer = new ChartViewer(chart, this); boxWhiskerPane.setCenter(viewer); }
From source file:j2se.jfreechart.barchart.BarChartDemo6.java
/** * Creates a new demo.//from w ww . j a v a2 s .c o m * * @param title the frame title. */ public BarChartDemo6(final String title) { super(title); // create a dataset... final DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.addValue(83.0, "First", "Factor 1"); // create the chart... final JFreeChart chart = ChartFactory.createBarChart(null, // chart title "Category", // domain axis label "Score (%)", // range axis label dataset, // data PlotOrientation.HORIZONTAL, false, // include legend true, false); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... chart.setBackgroundPaint(Color.yellow); // not seen final CategoryPlot plot = chart.getCategoryPlot(); // plot.setInsets(new Insets(0, 0, 0, 0)); plot.setRangeGridlinesVisible(false); final CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setLowerMargin(0.20); domainAxis.setUpperMargin(0.20); domainAxis.setVisible(false); final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setRange(0.0, 100.0); rangeAxis.setVisible(false); // OPTIONAL CUSTOMISATION COMPLETED. // add the chart to a panel... final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); setContentPane(chartPanel); }
From source file:com.sonyericsson.jenkins.plugins.bfa.graphs.TimeSeriesUnkownFailuresChart.java
@Override protected JFreeChart createGraph() { TimeTableXYDataset dataset = createDataset(); ValueAxis xAxis = new DateAxis(); xAxis.setLowerMargin(0.0);// w w w . j a v a2s . co m xAxis.setUpperMargin(0.0); Calendar lowerBound = getLowerGraphBound(); xAxis.setRange(lowerBound.getTimeInMillis(), Calendar.getInstance().getTimeInMillis()); NumberAxis yAxis = new NumberAxis(Y_AXIS_LABEL); yAxis.setRange(0, HUNDRED_PERCENT); XYItemRenderer renderer = new XYBarRenderer(); XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); JFreeChart chart = new JFreeChart(graphTitle, JFreeChart.DEFAULT_TITLE_FONT, plot, true); chart.removeLegend(); return chart; }
From source file:j2se.jfreechart.barchart.BarChartDemo2.java
/** * Creates a chart./*from w ww . ja v a 2s .c o m*/ * * @param dataset the dataset. * * @return A chart. */ private JFreeChart createChart(final CategoryDataset dataset) { final JFreeChart chart = ChartFactory.createBarChart("Bar Chart Demo 2", // chart title "Category", // domain axis label "Score (%)", // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, false); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... // set the background color for the chart... chart.setBackgroundPaint(Color.lightGray); // get a reference to the plot for further customisation... final CategoryPlot plot = chart.getCategoryPlot(); plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); // change the auto tick unit selection to integer units only... final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setRange(0.0, 100.0); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }
From source file:org.jfree.chart.demo.BarChartDemo2.java
/** * Creates a chart.//from w w w . j av a 2s . c o m * * @param dataset the dataset. * * @return A chart. */ private JFreeChart createChart(final CategoryDataset dataset) { final JFreeChart chart = ChartFactory.createBarChart("Bar Chart Demo 2", // chart title "Category", // domain axis label "Score (%)", // range axis label dataset, // data PlotOrientation.HORIZONTAL, // orientation true, // include legend true, false); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... // set the background color for the chart... chart.setBackgroundPaint(Color.lightGray); // get a reference to the plot for further customisation... final CategoryPlot plot = chart.getCategoryPlot(); plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); // change the auto tick unit selection to integer units only... final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setRange(0.0, 100.0); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }
From source file:physical_network.OscilloscopePanel.java
public OscilloscopePanel() { super("Oscilloscope"); // Set initial (time, voltage) datapoint of (0.0, 0.0). voltages.add(0.0, 0.0);// ww w.j a v a2s . c o m XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(voltages); JFreeChart chart = ChartFactory.createXYLineChart("Oscilloscope", "Time (seconds)", "Voltage", dataset, PlotOrientation.VERTICAL, true, false, false); XYPlot plot = (XYPlot) chart.getPlot(); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesLinesVisible(0, true); NumberAxis domain = (NumberAxis) plot.getDomainAxis(); domain.setRange(0.0, 10.0); domain.setTickUnit(new NumberTickUnit(1.0)); domain.setVerticalTickLabels(true); NumberAxis range = (NumberAxis) plot.getRangeAxis(); range.setRange(-5.0, 5.0); range.setTickUnit(new NumberTickUnit(1.0)); plot.setRenderer(renderer); ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 300)); setContentPane(chartPanel); }
From source file:it.eng.spagobi.engines.chart.bo.charttypes.scattercharts.SimpleScatter.java
public JFreeChart createChart(DatasetMap datasets) { DefaultXYDataset dataset = (DefaultXYDataset) datasets.getDatasets().get("1"); JFreeChart chart = ChartFactory.createScatterPlot(name, yLabel, xLabel, dataset, PlotOrientation.HORIZONTAL, false, true, false);/*w w w . ja va 2 s .c o m*/ Font font = new Font("Tahoma", Font.BOLD, titleDimension); //TextTitle title = new TextTitle(name, font); TextTitle title = setStyleTitle(name, styleTitle); chart.setTitle(title); chart.setBackgroundPaint(Color.white); if (subName != null && !subName.equals("")) { TextTitle subTitle = setStyleTitle(subName, styleSubTitle); chart.addSubtitle(subTitle); } XYPlot plot = (XYPlot) chart.getPlot(); plot.setForegroundAlpha(0.65f); XYItemRenderer renderer = plot.getRenderer(); int seriesN = dataset.getSeriesCount(); if (colorMap != null) { for (int i = 0; i < seriesN; i++) { String serieName = (String) dataset.getSeriesKey(i); Color color = (Color) colorMap.get(serieName); if (color != null) { renderer.setSeriesPaint(i, color); } } } // increase the margins to account for the fact that the auto-range // doesn't take into account the bubble size... NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setAutoRange(true); domainAxis.setRange(yMin, yMax); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setAutoRange(true); rangeAxis.setRange(xMin, xMax); if (legend == true) { drawLegend(chart); } return chart; }
From source file:playground.yu.utils.charts.XYScatterLineChart.java
private JFreeChart createChart(final String title, final String categoryAxisLabel, final String valueAxisLabel, final XYSeriesCollection dataset) { // return ChartFactory.createScatterPlot(title, categoryAxisLabel, // valueAxisLabel, dataset, PlotOrientation.VERTICAL, true, // legend? // false, // tooltips? // false // URLs? // );// w w w.j a va 2s. c o m NumberAxis xAxis = new NumberAxis(categoryAxisLabel); xAxis.setAutoRangeIncludesZero(false); xAxis.setRange(0, 24); NumberAxis yAxis = new NumberAxis(valueAxisLabel); yAxis.setAutoRangeIncludesZero(true); yAxis.setRange(0, 100); XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null); XYItemRenderer renderer = new XYLineAndShapeRenderer(true, true); renderer.setBaseToolTipGenerator(null/* XYToolTipGenerator */); renderer.setURLGenerator(null/* urlGenerator */); plot.setRenderer(renderer); plot.setOrientation(PlotOrientation.VERTICAL); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, true/* legend */); return chart; }
From source file:de.hs.mannheim.modUro.reader.BoxAndWhiskersPlotDiagram.java
/** * Plots Data for Chart/*from w ww. j a v a 2 s . c om*/ */ private void boxWhiskerPlot() { BoxAndWhiskerCategoryDataset dataset = createDataset(); CategoryAxis xAxis = new CategoryAxis("Model"); NumberAxis yAxis = new NumberAxis("Fitness"); yAxis.setRange(0.0, 1.0); BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer(); renderer.setFillBox(false); renderer.setMaximumBarWidth(0.2); renderer.setItemMargin(0.5); renderer.setToolTipGenerator(new BoxAndWhiskerToolTipGenerator()); CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer); plot.setOrientation(PlotOrientation.HORIZONTAL); chart = new JFreeChart("Model comparison", new Font("Palatino", Font.BOLD, 14), plot, true); chart.removeLegend(); // boxWhiskerPane.setCenter(viewer); }
From source file:j2se.jfreechart.barchart.BarChartDemo5.java
/** * Creates a chart./*from w ww.j a va2 s . c o m*/ * * @param dataset the dataset. * * @return A chart. */ private JFreeChart createChart(final CategoryDataset dataset) { // create the chart... final JFreeChart chart = ChartFactory.createBarChart("Bar Chart", // chart title "Category", // domain axis label "Score (%)", // range axis label dataset, // data PlotOrientation.HORIZONTAL, // orientation true, // include legend true, false); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... chart.setBackgroundPaint(Color.lightGray); // get a reference to the plot for further customisation... final CategoryPlot plot = chart.getCategoryPlot(); plot.getRenderer().setSeriesPaint(0, new Color(0, 0, 255)); plot.getRenderer().setSeriesPaint(1, new Color(75, 75, 255)); plot.getRenderer().setSeriesPaint(2, new Color(150, 150, 255)); // change the auto tick unit selection to integer units only... final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setRange(0.0, 100.0); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // NumberAxis hna = rangeAxis; // MarkerAxisBand band = new MarkerAxisBand(hna, 2.0, 2.0, 2.0, 2.0, // new Font("SansSerif", Font.PLAIN, 9)); // IntervalMarker m1 = new IntervalMarker(0.0, 33.0, "Low", Color.gray, // new BasicStroke(0.5f), Color.green, 0.75f); // IntervalMarker m2 = new IntervalMarker(33.0, 66.0, "Medium", Color.gray, // new BasicStroke(0.5f), Color.orange, 0.75f); // IntervalMarker m3 = new IntervalMarker(66.0, 100.0, "High", Color.gray, // new BasicStroke(0.5f), Color.red, 0.75f); // band.addMarker(m1); // band.addMarker(m2); // band.addMarker(m3); // hna.setMarkerBand(band); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }