List of usage examples for org.jfree.chart.plot XYPlot setAxisOffset
public void setAxisOffset(RectangleInsets offset)
From source file:pfg.graphic.Chart.java
/** * L'initialisation se fait part afin de ne pas ouvrir une fentre ds qu'on cre un objet */// ww w . j ava2 s . c o m private void init() { init = true; JFreeChart chart = ChartFactory.createTimeSeriesChart(title, // title xAxisLabel, // x-axis label yAxisLabel, // y-axis label dataset, // data true, // create legend? true, // generate tooltips? false // generate URLs? ); chart.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); XYItemRenderer r = plot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); renderer.setDrawSeriesLineAsPath(true); } ChartPanel panel = new ChartPanel(chart); panel.setFillZoomRectangle(true); panel.setMouseWheelEnabled(true); panel.setPreferredSize(new java.awt.Dimension(1024, 600)); setContentPane(panel); pack(); RefineryUtilities.centerFrameOnScreen(this); setVisible(true); }
From source file:org.jfree.chart.demo.MemoryUsageDemo.java
public MemoryUsageDemo(int i) { super(new BorderLayout()); total = new TimeSeries("Total Memory"); total.setMaximumItemAge(i);// w w w . j a v a 2s . c om free = new TimeSeries("Free Memory"); free.setMaximumItemAge(i); TimeSeriesCollection timeseriescollection = new TimeSeriesCollection(); timeseriescollection.addSeries(total); timeseriescollection.addSeries(free); DateAxis dateaxis = new DateAxis("Time"); NumberAxis numberaxis = new NumberAxis("Memory"); dateaxis.setTickLabelFont(new Font("SansSerif", 0, 12)); numberaxis.setTickLabelFont(new Font("SansSerif", 0, 12)); dateaxis.setLabelFont(new Font("SansSerif", 0, 14)); numberaxis.setLabelFont(new Font("SansSerif", 0, 14)); XYLineAndShapeRenderer xylineandshaperenderer = new XYLineAndShapeRenderer(true, false); xylineandshaperenderer.setSeriesPaint(0, Color.red); xylineandshaperenderer.setSeriesPaint(1, Color.green); xylineandshaperenderer.setSeriesStroke(0, new BasicStroke(3F, 0, 2)); xylineandshaperenderer.setSeriesStroke(1, new BasicStroke(3F, 0, 2)); XYPlot xyplot = new XYPlot(timeseriescollection, dateaxis, numberaxis, xylineandshaperenderer); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setDomainGridlinePaint(Color.white); xyplot.setRangeGridlinePaint(Color.white); xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D)); dateaxis.setAutoRange(true); dateaxis.setLowerMargin(0.0D); dateaxis.setUpperMargin(0.0D); dateaxis.setTickLabelsVisible(true); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); JFreeChart jfreechart = new JFreeChart("JVM Memory Usage", new Font("SansSerif", 1, 24), xyplot, true); jfreechart.setBackgroundPaint(Color.white); ChartPanel chartpanel = new ChartPanel(jfreechart, true); chartpanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4), BorderFactory.createLineBorder(Color.black))); add(chartpanel); }
From source file:diplomawork.model.ViewForDiagram.java
/** * Creates a chart.// www. j a va 2 s . co m * * @param dataset a dataset. * * @return A chart. */ private JFreeChart createChart(XYDataset dataset) { JFreeChart chart = ChartFactory.createTimeSeriesChart("EUR/USD", // title "Date", // x-axis label "Price Per Unit", // y-axis label dataset, // data true, // create legend? true, // generate tooltips? false // generate URLs? ); chart.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); plot.setOutlinePaint(null); XYItemRenderer r = plot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); renderer.setDrawSeriesLineAsPath(true); renderer.setSeriesPaint(0, Color.BLUE); } DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("dd HH:mm:ss")); return chart; }
From source file:edu.ucla.stat.SOCR.chart.demo.QQData2DataDemo.java
/** * Creates a chart.//from www .j a v a2 s .c o m * * @param dataset the data for the chart. * * @return a chart. */ protected JFreeChart createChart(XYDataset dataset) { // create the chart... JFreeChart chart = ChartFactory.createXYLineChart(chartTitle, //"Data vs Data Q-Q plot", // chart title domainLabel, // x axis label rangeLabel, // y axis label dataset, // data PlotOrientation.VERTICAL, !legendPanelOn, // include legend true, // tooltips false // urls ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... chart.setBackgroundPaint(Color.white); // get a reference to the plot for further customisation... XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainGridlinePaint(Color.lightGray); plot.setRangeGridlinePaint(Color.lightGray); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); // renderer.setShapesVisible(true); renderer.setBaseShapesFilled(true); // renderer.setLinesVisible(false); renderer.setSeriesLinesVisible(1, true); renderer.setSeriesShapesVisible(1, false); renderer.setSeriesLinesVisible(0, false); renderer.setSeriesShapesVisible(0, true); //renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator()); // change the auto tick unit selection to integer units only... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setAutoRangeIncludesZero(false); rangeAxis.setUpperMargin(0.02); rangeAxis.setLowerMargin(0.02); // rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setAutoRangeIncludesZero(false); domainAxis.setUpperMargin(0.02); domainAxis.setLowerMargin(0.02); // domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // OPTIONAL CUSTOMISATION COMPLETED. setQQSummary(dataset); return chart; }
From source file:de.uniol.ui.tsv.ui.StepChartDialog.java
protected JFreeChart createChart() { JFreeChart chart = ChartFactory.createXYStepChartFast(title, xTitle, yTitle, xy, PlotOrientation.VERTICAL, true, false, false);// ww w .j ava2 s . c o m chart.setBackgroundPaint(Color.white); chart.getLegend().setBackgroundPaint(new Color(224, 224, 224)); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(new Color(224, 224, 224)); plot.setDomainGridlinePaint(Color.lightGray); plot.setRangeGridlinePaint(Color.lightGray); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setRenderer(new XYStepRendererFast(null, null)); XYItemRenderer xyr = plot.getRenderer(); // xyr.setBaseToolTipGenerator(new XYToolTipGenerator() { // public String generateToolTip(XYDataset dataset, int series, // int item) { // return nf.format(dataset.getXValue(series, item)) // + tooltipRangeUnits + ", " // + nf2.format(dataset.getYValue(series, item)) // + tooltipValueUnits; // } // }); for (int i : seriesStrokes.keySet()) { xyr.setSeriesStroke(i, seriesStrokes.get(i)); } for (int i : seriesColors.keySet()) { xyr.setSeriesPaint(i, seriesColors.get(i)); } DateAxis da = new DateAxis(xTitle); if (useRelativeHourFormat) { da.setDateFormatOverride(new RelativeHourFormat()); } da.setLowerMargin(0.03); plot.setDomainAxis(da); ValueAxis yaxis = plot.getRangeAxis(); yaxis.setRange(new Range(minRange, maxRange)); return chart; }
From source file:edu.psu.citeseerx.misc.charts.CiteChartBuilderJFree.java
protected JFreeChart buildChart(Document doc) throws SQLException { Long clusterid = doc.getClusterID(); if (clusterid == null) { return null; }//from w w w .ja v a2s. c o m java.util.List<ThinDoc> citingDocs = citedao.getCitingDocuments(clusterid, 0, MAX_CITING); XYDataset dataset = collectData(citingDocs); if (dataset.getItemCount(0) <= 1) { return null; } XYBarDataset ivl_dataset = new XYBarDataset(dataset, 15.0); JFreeChart chart = ChartFactory.createXYBarChart(null, "Year", true, "Citation Count", ivl_dataset, PlotOrientation.VERTICAL, false, false, false); chart.setBackgroundPaint(Color.WHITE); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.WHITE); plot.setRangeGridlinePaint(Color.WHITE); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); XYItemRenderer r = plot.getRenderer(); NumberAxis axis = (NumberAxis) plot.getDomainAxis(); axis.setNumberFormatOverride(NumberFormat.getIntegerInstance()); //axis.setTickUnit(new DateTickUnit(DateTickUnit.YEAR, -1)); //axis.setDateFormatOverride(new SimpleDateFormat("yyyy")); return chart; }
From source file:aka.pirana.jdoc.JChart.java
private JPanel createChartPanel() { NumberAxis numberaxis = new NumberAxis("Date"); numberaxis.setAutoRangeIncludesZero(false); NumberAxis numberaxis1 = new NumberAxis("%"); numberaxis1.setAutoRangeIncludesZero(false); XYSplineRenderer xysplinerenderer = new XYSplineRenderer(); XYPlot xyplot = new XYPlot(SampleGenerator(), numberaxis, numberaxis1, xysplinerenderer); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setDomainGridlinePaint(Color.white); xyplot.setRangeGridlinePaint(Color.white); xyplot.setAxisOffset(new RectangleInsets(4D, 4D, 4D, 4D)); JFreeChart jfreechart = new JFreeChart("JDocSplineRenderer", JFreeChart.DEFAULT_TITLE_FONT, xyplot, true); ChartUtilities.applyCurrentTheme(jfreechart); ChartPanel chartpanel = new ChartPanel(jfreechart); return chartpanel; }
From source file:edu.ucla.stat.SOCR.chart.demo.IndexChart.java
/** * Creates a chart.//from w w w. j a v a 2 s . c om * * @param dataset the data for the chart. * * @return a chart. */ protected JFreeChart createChart(XYDataset dataset) { // create the chart... JFreeChart chart = ChartFactory.createXYLineChart(chartTitle, // chart title domainLabel, // x axis label rangeLabel, // y axis label dataset, // data PlotOrientation.VERTICAL, !legendPanelOn, // include legend true, // tooltips false // urls ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... chart.setBackgroundPaint(Color.white); // get a reference to the plot for further customisation... XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainGridlinePaint(Color.lightGray); plot.setRangeGridlinePaint(Color.lightGray); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); // renderer.setSeriesShape(0, java.awt.Shape.round); renderer.setBaseShapesVisible(false); renderer.setBaseShapesFilled(false); renderer.setBaseLinesVisible(true); renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator()); //change the auto tick unit selection to integer units only... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setAutoRangeIncludesZero(false); rangeAxis.setUpperMargin(0.05); rangeAxis.setLowerMargin(0.05); NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); domainAxis.setAutoRangeIncludesZero(false); // domainAxis.setTickLabelsVisible(false); // domainAxis.setTickMarksVisible(false); domainAxis.setUpperMargin(0.05); domainAxis.setLowerMargin(0.05); // OPTIONAL CUSTOMISATION COMPLETED. setYSummary(dataset); return chart; }
From source file:gui.Plotter1D.java
private ChartPanel createChartPanel1(String grapheName) { XYSplineRenderer xysplinerenderer = new XYSplineRenderer(); ValueAxis valueAxis = new NumberAxis("X"); valueAxis.setRange(0.0, 1.0);/*from ww w. ja va 2 s. c o m*/ ValueAxis valueAxisy = new NumberAxis("Y"); valueAxis.setRange(0.0, 1.0); XYPlot xyplot; xyplot = new XYPlot(xyseriescollection, valueAxis, valueAxisy, xysplinerenderer); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setDomainGridlinePaint(Color.white); xyplot.setRangeGridlinePaint(Color.white); xyplot.setAxisOffset(new RectangleInsets(4D, 4D, 4D, 4D)); JFreeChart jfreechart = new JFreeChart(grapheName, JFreeChart.DEFAULT_TITLE_FONT, xyplot, true); jfreechart.setBackgroundPaint(Color.white); ChartPanel chartpanel = new ChartPanel(jfreechart, false); return chartpanel; }
From source file:compecon.dashboard.panel.AbstractChartsPanel.java
protected void configureChart(JFreeChart chart) { chart.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); DateAxis dateAxis = (DateAxis) plot.getDomainAxis(); NumberAxis valueAxis = (NumberAxis) plot.getRangeAxis(); dateAxis.setDateFormatOverride(new SimpleDateFormat("dd-MMM")); valueAxis.setAutoRangeIncludesZero(true); valueAxis.setUpperMargin(0.15);/* www . ja v a 2 s .c o m*/ valueAxis.setLowerMargin(0.15); }