Java Code Examples for org.jfree.chart.plot.XYPlot#mapDatasetToRangeAxis()
The following examples show how to use
org.jfree.chart.plot.XYPlot#mapDatasetToRangeAxis() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MultipleAxisChart.java From netcdf-java with BSD 3-Clause "New" or "Revised" License | 6 votes |
public void addSeries(String yaxisName, TimeSeries series) { NumberAxis axis2 = new NumberAxis(yaxisName); axis2.setAutoRangeIncludesZero(false); XYPlot plot = (XYPlot) chart.getPlot(); plot.setRangeAxis(axisNum, axis2); plot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_LEFT); TimeSeriesCollection dataset = new TimeSeriesCollection(); dataset.addSeries(series); plot.setDataset(axisNum, dataset); plot.mapDatasetToRangeAxis(axisNum, axisNum); XYItemRenderer renderer2 = new StandardXYItemRenderer(); plot.setRenderer(axisNum, renderer2); axisNum++; }
Example 2
Source File: CashFlowToChart.java From ta4j-origins with MIT License | 5 votes |
/** * Adds the cash flow axis to the plot. * @param plot the plot * @param dataset the cash flow dataset */ private static void addCashFlowAxis(XYPlot plot, TimeSeriesCollection dataset) { final NumberAxis cashAxis = new NumberAxis("Cash Flow Ratio"); cashAxis.setAutoRangeIncludesZero(false); plot.setRangeAxis(1, cashAxis); plot.setDataset(1, dataset); plot.mapDatasetToRangeAxis(1, 1); final StandardXYItemRenderer cashFlowRenderer = new StandardXYItemRenderer(); cashFlowRenderer.setSeriesPaint(0, Color.blue); plot.setRenderer(1, cashFlowRenderer); }
Example 3
Source File: DataPanel.java From BowlerStudio with GNU General Public License v3.0 | 5 votes |
/** * Creates a new self-contained demo panel. */ public DataPanel(String title) { //setTitle(title); setLayout(new BorderLayout()); positionSer = new XYSeries("True Position"); XYSeriesCollection dataset1 = new XYSeriesCollection(positionSer); JFreeChart chart = ChartFactory.createTimeSeriesChart("Position", "Time (seconds)", "Angle (degrees)", dataset1,true, true, false); plot = (XYPlot) chart.getPlot(); plot.setRenderer(1, new DefaultXYItemRenderer()); plot.mapDatasetToRangeAxis(1, 1); ValueAxis axis = plot.getDomainAxis(); axis.setAutoRange(true); axis.setFixedAutoRange(20000.0); // 20 seconds ChartUtilities.applyCurrentTheme(chart); ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); exportXlsBtn.setActionCommand("EXPORT_XLS"); exportCsvBtn.setActionCommand("EXPORT_CSV"); exportXlsBtn.addActionListener(this); exportCsvBtn.addActionListener(this); JPanel exportPanel = new JPanel(); exportPanel.add(exportXlsBtn); exportPanel.add(exportCsvBtn); JPanel mainPanel = new JPanel(new BorderLayout()); mainPanel.add(chartPanel); mainPanel.add(exportPanel, BorderLayout.SOUTH); add(mainPanel); }
Example 4
Source File: JFreeChartPlotEngine.java From rapidminer-studio with GNU Affero General Public License v3.0 | 5 votes |
private void pushDataAndRendererIntoPlot(XYPlot plot, int rangeAxisIdx, XYItemRenderer renderer, XYDataset dataset) throws ChartPlottimeException { if (dataset != null && renderer != null) { int datasetIdx = plot.getDatasetCount(); if (datasetIdx > 0 && plot.getDataset(datasetIdx - 1) == null) { datasetIdx -= 1; } // push dataset and renderer into plot try { plot.setDataset(datasetIdx, dataset); // if Eclipse states that // dataset might not be // initialized, you did // not consider all // possibilities in the // condition block above } catch (RuntimeException e) { // probably this is because the domain axis contains values less // then zero and the scaling is logarithmic. // The shitty JFreeChart implementation does not throw a proper // exception stating what happened, // but just a RuntimeException with a string, so this is our // best guess: if (isProbablyZeroValuesOnLogScaleException(e)) { throw new ChartPlottimeException("gui.plotter.error.log_axis_contains_zero", "domain axis"); } else { throw e; } } plot.mapDatasetToRangeAxis(datasetIdx, rangeAxisIdx); plot.setRenderer(datasetIdx, renderer); } else { ChartPlottimeException chartPlottimeException = new ChartPlottimeException( new PlotConfigurationError("generic_plotter_error")); throw chartPlottimeException; } }
Example 5
Source File: DSWorkbenchStatsFrame.java From dsworkbench with Apache License 2.0 | 5 votes |
private void addDataset(String pId, XYDataset pDataset) { if (chart == null) { setupChart(pId, pDataset); } else { XYPlot plot = (XYPlot) chart.getPlot(); plot.setDataset(plot.getDatasetCount(), pDataset); NumberAxis axis = new NumberAxis(pId); NumberFormat nf = NumberFormat.getInstance(); nf.setMinimumFractionDigits(0); nf.setMaximumFractionDigits(0); axis.setNumberFormatOverride(nf); plot.setRangeAxis(plot.getDatasetCount() - 1, axis); plot.setRangeAxisLocation(plot.getDatasetCount() - 1, AxisLocation.TOP_OR_LEFT); plot.mapDatasetToRangeAxis(plot.getDatasetCount() - 1, plot.getDatasetCount() - 1); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesLinesVisible(0, jShowLines.isSelected()); renderer.setSeriesShapesVisible(0, jShowDataPoints.isSelected()); plot.setRenderer(plot.getDatasetCount() - 1, renderer); renderer.setDefaultItemLabelsVisible(jShowItemValues.isSelected()); renderer.setDefaultItemLabelGenerator(new org.jfree.chart.labels.StandardXYItemLabelGenerator()); renderer.setDefaultToolTipGenerator(new StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT, new SimpleDateFormat("dd.MM.yyyy HH:mm:ss"), NumberFormat.getInstance())); axis.setAxisLinePaint(plot.getLegendItems().get(plot.getDatasetCount() - 1).getLinePaint()); axis.setLabelPaint(plot.getLegendItems().get(plot.getDatasetCount() - 1).getLinePaint()); axis.setTickLabelPaint(plot.getLegendItems().get(plot.getDatasetCount() - 1).getLinePaint()); axis.setTickMarkPaint(plot.getLegendItems().get(plot.getDatasetCount() - 1).getLinePaint()); } }
Example 6
Source File: SWTMultipleAxisDemo1.java From buffer_bci with GNU General Public License v3.0 | 4 votes |
/** * Creates the demo chart. * * @return The chart. */ private static JFreeChart createChart() { XYDataset dataset1 = createDataset("Series 1", 100.0, new Minute(), 200); JFreeChart chart = ChartFactory.createTimeSeriesChart( "Multiple Axis Demo 3", "Time of Day", "Primary Range Axis", dataset1, true, true, false ); chart.setBackgroundPaint(Color.white); chart.setBorderVisible(true); chart.setBorderPaint(Color.BLACK); TextTitle subtitle = new TextTitle("Four datasets and four range axes."); chart.addSubtitle(subtitle); XYPlot plot = (XYPlot) chart.getPlot(); plot.setOrientation(PlotOrientation.VERTICAL); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); XYItemRenderer renderer = plot.getRenderer(); renderer.setSeriesPaint(0, Color.black); // AXIS 2 NumberAxis axis2 = new NumberAxis("Range Axis 2"); axis2.setAutoRangeIncludesZero(false); axis2.setLabelPaint(Color.red); axis2.setTickLabelPaint(Color.red); plot.setRangeAxis(1, axis2); plot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_LEFT); XYDataset dataset2 = createDataset("Series 2", 1000.0, new Minute(), 170); plot.setDataset(1, dataset2); plot.mapDatasetToRangeAxis(1, 1); XYItemRenderer renderer2 = new StandardXYItemRenderer(); renderer2.setSeriesPaint(0, Color.red); plot.setRenderer(1, renderer2); // AXIS 3 NumberAxis axis3 = new NumberAxis("Range Axis 3"); axis3.setLabelPaint(Color.blue); axis3.setTickLabelPaint(Color.blue); //axis3.setPositiveArrowVisible(true); plot.setRangeAxis(2, axis3); XYDataset dataset3 = createDataset("Series 3", 10000.0, new Minute(), 170); plot.setDataset(2, dataset3); plot.mapDatasetToRangeAxis(2, 2); XYItemRenderer renderer3 = new StandardXYItemRenderer(); renderer3.setSeriesPaint(0, Color.blue); plot.setRenderer(2, renderer3); // AXIS 4 NumberAxis axis4 = new NumberAxis("Range Axis 4"); axis4.setLabelPaint(Color.green); axis4.setTickLabelPaint(Color.green); plot.setRangeAxis(3, axis4); XYDataset dataset4 = createDataset("Series 4", 25.0, new Minute(), 200); plot.setDataset(3, dataset4); plot.mapDatasetToRangeAxis(3, 3); XYItemRenderer renderer4 = new StandardXYItemRenderer(); renderer4.setSeriesPaint(0, Color.green); plot.setRenderer(3, renderer4); return chart; }
Example 7
Source File: CandlestickChart.java From ta4j-origins with MIT License | 4 votes |
public static void main(String[] args) { /** * Getting time series */ TimeSeries series = CsvTradesLoader.loadBitstampSeries(); /** * Creating the OHLC dataset */ OHLCDataset ohlcDataset = createOHLCDataset(series); /** * Creating the additional dataset */ TimeSeriesCollection xyDataset = createAdditionalDataset(series); /** * Creating the chart */ JFreeChart chart = ChartFactory.createCandlestickChart( "Bitstamp BTC price", "Time", "USD", ohlcDataset, true); // Candlestick rendering CandlestickRenderer renderer = new CandlestickRenderer(); renderer.setAutoWidthMethod(CandlestickRenderer.WIDTHMETHOD_SMALLEST); XYPlot plot = chart.getXYPlot(); plot.setRenderer(renderer); // Additional dataset int index = 1; plot.setDataset(index, xyDataset); plot.mapDatasetToRangeAxis(index, 0); XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer(true, false); renderer2.setSeriesPaint(index, Color.blue); plot.setRenderer(index, renderer2); // Misc plot.setRangeGridlinePaint(Color.lightGray); plot.setBackgroundPaint(Color.white); NumberAxis numberAxis = (NumberAxis) plot.getRangeAxis(); numberAxis.setAutoRangeIncludesZero(false); plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); /** * Displaying the chart */ displayChart(chart); }
Example 8
Source File: SWTMultipleAxisDemo1.java From astor with GNU General Public License v2.0 | 4 votes |
/** * Creates the demo chart. * * @return The chart. */ private static JFreeChart createChart() { XYDataset dataset1 = createDataset("Series 1", 100.0, new Minute(), 200); JFreeChart chart = ChartFactory.createTimeSeriesChart( "Multiple Axis Demo 3", "Time of Day", "Primary Range Axis", dataset1, true, true, false ); chart.setBackgroundPaint( Color.white ); chart.setBorderVisible( true ); chart.setBorderPaint( Color.BLACK ); TextTitle subtitle = new TextTitle("Four datasets and four range axes."); chart.addSubtitle( subtitle ); XYPlot plot = (XYPlot) chart.getPlot(); plot.setOrientation(PlotOrientation.VERTICAL); 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.getRangeAxis().setFixedDimension(15.0); XYItemRenderer renderer = plot.getRenderer(); renderer.setSeriesPaint(0, Color.black); // AXIS 2 NumberAxis axis2 = new NumberAxis("Range Axis 2"); axis2.setFixedDimension(10.0); axis2.setAutoRangeIncludesZero(false); axis2.setLabelPaint(Color.red); axis2.setTickLabelPaint(Color.red); plot.setRangeAxis(1, axis2); plot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_LEFT); XYDataset dataset2 = createDataset("Series 2", 1000.0, new Minute(), 170); plot.setDataset(1, dataset2); plot.mapDatasetToRangeAxis(1, 1); XYItemRenderer renderer2 = new StandardXYItemRenderer(); renderer2.setSeriesPaint(0, Color.red); plot.setRenderer(1, renderer2); // AXIS 3 NumberAxis axis3 = new NumberAxis("Range Axis 3"); axis3.setLabelPaint(Color.blue); axis3.setTickLabelPaint(Color.blue); //axis3.setPositiveArrowVisible( true ); plot.setRangeAxis(2, axis3); XYDataset dataset3 = createDataset("Series 3", 10000.0, new Minute(), 170); plot.setDataset(2, dataset3); plot.mapDatasetToRangeAxis(2, 2); XYItemRenderer renderer3 = new StandardXYItemRenderer(); renderer3.setSeriesPaint(0, Color.blue); plot.setRenderer(2, renderer3); // AXIS 4 NumberAxis axis4 = new NumberAxis("Range Axis 4"); axis4.setLabelPaint(Color.green); axis4.setTickLabelPaint(Color.green); plot.setRangeAxis(3, axis4); XYDataset dataset4 = createDataset("Series 4", 25.0, new Minute(), 200); plot.setDataset(3, dataset4); plot.mapDatasetToRangeAxis(3, 3); XYItemRenderer renderer4 = new StandardXYItemRenderer(); renderer4.setSeriesPaint(0, Color.green); plot.setRenderer(3, renderer4); return chart; }
Example 9
Source File: SWTMultipleAxisDemo1.java From astor with GNU General Public License v2.0 | 4 votes |
/** * Creates the demo chart. * * @return The chart. */ private static JFreeChart createChart() { XYDataset dataset1 = createDataset("Series 1", 100.0, new Minute(), 200); JFreeChart chart = ChartFactory.createTimeSeriesChart( "Multiple Axis Demo 3", "Time of Day", "Primary Range Axis", dataset1, true, true, false ); chart.setBackgroundPaint( Color.white ); chart.setBorderVisible( true ); chart.setBorderPaint( Color.BLACK ); TextTitle subtitle = new TextTitle("Four datasets and four range axes."); chart.addSubtitle( subtitle ); XYPlot plot = (XYPlot) chart.getPlot(); plot.setOrientation(PlotOrientation.VERTICAL); 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.getRangeAxis().setFixedDimension(15.0); XYItemRenderer renderer = plot.getRenderer(); renderer.setSeriesPaint(0, Color.black); // AXIS 2 NumberAxis axis2 = new NumberAxis("Range Axis 2"); axis2.setFixedDimension(10.0); axis2.setAutoRangeIncludesZero(false); axis2.setLabelPaint(Color.red); axis2.setTickLabelPaint(Color.red); plot.setRangeAxis(1, axis2); plot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_LEFT); XYDataset dataset2 = createDataset("Series 2", 1000.0, new Minute(), 170); plot.setDataset(1, dataset2); plot.mapDatasetToRangeAxis(1, 1); XYItemRenderer renderer2 = new StandardXYItemRenderer(); renderer2.setSeriesPaint(0, Color.red); plot.setRenderer(1, renderer2); // AXIS 3 NumberAxis axis3 = new NumberAxis("Range Axis 3"); axis3.setLabelPaint(Color.blue); axis3.setTickLabelPaint(Color.blue); //axis3.setPositiveArrowVisible( true ); plot.setRangeAxis(2, axis3); XYDataset dataset3 = createDataset("Series 3", 10000.0, new Minute(), 170); plot.setDataset(2, dataset3); plot.mapDatasetToRangeAxis(2, 2); XYItemRenderer renderer3 = new StandardXYItemRenderer(); renderer3.setSeriesPaint(0, Color.blue); plot.setRenderer(2, renderer3); // AXIS 4 NumberAxis axis4 = new NumberAxis("Range Axis 4"); axis4.setLabelPaint(Color.green); axis4.setTickLabelPaint(Color.green); plot.setRangeAxis(3, axis4); XYDataset dataset4 = createDataset("Series 4", 25.0, new Minute(), 200); plot.setDataset(3, dataset4); plot.mapDatasetToRangeAxis(3, 3); XYItemRenderer renderer4 = new StandardXYItemRenderer(); renderer4.setSeriesPaint(0, Color.green); plot.setRenderer(3, renderer4); return chart; }
Example 10
Source File: SWTMultipleAxisDemo1.java From ECG-Viewer with GNU General Public License v2.0 | 4 votes |
/** * Creates the demo chart. * * @return The chart. */ private static JFreeChart createChart() { XYDataset dataset1 = createDataset("Series 1", 100.0, new Minute(), 200); JFreeChart chart = ChartFactory.createTimeSeriesChart( "Multiple Axis Demo 3", "Time of Day", "Primary Range Axis", dataset1, true, true, false ); chart.setBackgroundPaint(Color.white); chart.setBorderVisible(true); chart.setBorderPaint(Color.BLACK); TextTitle subtitle = new TextTitle("Four datasets and four range axes."); chart.addSubtitle(subtitle); XYPlot plot = (XYPlot) chart.getPlot(); plot.setOrientation(PlotOrientation.VERTICAL); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); XYItemRenderer renderer = plot.getRenderer(); renderer.setSeriesPaint(0, Color.black); // AXIS 2 NumberAxis axis2 = new NumberAxis("Range Axis 2"); axis2.setAutoRangeIncludesZero(false); axis2.setLabelPaint(Color.red); axis2.setTickLabelPaint(Color.red); plot.setRangeAxis(1, axis2); plot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_LEFT); XYDataset dataset2 = createDataset("Series 2", 1000.0, new Minute(), 170); plot.setDataset(1, dataset2); plot.mapDatasetToRangeAxis(1, 1); XYItemRenderer renderer2 = new StandardXYItemRenderer(); renderer2.setSeriesPaint(0, Color.red); plot.setRenderer(1, renderer2); // AXIS 3 NumberAxis axis3 = new NumberAxis("Range Axis 3"); axis3.setLabelPaint(Color.blue); axis3.setTickLabelPaint(Color.blue); //axis3.setPositiveArrowVisible(true); plot.setRangeAxis(2, axis3); XYDataset dataset3 = createDataset("Series 3", 10000.0, new Minute(), 170); plot.setDataset(2, dataset3); plot.mapDatasetToRangeAxis(2, 2); XYItemRenderer renderer3 = new StandardXYItemRenderer(); renderer3.setSeriesPaint(0, Color.blue); plot.setRenderer(2, renderer3); // AXIS 4 NumberAxis axis4 = new NumberAxis("Range Axis 4"); axis4.setLabelPaint(Color.green); axis4.setTickLabelPaint(Color.green); plot.setRangeAxis(3, axis4); XYDataset dataset4 = createDataset("Series 4", 25.0, new Minute(), 200); plot.setDataset(3, dataset4); plot.mapDatasetToRangeAxis(3, 3); XYItemRenderer renderer4 = new StandardXYItemRenderer(); renderer4.setSeriesPaint(0, Color.green); plot.setRenderer(3, renderer4); return chart; }
Example 11
Source File: OffspringChartComposite.java From offspring with MIT License | 4 votes |
private JFreeChart createChart(String title) { XYDataset priceDataset = createPriceDataset(); XYDataset volumeDataset = createVolumeDataset(); JFreeChart jfreechart = ChartFactory.createTimeSeriesChart(title, // title "Date", // x title "Price", // y title priceDataset, // dataset false, // legend true, // tooltips false); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); NumberAxis numberaxis = (NumberAxis) xyplot.getRangeAxis(); numberaxis.setLowerMargin(0.40000000000000002D); DecimalFormat decimalformat = new DecimalFormat(quote.getDecimalFormat()); numberaxis.setNumberFormatOverride(decimalformat); if (volumeDataset != null) { XYItemRenderer xyitemrenderer = xyplot.getRenderer(); xyitemrenderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator( "{0}: ({1}, {2})", new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("0.00"))); xyitemrenderer.setSeriesStroke(0, new BasicStroke(3)); NumberAxis numberaxis1 = new NumberAxis("Volume"); numberaxis1.setUpperMargin(1.0D); xyplot.setRangeAxis(1, numberaxis1); xyplot.setDataset(1, volumeDataset); xyplot.setRangeAxis(1, numberaxis1); xyplot.mapDatasetToRangeAxis(1, 1); XYBarRenderer xybarrenderer = new XYBarRenderer(0.20000000000000001D); xybarrenderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator( "{0}: ({1}, {2})", new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("0,000.00"))); xyplot.setRenderer(1, xybarrenderer); } return jfreechart; }
Example 12
Source File: DiagramRenderer.java From SensorWebClient with GNU General Public License v2.0 | 4 votes |
protected JFreeChart renderPreChart(Map<String, OXFFeatureCollection> entireCollMap, String[] observedProperties, ArrayList<TimeSeriesCollection> timeSeries, Calendar begin, Calendar end) { JFreeChart chart = ChartFactory.createTimeSeriesChart(null, // title "Date", // x-axis label observedProperties[0], // y-axis label timeSeries.get(0), // data true, // create legend? true, // generate tooltips? false // generate URLs? ); chart.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.lightGray); plot.setRangeGridlinePaint(Color.lightGray); plot.setAxisOffset(new RectangleInsets(2.0, 2.0, 2.0, 2.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); // add additional datasets: DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setRange(begin.getTime(), end.getTime()); axis.setDateFormatOverride(new SimpleDateFormat()); axis.setTimeZone(end.getTimeZone()); for (int i = 1; i < observedProperties.length; i++) { XYDataset additionalDataset = timeSeries.get(i); plot.setDataset(i, additionalDataset); plot.setRangeAxis(i, new NumberAxis(observedProperties[i])); // plot.getRangeAxis(i).setRange((Double) // overAllSeriesCollection.getMinimum(i), // (Double) overAllSeriesCollection.getMaximum(i)); plot.mapDatasetToRangeAxis(i, i); // plot.getDataset().getXValue(i, i); } return chart; }
Example 13
Source File: JPanelAnalysisTimeTemperature.java From Course_Generator with GNU General Public License v3.0 | 4 votes |
private JFreeChart CreateChart(XYDataset dataset1, XYDataset dataset2) { JFreeChart chart = ChartFactory.createXYLineChart("", // x axis label bundle.getString("JPanelAnalysisTimeDist.labelX"), // "Distance" // y axis label bundle.getString("JPanelAnalysisTimeDist.labelY1"), // "Elevation" dataset1, // data PlotOrientation.VERTICAL, false, // include legend true, // tooltips false // urls ); // -- Background color chart.setBackgroundPaint(Color.white); chart.setAntiAlias(true); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.gray); plot.setRangeGridlinePaint(Color.gray); plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_RIGHT); XYAreaRenderer renderer = new XYAreaRenderer(); renderer.setSeriesPaint(0, new Color(0x99, 0xff, 0x00)); renderer.setOutline(true); renderer.setSeriesOutlineStroke(0, new BasicStroke(2.0f)); plot.setRenderer(0, renderer); NumberAxis rangeAxis2 = new NumberAxis(bundle.getString("JPanelAnalysisTimeTemperature.labelY2")); // "Time" plot.setRangeAxis(1, rangeAxis2); plot.setDataset(1, dataset2); plot.setRangeAxis(1, rangeAxis2); plot.mapDatasetToRangeAxis(1, 1); StandardXYItemRenderer renderer2 = new StandardXYItemRenderer(); renderer2.setSeriesPaint(0, Color.red); plot.setRenderer(1, renderer2); // -- Select the display order plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); return chart; }
Example 14
Source File: JPanelAnalysisTimeDist.java From Course_Generator with GNU General Public License v3.0 | 4 votes |
private JFreeChart CreateChart(XYDataset dataset1, XYDataset dataset2) { JFreeChart chart = ChartFactory.createXYAreaChart("", // x axis label bundle.getString("JPanelAnalysisTimeDist.labelX"), // "Distance" // y axis label bundle.getString("JPanelAnalysisTimeDist.labelY1"), // "Elevation" dataset1, // data PlotOrientation.VERTICAL, false, // include legend true, // tooltips false // urls ); // -- Background color chart.setBackgroundPaint(Color.white); chart.setAntiAlias(true); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.gray); plot.setRangeGridlinePaint(Color.gray); plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_RIGHT); XYAreaRenderer renderer = new XYAreaRenderer(); renderer.setSeriesPaint(0, new Color(0x99, 0xff, 0x00)); renderer.setOutline(true); renderer.setSeriesOutlineStroke(0, new BasicStroke(2.0f)); plot.setRenderer(0, renderer); NumberAxis rangeAxis2 = new NumberAxis(bundle.getString("JPanelAnalysisTimeDist.labelY2")); // "Time" plot.setRangeAxis(1, rangeAxis2); plot.setDataset(1, dataset2); plot.setRangeAxis(1, rangeAxis2); plot.mapDatasetToRangeAxis(1, 1); StandardXYItemRenderer renderer2 = new StandardXYItemRenderer(); renderer2.setSeriesPaint(0, Color.red); plot.setRenderer(1, renderer2); // -- Select the display order plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); return chart; }
Example 15
Source File: JPanelAnalysisSpeedSlope.java From Course_Generator with GNU General Public License v3.0 | 4 votes |
private JFreeChart CreateChart(XYDataset dataset1, XYDataset dataset2) { JFreeChart chart = ChartFactory.createScatterPlot("", // x axis label bundle.getString("JPanelAnalysisSpeedSlope.labelX"), // "Slope", // y axis label bundle.getString("JPanelAnalysisSpeedSlope.labelY"), // "Speed", // data dataset1, PlotOrientation.VERTICAL, false, // include legend true, // tooltips false // urls ); chart.setBackgroundPaint(Color.white); // Panel background color chart.setAntiAlias(true); XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.gray); plot.setRangeGridlinePaint(Color.gray); plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_RIGHT); plot.setRangeCrosshairLockedOnData(false); XYDotRenderer renderer = new XYDotRenderer(); renderer.setSeriesPaint(0, new Color(0x6B, 0xB2, 0x00)); renderer.setDotWidth(2); renderer.setDotHeight(2); plot.setRenderer(renderer); NumberAxis rangeAxis2 = new NumberAxis(); plot.setRangeAxis(1, rangeAxis2); plot.setDataset(1, dataset2); plot.setRangeAxis(1, rangeAxis2); plot.mapDatasetToRangeAxis(1, 1); XYAreaRenderer renderer2 = new XYAreaRenderer(); renderer2.setSeriesPaint(0, new Color(0x99, 0xff, 0x00, 0x80)); renderer2.setOutline(true); renderer2.setSeriesOutlinePaint(0, new Color(0x80, 0x80, 0x80, 0x80)); renderer2.setSeriesOutlineStroke(0, new BasicStroke(2.0f)); plot.setRenderer(1, renderer2); /* * StandardXYItemRenderer renderer2 = new StandardXYItemRenderer(); * renderer2.setSeriesPaint(0, Color.red); plot.setRenderer(1, renderer2); */ // -- Select the display order plot.setDatasetRenderingOrder(DatasetRenderingOrder.REVERSE); return chart; }
Example 16
Source File: JPanelAnalysisSpeed.java From Course_Generator with GNU General Public License v3.0 | 4 votes |
private JFreeChart CreateChart(XYDataset dataset1, XYDataset dataset2) { JFreeChart chart = ChartFactory.createXYAreaChart("", // x axis label bundle.getString("JPanelAnalysisSpeed.labelX"), // "Distance", // y axis label bundle.getString("JPanelAnalysisSpeed.labelY"), // "Speed" dataset1, // data PlotOrientation.VERTICAL, false, // include legend true, // tooltips false // urls ); chart.setBackgroundPaint(Color.white); // Panel background color chart.setAntiAlias(true); XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.gray); plot.setRangeGridlinePaint(Color.gray); plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_RIGHT); XYAreaRenderer renderer = new XYAreaRenderer(); renderer.setSeriesPaint(0, new Color(0x99, 0xff, 0x00)); renderer.setOutline(true); renderer.setSeriesOutlineStroke(0, new BasicStroke(2.0f)); plot.setRenderer(0, renderer); NumberAxis rangeAxis2 = new NumberAxis(); plot.setRangeAxis(1, rangeAxis2); plot.setDataset(1, dataset2); plot.setRangeAxis(1, rangeAxis2); plot.mapDatasetToRangeAxis(1, 1); StandardXYItemRenderer renderer2 = new StandardXYItemRenderer(); renderer2.setSeriesPaint(0, Color.red); plot.setRenderer(1, renderer2); // -- Select the display order plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); return chart; }
Example 17
Source File: SWTMultipleAxisDemo1.java From SIMVA-SoS with Apache License 2.0 | 4 votes |
/** * Creates the demo chart. * * @return The chart. */ private static JFreeChart createChart() { XYDataset dataset1 = createDataset("Series 1", 100.0, new Minute(), 200); JFreeChart chart = ChartFactory.createTimeSeriesChart( "Multiple Axis Demo 3", "Time of Day", "Primary Range Axis", dataset1, true, true, false ); chart.setBackgroundPaint(Color.white); chart.setBorderVisible(true); chart.setBorderPaint(Color.BLACK); TextTitle subtitle = new TextTitle("Four datasets and four range axes."); chart.addSubtitle(subtitle); XYPlot plot = (XYPlot) chart.getPlot(); plot.setOrientation(PlotOrientation.VERTICAL); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); XYItemRenderer renderer = plot.getRenderer(); renderer.setSeriesPaint(0, Color.black); // AXIS 2 NumberAxis axis2 = new NumberAxis("Range Axis 2"); axis2.setAutoRangeIncludesZero(false); axis2.setLabelPaint(Color.red); axis2.setTickLabelPaint(Color.red); plot.setRangeAxis(1, axis2); plot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_LEFT); XYDataset dataset2 = createDataset("Series 2", 1000.0, new Minute(), 170); plot.setDataset(1, dataset2); plot.mapDatasetToRangeAxis(1, 1); XYItemRenderer renderer2 = new StandardXYItemRenderer(); renderer2.setSeriesPaint(0, Color.red); plot.setRenderer(1, renderer2); // AXIS 3 NumberAxis axis3 = new NumberAxis("Range Axis 3"); axis3.setLabelPaint(Color.blue); axis3.setTickLabelPaint(Color.blue); //axis3.setPositiveArrowVisible(true); plot.setRangeAxis(2, axis3); XYDataset dataset3 = createDataset("Series 3", 10000.0, new Minute(), 170); plot.setDataset(2, dataset3); plot.mapDatasetToRangeAxis(2, 2); XYItemRenderer renderer3 = new StandardXYItemRenderer(); renderer3.setSeriesPaint(0, Color.blue); plot.setRenderer(2, renderer3); // AXIS 4 NumberAxis axis4 = new NumberAxis("Range Axis 4"); axis4.setLabelPaint(Color.green); axis4.setTickLabelPaint(Color.green); plot.setRangeAxis(3, axis4); XYDataset dataset4 = createDataset("Series 4", 25.0, new Minute(), 200); plot.setDataset(3, dataset4); plot.mapDatasetToRangeAxis(3, 3); XYItemRenderer renderer4 = new StandardXYItemRenderer(); renderer4.setSeriesPaint(0, Color.green); plot.setRenderer(3, renderer4); return chart; }
Example 18
Source File: SWTMultipleAxisDemo1.java From ccu-historian with GNU General Public License v3.0 | 4 votes |
/** * Creates the demo chart. * * @return The chart. */ private static JFreeChart createChart() { XYDataset dataset1 = createDataset("Series 1", 100.0, new Minute(), 200); JFreeChart chart = ChartFactory.createTimeSeriesChart( "Multiple Axis Demo 3", "Time of Day", "Primary Range Axis", dataset1, true, true, false ); chart.setBackgroundPaint(Color.white); chart.setBorderVisible(true); chart.setBorderPaint(Color.BLACK); TextTitle subtitle = new TextTitle("Four datasets and four range axes."); chart.addSubtitle(subtitle); XYPlot plot = (XYPlot) chart.getPlot(); plot.setOrientation(PlotOrientation.VERTICAL); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); XYItemRenderer renderer = plot.getRenderer(); renderer.setSeriesPaint(0, Color.black); // AXIS 2 NumberAxis axis2 = new NumberAxis("Range Axis 2"); axis2.setAutoRangeIncludesZero(false); axis2.setLabelPaint(Color.red); axis2.setTickLabelPaint(Color.red); plot.setRangeAxis(1, axis2); plot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_LEFT); XYDataset dataset2 = createDataset("Series 2", 1000.0, new Minute(), 170); plot.setDataset(1, dataset2); plot.mapDatasetToRangeAxis(1, 1); XYItemRenderer renderer2 = new StandardXYItemRenderer(); renderer2.setSeriesPaint(0, Color.red); plot.setRenderer(1, renderer2); // AXIS 3 NumberAxis axis3 = new NumberAxis("Range Axis 3"); axis3.setLabelPaint(Color.blue); axis3.setTickLabelPaint(Color.blue); //axis3.setPositiveArrowVisible(true); plot.setRangeAxis(2, axis3); XYDataset dataset3 = createDataset("Series 3", 10000.0, new Minute(), 170); plot.setDataset(2, dataset3); plot.mapDatasetToRangeAxis(2, 2); XYItemRenderer renderer3 = new StandardXYItemRenderer(); renderer3.setSeriesPaint(0, Color.blue); plot.setRenderer(2, renderer3); // AXIS 4 NumberAxis axis4 = new NumberAxis("Range Axis 4"); axis4.setLabelPaint(Color.green); axis4.setTickLabelPaint(Color.green); plot.setRangeAxis(3, axis4); XYDataset dataset4 = createDataset("Series 4", 25.0, new Minute(), 200); plot.setDataset(3, dataset4); plot.mapDatasetToRangeAxis(3, 3); XYItemRenderer renderer4 = new StandardXYItemRenderer(); renderer4.setSeriesPaint(0, Color.green); plot.setRenderer(3, renderer4); return chart; }
Example 19
Source File: Chart.java From freeacs with MIT License | 4 votes |
/** * All params can be null. * * @param min - the minimum number on the left range axis (must be set if max is set) * @param max - the maximum number on the left range axis (must be set if min is set) * @param method2 - the method to run out of Record, and populates a bar series (right range axis) * @param highLightIndex - the index to highlight * @return * @throws Exception */ public JFreeChart makeTimeChart(Double min, Double max, String method2, Integer highLightIndex) throws Exception { startTms = System.currentTimeMillis(); endTms = 0; XYBarRenderer.setDefaultShadowsVisible(false); TimeSeriesCollection data = new TimeSeriesCollection(); Map<String, TimeSeries> timeSeriesMap = makeTimeSeriesMap(method, recordMap, keyNames); for (TimeSeries timeSeries : timeSeriesMap.values()) { data.addSeries(timeSeries); } String yAxisLabel = method; String denominator = Record.getDenominator(report.getRecordClass(), method.toLowerCase()); if (denominator != null) { yAxisLabel += " (" + denominator + ")"; } chart = ChartFactory.createTimeSeriesChart(title, "Time", yAxisLabel, data, true, true, true); XYPlot plot = (XYPlot) chart.getPlot(); if (method2 != null) { Map<Key, R> recordMap2 = recordMap; TimeSeriesCollection data2 = new TimeSeriesCollection(); if (keyNames.length > 0) { recordMap2 = report.getMapAggregatedOn(); } Map<String, TimeSeries> timeSeriesMap2 = makeTimeSeriesMap(method2, recordMap2); if (timeSeriesMap2.get("Total (" + method2 + ")") != null) { data2.addSeries(timeSeriesMap2.get("Total (" + method2 + ")")); } String y2AxisLabel = method2; String demoninator2 = Record.getDenominator(report.getRecordClass(), method2.toLowerCase()); if (demoninator2 != null) { y2AxisLabel += " (" + demoninator2 + ")"; } NumberAxis axis2 = new NumberAxis(y2AxisLabel); XYBarRenderer renderer2 = new XYBarRenderer(0.20); plot.setRangeAxis(1, axis2); plot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_RIGHT); plot.setDataset(1, data2); plot.setRenderer(1, renderer2); plot.mapDatasetToRangeAxis(1, 1); renderer2.setBarPainter(new StandardXYBarPainter()); plot.setDatasetRenderingOrder(DatasetRenderingOrder.REVERSE); } if (min != null && max != null) { plot.getRangeAxis(0).setRange(min, max); } if (highLightIndex != null) { chart.getXYPlot().getRenderer().setSeriesStroke(highLightIndex, new BasicStroke(5f)); } XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); renderer.setDefaultShapesVisible(true); renderer.setUseFillPaint(true); renderer.setDefaultFillPaint(Color.white); long diff = endTms - startTms; String format; if (diff > NINTY_DAYS) { format = "MMM-yyyy"; } else if (diff > TWO_DAYS) { format = "dd-MMM"; } else if (diff > TWO_MINUTES) { format = "HH:mm"; } else { format = "HH:mm:ss"; } DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat(format)); LegendTitle lt = chart.getLegend(0); lt.setPosition(RectangleEdge.RIGHT); if (displayFrame) { ChartFrame frame = new ChartFrame(title, chart); frame.pack(); frame.setVisible(true); } return chart; }
Example 20
Source File: SWTMultipleAxisDemo1.java From openstock with GNU General Public License v3.0 | 4 votes |
/** * Creates the demo chart. * * @return The chart. */ private static JFreeChart createChart() { XYDataset dataset1 = createDataset("Series 1", 100.0, new Minute(), 200); JFreeChart chart = ChartFactory.createTimeSeriesChart( "Multiple Axis Demo 3", "Time of Day", "Primary Range Axis", dataset1, true, true, false ); chart.setBackgroundPaint(Color.white); chart.setBorderVisible(true); chart.setBorderPaint(Color.BLACK); TextTitle subtitle = new TextTitle("Four datasets and four range axes."); chart.addSubtitle(subtitle); XYPlot plot = (XYPlot) chart.getPlot(); plot.setOrientation(PlotOrientation.VERTICAL); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); XYItemRenderer renderer = plot.getRenderer(); renderer.setSeriesPaint(0, Color.black); // AXIS 2 NumberAxis axis2 = new NumberAxis("Range Axis 2"); axis2.setAutoRangeIncludesZero(false); axis2.setLabelPaint(Color.red); axis2.setTickLabelPaint(Color.red); plot.setRangeAxis(1, axis2); plot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_LEFT); XYDataset dataset2 = createDataset("Series 2", 1000.0, new Minute(), 170); plot.setDataset(1, dataset2); plot.mapDatasetToRangeAxis(1, 1); XYItemRenderer renderer2 = new StandardXYItemRenderer(); renderer2.setSeriesPaint(0, Color.red); plot.setRenderer(1, renderer2); // AXIS 3 NumberAxis axis3 = new NumberAxis("Range Axis 3"); axis3.setLabelPaint(Color.blue); axis3.setTickLabelPaint(Color.blue); //axis3.setPositiveArrowVisible(true); plot.setRangeAxis(2, axis3); XYDataset dataset3 = createDataset("Series 3", 10000.0, new Minute(), 170); plot.setDataset(2, dataset3); plot.mapDatasetToRangeAxis(2, 2); XYItemRenderer renderer3 = new StandardXYItemRenderer(); renderer3.setSeriesPaint(0, Color.blue); plot.setRenderer(2, renderer3); // AXIS 4 NumberAxis axis4 = new NumberAxis("Range Axis 4"); axis4.setLabelPaint(Color.green); axis4.setTickLabelPaint(Color.green); plot.setRangeAxis(3, axis4); XYDataset dataset4 = createDataset("Series 4", 25.0, new Minute(), 200); plot.setDataset(3, dataset4); plot.mapDatasetToRangeAxis(3, 3); XYItemRenderer renderer4 = new StandardXYItemRenderer(); renderer4.setSeriesPaint(0, Color.green); plot.setRenderer(3, renderer4); return chart; }