List of usage examples for org.jfree.chart.plot XYPlot setDomainPannable
public void setDomainPannable(boolean pannable)
From source file:com.intel.stl.ui.common.view.ComponentFactory.java
public static JFreeChart createXYAreaChart(String xAxisLabel, String yAxisLabel, XYDataset dataset, boolean includeLegend) { JFreeChart jfreechart = ChartFactory.createXYAreaChart(null, xAxisLabel, yAxisLabel, dataset, PlotOrientation.VERTICAL, false, true, false); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.setDomainPannable(true); xyplot.setBackgroundPaint(null);//from w w w . j a va 2 s .c o m xyplot.setOutlinePaint(null); xyplot.setForegroundAlpha(0.8F); xyplot.setRangeGridlinePaint(UIConstants.INTEL_DARK_GRAY); DateAxis dateaxis = new DateAxis(xAxisLabel); dateaxis.setLowerMargin(0.0D); dateaxis.setUpperMargin(0.0D); xyplot.setDomainAxis(dateaxis); NumberAxis rangeAxis = (NumberAxis) xyplot.getRangeAxis(); rangeAxis.setRangeType(RangeType.POSITIVE); rangeAxis.setLabelFont(UIConstants.H5_FONT); rangeAxis.setLabelInsets(new RectangleInsets(0, 0, 0, 0)); if (includeLegend) { LegendTitle legendtitle = new LegendTitle(xyplot); legendtitle.setItemFont(UIConstants.H5_FONT); legendtitle.setBackgroundPaint(UIConstants.INTEL_WHITE); legendtitle.setFrame(new BlockBorder(UIConstants.INTEL_BLUE)); legendtitle.setPosition(RectangleEdge.BOTTOM); XYTitleAnnotation xytitleannotation = new XYTitleAnnotation(0.97999999999999998D, 0.99999999999999998D, legendtitle, RectangleAnchor.TOP_RIGHT); // xytitleannotation.setMaxWidth(0.47999999999999998D); xyplot.addAnnotation(xytitleannotation); } XYItemRenderer xyitemrenderer = xyplot.getRenderer(); xyitemrenderer.setSeriesPaint(1, UIConstants.INTEL_DARK_GRAY); xyitemrenderer.setSeriesPaint(0, NodeTypeViz.SWITCH.getColor()); xyitemrenderer.setBaseToolTipGenerator( new StandardXYToolTipGenerator("<html><b>{0}</b><br> Time: {1}<br> Data: {2}</html>", Util.getHHMMSS(), new DecimalFormat("#,##0.00"))); return jfreechart; }
From source file:net.nosleep.superanalyzer.analysis.views.LikesView.java
private void createChart() { _chart = ChartFactory.createScatterPlot(Misc.getString("LIKES_VS_PLAYS"), Misc.getString("ALBUM_PLAY_COUNT"), Misc.getString("ALBUM_RATING"), _dataset, PlotOrientation.VERTICAL, false, true, false); _chart.addSubtitle(HomePanel.createSubtitle(Misc.getString("LIKES_VS_PLAYS_SUBTITLE"))); XYPlot plot = (XYPlot) _chart.getPlot(); ChartUtilities.applyCurrentTheme(_chart); plot.setDomainPannable(true); plot.setRangePannable(true);//from ww w.j av a 2s . c om plot.setDomainZeroBaselineVisible(true); plot.setRangeZeroBaselineVisible(true); plot.setDomainGridlinesVisible(false); plot.setRangeGridlinesVisible(false); // get rid of the little line above/next to the axis plot.setDomainZeroBaselinePaint(Color.white); plot.setRangeZeroBaselinePaint(Color.white); /* * NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); * domainAxis.setAutoRangeIncludesZero(false); * * domainAxis.setTickMarkInsideLength(2.0f); * domainAxis.setTickMarkOutsideLength(2.0f); * * domainAxis.setMinorTickCount(2); * domainAxis.setMinorTickMarksVisible(true); */ NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); /* * rangeAxis.setTickMarkInsideLength(2.0f); * rangeAxis.setTickMarkOutsideLength(2.0f); * rangeAxis.setMinorTickCount(2); * rangeAxis.setMinorTickMarksVisible(true); */ rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // format the line renderer after applying the theme XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); renderer.setBaseShapesVisible(true); renderer.setDrawOutlines(true); renderer.setUseFillPaint(true); renderer.setBaseFillPaint(Color.white); renderer.setSeriesStroke(0, new BasicStroke(3.0f)); renderer.setSeriesOutlineStroke(0, new BasicStroke(2.0f)); renderer.setSeriesShape(0, new Ellipse2D.Double(-4.0, -4.0, 8.0, 8.0)); Misc.formatChart(plot); renderer.setSeriesPaint(0, Theme.getColorSet()[1]); }
From source file:org.encog.workbench.tabs.rbf.RadialBasisFunctionsTab.java
public JFreeChart createChart(XYDataset dataset) { JFreeChart chart = ChartFactory.createXYLineChart(null, "input (x)", "output (y)", dataset, PlotOrientation.VERTICAL, true, true, false); XYPlot plot = (XYPlot) chart.getPlot(); plot.setDomainZeroBaselineVisible(true); plot.setRangeZeroBaselineVisible(true); plot.setDomainPannable(true); plot.setRangePannable(true);//from w ww . java 2 s .c om ValueAxis xAxis = plot.getDomainAxis(); xAxis.setLowerMargin(0.0); xAxis.setUpperMargin(0.0); XYLineAndShapeRenderer r = (XYLineAndShapeRenderer) plot.getRenderer(); r.setDrawSeriesLineAsPath(true); r.setSeriesStroke(0, new BasicStroke(1.5f)); r.setSeriesStroke(1, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 6.0f, 4.0f }, 0.0f)); r.setSeriesStroke(2, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 6.0f, 4.0f, 3.0f, 3.0f }, 0.0f)); r.setSeriesStroke(3, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 4.0f, 4.0f }, 0.0f)); return chart; }
From source file:org.gumtree.vis.awt.PlotFactory.java
public static JFreeChart createXYErrorChart(IXYErrorDataset dataset) { JFreeChart chart;// ww w . j a va 2s . co m String title = null; String xTitle = null; String yTitle = null; if (dataset != null) { title = ""; if (dataset.getTitle() != null) { title = dataset.getTitle(); } xTitle = ""; if (dataset.getXTitle() != null) { xTitle += dataset.getXTitle(); } if (dataset.getXUnits() != null) { xTitle += " (" + dataset.getXUnits() + ")"; } yTitle = ""; if (dataset.getYTitle() != null) { yTitle += dataset.getYTitle(); } if (dataset.getYUnits() != null) { yTitle += " (" + dataset.getYUnits() + ")"; } } else { dataset = new XYErrorDataset(); } chart = createXYLineChart(title, xTitle, yTitle, dataset, PlotOrientation.VERTICAL, true, false, true); chart.setBackgroundPaint(Color.WHITE); final LegendTitle legend = (LegendTitle) chart.getLegend(); RectangleEdge legendPosition = RectangleEdge.BOTTOM; try { String legendProperty = "RectangleEdge." + System.getProperty("kuranda1D.legendPosition"); if (RectangleEdge.BOTTOM.toString().equals(legendProperty)) legendPosition = RectangleEdge.BOTTOM; else if (RectangleEdge.RIGHT.toString().equals(legendProperty)) legendPosition = RectangleEdge.RIGHT; else if (RectangleEdge.LEFT.toString().equals(legendProperty)) legendPosition = RectangleEdge.LEFT; else if (RectangleEdge.TOP.toString().equals(legendProperty)) legendPosition = RectangleEdge.TOP; } catch (Exception e) { // TODO: handle exception } legend.setPosition(legendPosition); chart.setBorderVisible(true); // ChartUtilities.applyCurrentTheme(chart); // chartTheme.apply(chart); XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setRangeGridlinePaint(Color.LIGHT_GRAY); plot.setDomainGridlinePaint(Color.LIGHT_GRAY); // plot.setRangeZeroBaselineVisible(false); // plot.setDomainZeroBaselineVisible(false); ValueAxis rangeAxis = plot.getRangeAxis(); if (rangeAxis instanceof NumberAxis) { ((NumberAxis) rangeAxis).setAutoRangeStickyZero(false); ((NumberAxis) rangeAxis).setAutoRangeIncludesZero(false); } ValueAxis domainAxis = plot.getDomainAxis(); if (domainAxis instanceof NumberAxis) { ((NumberAxis) domainAxis).setAutoRangeStickyZero(false); ((NumberAxis) domainAxis).setAutoRangeIncludesZero(false); } plot.setDomainPannable(true); plot.setRangePannable(true); plot.setDomainGridlinesVisible(true); // plot.setDomainCrosshairLockedOnData(true); // plot.setDomainCrosshairVisible(true); plot.setRangeGridlinesVisible(true); // plot.setRangeCrosshairLockedOnData(true); // plot.setRangeCrosshairVisible(true); // xAxis = plot.getDomainAxis(); // yAxis = plot.getRangeAxis(); plot.setDataset(dataset); XYItemRenderer renderer = chart.getXYPlot().getRenderer(); if (renderer instanceof XYErrorRenderer) { // ((XYLineAndShapeRenderer) renderer).setBaseShapesVisible(true); ((XYErrorRenderer) renderer).setBaseShapesFilled(true); ((XYErrorRenderer) renderer).setDrawXError(false); ((XYErrorRenderer) renderer).setDrawYError(true); } chart.fireChartChanged(); return chart; }
From source file:gov.sandia.umf.platform.ui.jobs.Plot.java
public JFreeChart createChart(final XYDataset dataset) { final JFreeChart chart = ChartFactory.createXYLineChart(null, // chart title null, // x axis label null, // y axis label dataset, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls );// w ww .j a v a 2s . c o m chart.setBackgroundPaint(Color.white); LegendTitle legend = chart.getLegend(); legend.setVisible(dataset.getSeriesCount() <= 5); XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setDomainPannable(true); plot.setRangePannable(true); ValueAxis axis = plot.getRangeAxis(); if (axis instanceof NumberAxis) ((NumberAxis) axis).setAutoRangeIncludesZero(false); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); for (int i = 0; i < dataset.getSeriesCount(); i++) renderer.setSeriesShapesVisible(i, false); plot.setRenderer(renderer); return chart; }
From source file:gov.sandia.umf.platform.ui.jobs.Raster.java
public JFreeChart createChart(final XYDataset dataset) { final JFreeChart chart = ChartFactory.createScatterPlot(null, // chart title null, // x axis label null, // y axis label dataset, // data PlotOrientation.VERTICAL, false, // include legend true, // tooltips false // urls );/*from w w w . j a v a2s. c o m*/ chart.setBackgroundPaint(Color.white); XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.white); plot.setRangeGridlinePaint(Color.lightGray); plot.setDomainPannable(true); plot.setRangePannable(true); plot.setRenderer(new XYDotRenderer() { public void drawItem(java.awt.Graphics2D g2, XYItemRendererState state, java.awt.geom.Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, int series, int item, CrosshairState crosshairState, int pass) { // Copied from org.jfree.chart.renderer.xy.XYDotRenderer.java and modified. // This would only need to be a couple of lines if they authors of jfreechart had not made dotWidth and dotHeight private members. // Yet another example of textbook OO programming gone awry. (Can anyone hear me scream?) if (!getItemVisible(series, item)) return; int dotWidth = 1; double rasterLines = rangeAxis.getRange().getLength(); int pixels = g2.getClipBounds().height; double height = pixels / rasterLines; if (height > 10) height -= 2; else if (height > 2) height -= 1; int dotHeight = (int) Math.min(20, Math.max(1, Math.floor(height))); double x = dataset.getXValue(series, item); double y = dataset.getYValue(series, item); if (Double.isNaN(y)) return; double adjx = (dotWidth - 1) / 2.0; double adjy = (dotHeight - 1) / 2.0; RectangleEdge xAxisLocation = plot.getDomainAxisEdge(); RectangleEdge yAxisLocation = plot.getRangeAxisEdge(); double transX = domainAxis.valueToJava2D(x, dataArea, xAxisLocation) - adjx; double transY = rangeAxis.valueToJava2D(y, dataArea, yAxisLocation) - adjy; g2.setPaint(Color.black); PlotOrientation orientation = plot.getOrientation(); if (orientation == PlotOrientation.HORIZONTAL) g2.fillRect((int) transY, (int) transX, dotHeight, dotWidth); else g2.fillRect((int) transX, (int) transY, dotWidth, dotHeight); int domainAxisIndex = plot.getDomainAxisIndex(domainAxis); int rangeAxisIndex = plot.getRangeAxisIndex(rangeAxis); updateCrosshairValues(crosshairState, x, y, domainAxisIndex, rangeAxisIndex, transX, transY, orientation); } }); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // Integer units only return chart; }
From source file:net.sf.maltcms.chromaui.chromatogram2Dviewer.ui.Chromatogram2DViewTopComponent.java
private XYPlot createPlot(IChromatogramDescriptor chromatogram, ADataset2D<IChromatogram2D, IScan2D> ds, PaintScale ps) {/* www .j a v a2 s . c o m*/ XYNoBlockRenderer xybr = new XYNoBlockRenderer(); xybr.setPaintScale(ps); try { double modulationTime = chromatogram.getChromatogram().getParent().getChild("modulation_time") .getArray().getDouble(0); double scanRate = chromatogram.getChromatogram().getParent().getChild("scan_rate").getArray() .getDouble(0); xybr.setDefaultEntityRadius(10);//Math.max(1, (int)(modulationTime / scanRate))); xybr.setEntityThreshold(ds.getMinZ()); xybr.setBlockWidth(modulationTime); xybr.setBlockAnchor(RectangleAnchor.CENTER); double spm = modulationTime * scanRate; double scanDuration = modulationTime / spm; xybr.setBlockHeight(scanDuration); } catch (ResourceNotAvailableException rnae) { } RTUnit rtUnit = RTUnit.SECONDS; xybr.setToolTipGenerator( new StandardXYZToolTipGenerator("{0}: @({1}, {2}) = {3}", DecimalFormat.getNumberInstance(), DecimalFormat.getNumberInstance(), DecimalFormat.getNumberInstance())); NumberAxis rt1 = new NumberAxis("RT1 [" + rtUnit.name().toLowerCase() + "]"); NumberAxis rt2 = new NumberAxis("RT2 [" + rtUnit.name().toLowerCase() + "]"); rt1.setAutoRange(false); rt1.setLowerBound(ds.getMinX()); rt1.setUpperBound(ds.getMaxX()); rt1.setRangeWithMargins(ds.getMinX(), ds.getMaxX()); rt2.setFixedAutoRange(ds.getMaxX() - ds.getMinX()); rt2.setAutoRange(false); rt2.setLowerBound(ds.getMinY()); rt2.setUpperBound(ds.getMaxY()); rt2.setFixedAutoRange(ds.getMaxY() - ds.getMinY()); rt2.setRangeWithMargins(ds.getMinY(), ds.getMaxY()); XYPlot heatmapPlot = new XYPlot(ds, rt1, rt2, xybr); heatmapPlot.setDomainPannable(true); heatmapPlot.setRangePannable(true); return heatmapPlot; }
From source file:com.seagate.kinetic.monitor.view.KineticSpecifiedNodeView.java
private void createStatChart() { TimeSeriesCollection putOpsTsc = new TimeSeriesCollection(putOpsTs); TimeSeriesCollection putTrgTsc = new TimeSeriesCollection(putTrgTs); TimeSeriesCollection getOpsTsc = new TimeSeriesCollection(getOpsTs); TimeSeriesCollection getTrgTsc = new TimeSeriesCollection(getTrgTs); TimeSeriesCollection deleteOpsTsc = new TimeSeriesCollection(deleteOpsTs); TimeSeriesCollection deleteTrgTsc = new TimeSeriesCollection(deleteTrgTs); statChart = ChartFactory.createTimeSeriesChart("", "Time", "put kvop/s", putOpsTsc, true, true, false); XYPlot xyplot = (XYPlot) statChart.getPlot(); xyplot.setOrientation(PlotOrientation.VERTICAL); xyplot.setDomainPannable(true); xyplot.setRangePannable(true);//from www . ja v a2s .co m ValueAxis yAxis = xyplot.getDomainAxis(); yAxis.setAutoRange(true); yAxis.setFixedAutoRange(60000.0); NumberAxis numberaxis1 = new NumberAxis("get kvop/s"); xyplot.setRangeAxis(1, numberaxis1); xyplot.setDataset(1, getOpsTsc); xyplot.mapDatasetToRangeAxis(1, 1); StandardXYItemRenderer standardxyitemrenderer1 = new StandardXYItemRenderer(); xyplot.setRenderer(1, standardxyitemrenderer1); NumberAxis numberaxis2 = new NumberAxis("delete kvop/s"); numberaxis2.setAutoRangeIncludesZero(false); xyplot.setRangeAxis(2, numberaxis2); xyplot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_LEFT); xyplot.setDataset(2, deleteOpsTsc); xyplot.mapDatasetToRangeAxis(2, 2); StandardXYItemRenderer standardxyitemrenderer2 = new StandardXYItemRenderer(); xyplot.setRenderer(2, standardxyitemrenderer2); NumberAxis numberaxis3 = new NumberAxis("put MB/s"); xyplot.setRangeAxis(3, numberaxis3); xyplot.setDataset(3, putTrgTsc); xyplot.mapDatasetToRangeAxis(3, 3); StandardXYItemRenderer standardxyitemrenderer3 = new StandardXYItemRenderer(); xyplot.setRenderer(3, standardxyitemrenderer3); NumberAxis numberaxis4 = new NumberAxis("get MB/s"); numberaxis4.setAutoRangeIncludesZero(false); xyplot.setRangeAxis(4, numberaxis4); xyplot.setRangeAxisLocation(2, AxisLocation.BOTTOM_OR_LEFT); xyplot.setDataset(4, getTrgTsc); xyplot.mapDatasetToRangeAxis(4, 4); StandardXYItemRenderer standardxyitemrenderer4 = new StandardXYItemRenderer(); xyplot.setRenderer(4, standardxyitemrenderer4); NumberAxis numberaxis5 = new NumberAxis("delete MB/s"); xyplot.setRangeAxis(5, numberaxis5); xyplot.setDataset(5, deleteTrgTsc); xyplot.mapDatasetToRangeAxis(5, 5); StandardXYItemRenderer standardxyitemrenderer5 = new StandardXYItemRenderer(); xyplot.setRenderer(5, standardxyitemrenderer5); ChartUtilities.applyCurrentTheme(statChart); xyplot.getRenderer().setSeriesPaint(0, Color.black); standardxyitemrenderer1.setSeriesPaint(0, Color.red); numberaxis1.setLabelPaint(Color.red); numberaxis1.setTickLabelPaint(Color.red); standardxyitemrenderer2.setSeriesPaint(0, Color.green); numberaxis2.setLabelPaint(Color.green); numberaxis2.setTickLabelPaint(Color.green); standardxyitemrenderer3.setSeriesPaint(0, Color.orange); numberaxis3.setLabelPaint(Color.orange); numberaxis3.setTickLabelPaint(Color.orange); standardxyitemrenderer4.setSeriesPaint(0, Color.blue); numberaxis4.setLabelPaint(Color.blue); numberaxis4.setTickLabelPaint(Color.blue); standardxyitemrenderer5.setSeriesPaint(0, Color.cyan); numberaxis5.setLabelPaint(Color.cyan); numberaxis5.setTickLabelPaint(Color.cyan); final JPanel main = new JPanel(new BorderLayout()); final JPanel optionsPanel = new JPanel(); String[] options = { SYSTEM_TOTAL_IOPS_AND_THROUGHPUT_STATISTICS }; this.orientationComboBox = new JComboBox<String>(options); this.orientationComboBox.setSize(600, 50); this.orientationComboBox.addActionListener(this); optionsPanel.add(this.orientationComboBox); chartPanel = new ChartPanel(statChart); chartPanel.setMouseWheelEnabled(false); chartPanel.setPreferredSize(new Dimension(900, 450)); chartPanel.setDomainZoomable(true); chartPanel.setRangeZoomable(true); main.add(optionsPanel, BorderLayout.NORTH); main.add(this.chartPanel); setContentPane(main); }
From source file:net.sf.maltcms.chromaui.chromatogram1Dviewer.ui.Chromatogram1DHeatmapViewTopComponent.java
private XYPlot createPlot(ADataset2D<IChromatogram1D, IScan> ds) { XYBlockRenderer xybr = new XYBlockRenderer(); IPaintScaleProvider ips = Lookup.getDefault().lookup(IPaintScaleProvider.class); ips.setMin(ds.getMinZ());//from ww w . ja v a 2s . c om ips.setMax(ds.getMaxZ()); PaintScale ps = ips.getPaintScales().get(0); xybr.setPaintScale(ps); xybr.setDefaultEntityRadius(5); xybr.setBlockWidth(0.1); xybr.setBlockAnchor(RectangleAnchor.CENTER); xybr.setBlockHeight(1.0); RTUnit rtUnit = RTUnit.SECONDS; xybr.setToolTipGenerator( new StandardXYZToolTipGenerator("{0}: @({1}, {2}) = {3}", DecimalFormat.getNumberInstance(), DecimalFormat.getNumberInstance(), DecimalFormat.getNumberInstance())); NumberAxis rt1 = new NumberAxis("Retention Time [" + rtUnit.name().toLowerCase() + "]"); NumberAxis rt2 = new NumberAxis("M/Z"); rt1.setAutoRange(false); rt1.setLowerBound(ds.getMinX()); rt1.setUpperBound(ds.getMaxX()); rt1.setRangeWithMargins(ds.getMinX(), ds.getMaxX()); rt2.setFixedAutoRange(ds.getMaxX() - ds.getMinX()); rt2.setAutoRange(false); rt2.setLowerBound(ds.getMinY()); rt2.setUpperBound(ds.getMaxY()); rt2.setFixedAutoRange(ds.getMaxY() - ds.getMinY()); rt2.setRangeWithMargins(ds.getMinY(), ds.getMaxY()); XYPlot heatmapPlot = new XYPlot(ds, rt1, rt2, xybr); heatmapPlot.setDomainPannable(true); heatmapPlot.setRangePannable(true); return heatmapPlot; }
From source file:ruc.edu.window.DynamicDataDemo2.java
/** * Constructs a new demonstration application. * * @param title the frame title.// w ww. jav a 2s .c o m */ public DynamicDataDemo2(final String title) { super(title); this.series1 = new TimeSeries("Random 1"); this.series2 = new TimeSeries("Random 2"); final TimeSeriesCollection dataset1 = new TimeSeriesCollection(this.series1); final TimeSeriesCollection dataset2 = new TimeSeriesCollection(this.series2); final JFreeChart chart = ChartFactory.createTimeSeriesChart("Dynamic Data Demo 2", "Time", "Value", dataset1, true, true, false); chart.setBackgroundPaint(Color.white); final XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.gray); plot.setRangeGridlinePaint(Color.gray); plot.setDomainPannable(true); // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 4, 4, 4, 4)); final ValueAxis axis = plot.getDomainAxis(); axis.setAutoRange(true); //axis.setAutoRangeMinimumSize(600000.0); axis.setFixedAutoRange(5000.0); // 60 seconds plot.setDataset(1, dataset2); //final NumberAxis rangeAxis2 = new NumberAxis("Range Axis 2"); /// rangeAxis2.setAutoRangeIncludesZero(false); plot.setRenderer(0, new DefaultXYItemRenderer()); plot.setRenderer(1, new DefaultXYItemRenderer()); //plot.setRangeAxis(1, rangeAxis2); plot.mapDatasetToRangeAxis(1, 0); plot.getRenderer().setSeriesPaint(0, new Color(91, 155, 213)); plot.getRenderer(1).setSeriesPaint(0, Color.BLUE); XYLineAndShapeRenderer render2 = new XYLineAndShapeRenderer() { Stroke soild = new BasicStroke(2.0f); Stroke dashed = new BasicStroke(10.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, new float[] { 10.0f }, 0.0f); @Override public Stroke getItemStroke(int row, int column) { return dashed; } }; plot.setRenderer(1, render2); final JPanel content = new JPanel(new BorderLayout()); final ChartPanel chartPanel = new ChartPanel(chart); content.add(chartPanel); final JButton button1 = new JButton("Add To Series 1"); button1.setActionCommand("ADD_DATA_1"); button1.addActionListener(this); final JButton button2 = new JButton("Add To Series 2"); button2.setActionCommand("ADD_DATA_2"); button2.addActionListener(this); final JButton button3 = new JButton("Add To Both"); button3.setActionCommand("ADD_BOTH"); button3.addActionListener(this); final JPanel buttonPanel = new JPanel(new FlowLayout()); buttonPanel.add(button1); buttonPanel.add(button2); buttonPanel.add(button3); content.add(buttonPanel, BorderLayout.SOUTH); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); setContentPane(content); }