List of usage examples for org.jfree.chart ChartFactory createXYLineChart
public static JFreeChart createXYLineChart(String title, String xAxisLabel, String yAxisLabel, XYDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls)
From source file:org.azrul.langmera.LineChart.java
/** * Creates a chart.//from ww w. j a va2s.c o m * * @param dataset the data for the chart. * * @return a chart. */ private JFreeChart createChart(final XYDataset dataset) { // create the chart... final JFreeChart chart = ChartFactory.createXYLineChart(this.getTitle(), // chart title "Number of messages", // x axis label "Value of actions", // y axis label dataset, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... chart.setBackgroundPaint(Color.white); // final StandardLegend legend = (StandardLegend) chart.getLegend(); // legend.setDisplaySeriesShapes(true); // get a reference to the plot for further customisation... final XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.lightGray); // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0)); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); for (int i = 0; i < dataset.getSeriesCount(); i++) { renderer.setSeriesStroke(i, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 10.0f, 6.0f }, 0.0f)); } return chart; }
From source file:ejemplo.Ejemplo.java
private JFreeChart createChart(final XYDataset dataset) { // create the chart... final JFreeChart chart = ChartFactory.createXYLineChart("Line Chart Demo 6", // chart title "X", // x axis label "Y", // y axis label dataset, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls );//from ww w . j a v a2 s . c o m // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... chart.setBackgroundPaint(Color.white); // final StandardLegend legend = (StandardLegend) chart.getLegend(); // legend.setDisplaySeriesShapes(true); // get a reference to the plot for further customisation... final XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.lightGray); // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0)); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesLinesVisible(0, false); renderer.setSeriesShapesVisible(1, false); plot.setRenderer(renderer); // change the auto tick unit selection to integer units only... final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }
From source file:org.esa.s1tbx.insar.rcp.toolviews.insar_statistics.StatESDMeasure.java
public Component createPanel() { // Add the series to your data set dataset = new XYSeriesCollection(); // Generate the graph chart = ChartFactory.createXYLineChart(TITLE, // Title XAXIS_LABEL, // x-axis Label YAXIS_LABEL, // y-axis Label dataset, // Dataset PlotOrientation.VERTICAL, // Plot Orientation true, // Show Legend true, // Use tooltips false // Configure chart to generate URLs? );/* w w w. j ava 2s . c o m*/ chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 470)); chartPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); panel = new JPanel(new BorderLayout()); textarea = new JTextArea(EmptyMsg); panel.add(textarea, BorderLayout.NORTH); panel.add(chartPanel, BorderLayout.CENTER); setVisible(false); return panel; }
From source file:com.joey.software.plottingToolkit.PlotingToolkit.java
public static JFreeChart getPlot(double[] xData, double[] yData, String title, String xlabel, String ylabel) { XYSeriesCollection datCol = getCollection(xData, yData, "Data"); // Create the chart JFreeChart chart = ChartFactory.createXYLineChart(title, // Title xlabel, // X-Axis label ylabel, // Y-Axis label new XYSeriesCollection(), // Dataset PlotOrientation.VERTICAL, true, // Show legend true, true);/*ww w . j a v a 2s . c om*/ // Add the series chart.getXYPlot().setDataset(0, datCol); // Set the rendering XYLineAndShapeRenderer rend1 = new XYLineAndShapeRenderer(true, true); rend1.setShapesVisible(false); chart.getXYPlot().setRenderer(0, rend1); return chart; }
From source file:gov.nih.nci.caintegrator.ui.graphing.chart.plot.KaplanMeierPlot.java
private void createChart(XYDataset dataset) { //Create the chart, dropping in the data set JFreeChart chart = ChartFactory.createXYLineChart("", "Days in Study", "Probability of Survival", dataset, PlotOrientation.VERTICAL, false, //legend true, //tooltips false//urls );/*from w w w . j av a 2 s . c o m*/ LegendTitle legend = chart.getLegend(); XYPlot plot = (XYPlot) chart.getPlot(); /******************************************************** * IMPORTANT: * Ideally I would create the actual Renderer settings for * the at the time I start to march through the * KaplanMeierPlotPointSeriesSets, adding them to the actual * Data Set that is going to be going into the Chart plotter. * But you have no idea how they are going to be sitting in * the Plot dataset so there is no guarantee that setting the * renderer based on a supposed index will actually work. In fact * it didn't work when I wrote this. * */ XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); for (int i = 0; i < finalDataCollection.getSeriesCount(); i++) { KaplanMeierPlotPointSeries kmSeries = (KaplanMeierPlotPointSeries) finalDataCollection.getSeries(i); if (kmSeries.getType() == SeriesType.CENSOR) { renderer.setSeriesLinesVisible(i, false); renderer.setSeriesShapesVisible(i, true); } else if (kmSeries.getType() == SeriesType.PROBABILITY) { renderer.setSeriesLinesVisible(i, true); renderer.setSeriesShapesVisible(i, false); } else { //don't show this set as it is not a known type renderer.setSeriesLinesVisible(i, false); renderer.setSeriesShapesVisible(i, false); } renderer.setSeriesPaint(i, getKMSetColor(kmSeries.getKey(), kmSeries.getType()), true); } renderer.setToolTipGenerator(new StandardXYToolTipGenerator()); renderer.setDefaultEntityRadius(6); plot.setRenderer(renderer); //change the auto tick unit selection to integer units only... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits()); // OPTIONAL CUSTOMISATION COMPLETED. rangeAxis.setAutoRange(true); rangeAxis.setRange(0.0, 1.0); kmChart = chart; }
From source file:gda.util.SavePNGPlot.java
/** * //w ww.j a v a 2s . c o m * @param imageFile * @param scan * @param width * @param height * @param chartTitle * @throws IOException */ public static void save(String imageFile, ScanFileHolder scan, int width, int height, String chartTitle) throws IOException { final XYSeriesCollection dataset = new XYSeriesCollection(); XYSeries series; IDataset x_axis = scan.getAxis(0); String[] headings = scan.getHeadings(); String yAxisName; if (headings.length == 2) yAxisName = headings[1]; else yAxisName = "various"; for (int seriesNum = 1; seriesNum < headings.length; seriesNum++) { series = new XYSeries(""); for (int point = 0, max = x_axis.getSize(); point < max - 1; point++) series.add(x_axis.getDouble(point), scan.getAxis(seriesNum).getDouble(point)); series.setKey(headings[seriesNum]); dataset.addSeries(series); } final JFreeChart chart = ChartFactory.createXYLineChart(chartTitle, // chart // title headings[0], // x axis label yAxisName, // y axis label dataset, // data PlotOrientation.VERTICAL, true, // include legend false, // tool tips false // url's ); ChartUtilities.saveChartAsPNG(new File(imageFile), chart, width, height); }
From source file:org.jboss.modcluster.demo.client.ChartManager.java
public ChartManager(Map<String, AtomicInteger> requestCounts, Map<String, AtomicInteger> sessionCounts) { this.requestCounts = requestCounts; this.sessionCounts = sessionCounts; requestBalancingChart = ChartFactory.createXYLineChart("Request Balancing", "Sample", "Requests / Second", requestSeriesCollection, PlotOrientation.VERTICAL, true, true, false); sessionBalancingChart = ChartFactory.createXYLineChart("Session Balancing", "Sample", "Session Count", sessionSeriesCollection, PlotOrientation.VERTICAL, true, true, false); // for (int i = 1; i < 9; i++) // {//www . j av a2 s .c o m // String key = "cluster0" + i; // createRequestSeries(key); // createSessionSeries(key); // } }
From source file:eu.choreos.vv.chart.XYChart.java
private static JFreeChart createChart(XYDataset dataset, String chartTitle, String xLabel, String yLabel) { // create the chart... JFreeChart chart = ChartFactory.createXYLineChart(chartTitle, // chart title xLabel, // domain axis label yLabel, // range axis label dataset, // initial series PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips? false // URLs? );/* ww w . j ava2 s . c o m*/ // set chart background chart.setBackgroundPaint(Color.white); // set a few custom plot features XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(new Color(0xffffe0)); plot.setDomainGridlinesVisible(true); plot.setDomainGridlinePaint(Color.lightGray); plot.setRangeGridlinePaint(Color.lightGray); // set the plot's axes to display integers TickUnitSource ticks = NumberAxis.createIntegerTickUnits(); NumberAxis domain = (NumberAxis) plot.getDomainAxis(); domain.setStandardTickUnits(ticks); domain.resizeRange(1.1); domain.setLowerBound(0.5); NumberAxis range = (NumberAxis) plot.getRangeAxis(); range.setStandardTickUnits(ticks); range.setUpperBound(range.getUpperBound() * 1.1); // render shapes and lines XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, true); plot.setRenderer(renderer); renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); // set the renderer's stroke Stroke stroke = new BasicStroke(3f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL); renderer.setBaseOutlineStroke(stroke); // label the points NumberFormat format = NumberFormat.getNumberInstance(); format.setMaximumFractionDigits(2); XYItemLabelGenerator generator = new StandardXYItemLabelGenerator( StandardXYItemLabelGenerator.DEFAULT_ITEM_LABEL_FORMAT, format, format); renderer.setBaseItemLabelGenerator(generator); renderer.setBaseItemLabelsVisible(true); return chart; }
From source file:org.jfree.chart.demo.XYLineAndShapeRendererDemo.java
/** * Constructs the demo application./*from w w w. jav a 2 s .c om*/ * * @param title the frame title. */ public XYLineAndShapeRendererDemo(final String title) { super(title); XYDataset dataset = createSampleDataset(); JFreeChart chart = ChartFactory.createXYLineChart(title, "X", "Y", dataset, PlotOrientation.VERTICAL, true, false, false); XYPlot plot = (XYPlot) chart.getPlot(); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesLinesVisible(0, true); renderer.setSeriesShapesVisible(0, false); renderer.setSeriesLinesVisible(1, false); renderer.setSeriesShapesVisible(1, true); plot.setRenderer(renderer); final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 300)); setContentPane(chartPanel); }
From source file:com.compomics.pepshell.view.statistics.CleavingProbabilityPane.java
@Override public void setGraphData(PepshellProtein aPepshellProtein) { //obligatory checks if (aPepshellProtein != null && experiment.getProteins().contains(aPepshellProtein)) { if (aPepshellProtein != currentPepshellProtein) { //TODO: run this outside of the gui thread currentPepshellProtein = experiment.getProteins() .get(experiment.getProteins().indexOf(aPepshellProtein)); XYSeriesCollection xYSeriesCollection = new XYSeriesCollection(); fillSeries(currentPepshellProtein).forEach(xYSeriesCollection::addSeries); JFreeChart CPDTchart = ChartFactory.createXYLineChart("probability of cleaving", "aminoacids of " + currentPepshellProtein.getVisibleAccession(), "probability", xYSeriesCollection, PlotOrientation.VERTICAL, false, true, false); prettifyChart(CPDTchart);//from w w w. j ava 2s .c om CPDTchart.getXYPlot().getRangeAxis().setLowerBound(cutoff - 0.05); for (int i = 0; i < CPDTchart.getXYPlot().getSeriesCount(); i++) { CPDTchart.getXYPlot().getRenderer().setSeriesStroke(i, new BasicStroke(5)); } if (!aPepshellProtein.getDomains().isEmpty()) { CPDTchart.setBackgroundImageAlpha(0.18f); CPDTchart.getXYPlot().getDomainAxis().setRange(0, aPepshellProtein.getProteinSequence().length()); BufferedImage anImage = new BufferedImage(this.getHeight(), this.getWidth(), BufferedImage.TYPE_INT_ARGB); for (FeatureWithLocation aDomain : aPepshellProtein.getDomains()) { anImage.getGraphics().drawRect(aDomain.getStartPosition(), 0, aDomain.getEndPosition(), this.getHeight()); } CPDTchart.setBackgroundImage(anImage); } chart.setChart(CPDTchart); } } else { chart.setChart(null); this.getGraphics().drawString("missing data", 0, 0); } }