Java Code Examples for org.jfree.chart.plot.XYPlot#setDomainGridlinePaint()
The following examples show how to use
org.jfree.chart.plot.XYPlot#setDomainGridlinePaint() .
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: ChartViewerUtil.java From cst with GNU Lesser General Public License v3.0 | 6 votes |
public static synchronized ChartPanel createLineXYChart(XYSeriesCollection dataset, String title, String categoryAxisLabel, String valueAxisLabel, long timeRefresh) { final JFreeChart chart = ChartFactory.createXYLineChart(title, categoryAxisLabel, valueAxisLabel, dataset, PlotOrientation.VERTICAL, true, true, false); final XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.getDomainAxis().setFixedAutoRange(timeRefresh * 100); chart.setBackgroundPaint(Color.lightGray); ChartPanel localChartPanel = new ChartPanel(chart); localChartPanel.setVisible(true); localChartPanel.setDomainZoomable(true); return localChartPanel; }
Example 2
Source File: HistogramChartFactory.java From mzmine2 with GNU General Public License v2.0 | 6 votes |
public static JFreeChart createHistogram(XYSeries series, double barwidth, String yAxisLabel) { XYSeriesCollection xydata = new XYSeriesCollection(series); XYBarDataset dataset = new XYBarDataset(xydata, barwidth); JFreeChart chart = ChartFactory.createXYBarChart("", yAxisLabel, false, "n", dataset, PlotOrientation.VERTICAL, true, true, false); XYPlot xyplot = chart.getXYPlot(); chart.setBackgroundPaint(new Color(230, 230, 230)); chart.getLegend().setVisible(false); xyplot.setForegroundAlpha(0.7F); xyplot.setBackgroundPaint(Color.WHITE); xyplot.setDomainGridlinePaint(new Color(150, 150, 150)); xyplot.setRangeGridlinePaint(new Color(150, 150, 150)); xyplot.getDomainAxis().setVisible(true); xyplot.getRangeAxis().setVisible(yAxisLabel != null); XYBarRenderer xybarrenderer = (XYBarRenderer) xyplot.getRenderer(); xybarrenderer.setShadowVisible(false); xybarrenderer.setBarPainter(new StandardXYBarPainter()); xybarrenderer.setDrawBarOutline(false); return chart; }
Example 3
Source File: HistogramChartFactory.java From old-mzmine3 with GNU General Public License v2.0 | 6 votes |
public static JFreeChart createHistogram(XYSeries series, double barwidth, String yAxisLabel) { XYSeriesCollection xydata = new XYSeriesCollection(series); XYBarDataset dataset = new XYBarDataset(xydata, barwidth); JFreeChart chart = ChartFactory.createXYBarChart("", yAxisLabel, false, "n", dataset, PlotOrientation.VERTICAL, true, true, false); XYPlot xyplot = chart.getXYPlot(); chart.setBackgroundPaint(new Color(230, 230, 230)); chart.getLegend().setVisible(false); xyplot.setForegroundAlpha(0.7F); xyplot.setBackgroundPaint(Color.WHITE); xyplot.setDomainGridlinePaint(new Color(150, 150, 150)); xyplot.setRangeGridlinePaint(new Color(150, 150, 150)); xyplot.getDomainAxis().setVisible(true); xyplot.getRangeAxis().setVisible(yAxisLabel != null); XYBarRenderer xybarrenderer = (XYBarRenderer) xyplot.getRenderer(); xybarrenderer.setShadowVisible(false); xybarrenderer.setBarPainter(new StandardXYBarPainter()); xybarrenderer.setDrawBarOutline(false); return chart; }
Example 4
Source File: Grafico.java From cst with GNU Lesser General Public License v3.0 | 6 votes |
public Grafico(String frametitle, String charttitle, String xlabel, String ylabel, XYSeriesCollection dataset){ JFreeChart chart = ChartFactory.createXYLineChart(charttitle, xlabel, ylabel, dataset, PlotOrientation.VERTICAL, true, true, false); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); renderer.setShapesVisible(true); renderer.setShapesFilled(true); setXyplot(plot); setChart(chart); ChartFrame frame= new ChartFrame(frametitle,chart); frame.pack(); frame.setVisible(true); }
Example 5
Source File: HistogramChartFactory.java From mzmine2 with GNU General Public License v2.0 | 6 votes |
public static JFreeChart createHistogramOld(double[] data, int bin, String yAxisLabel, double min, double max) { if (data != null && data.length > 0) { HistogramDataset dataset = new HistogramDataset(); dataset.addSeries("histo", data, bin, min, max); JFreeChart chart = ChartFactory.createHistogram("", yAxisLabel, "n", dataset, PlotOrientation.VERTICAL, true, false, false); chart.setBackgroundPaint(new Color(230, 230, 230)); chart.getLegend().setVisible(false); XYPlot xyplot = chart.getXYPlot(); xyplot.setForegroundAlpha(0.7F); xyplot.setBackgroundPaint(Color.WHITE); xyplot.setDomainGridlinePaint(new Color(150, 150, 150)); xyplot.setRangeGridlinePaint(new Color(150, 150, 150)); xyplot.getDomainAxis().setVisible(true); xyplot.getRangeAxis().setVisible(yAxisLabel != null); XYBarRenderer xybarrenderer = (XYBarRenderer) xyplot.getRenderer(); xybarrenderer.setShadowVisible(false); xybarrenderer.setBarPainter(new StandardXYBarPainter()); // xybarrenderer.setDrawBarOutline(false); return chart; } else return null; }
Example 6
Source File: TradeMonitorGui.java From hazelcast-jet-training with Apache License 2.0 | 6 votes |
private XYPlot createChartFrame(XYDataset dataset) { JFreeChart chart = ChartFactory.createTimeSeriesChart( "Average Stock Price over 1 minute", "Time", "Price in USD", dataset, true, true, false ); XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(new Color(245, 245, 245)); plot.setDomainGridlinePaint(Color.BLACK); plot.setRangeGridlinePaint(Color.BLACK); final JFrame frame = new JFrame(); frame.setBackground(Color.WHITE); frame.setDefaultCloseOperation(EXIT_ON_CLOSE); frame.setTitle("Trade Monitor"); frame.setBounds(WINDOW_X, WINDOW_Y, WINDOW_WIDTH, WINDOW_HEIGHT); frame.setLayout(new BorderLayout()); frame.add(new ChartPanel(chart)); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent windowEvent) { avgPrices.removeEntryListener(listenerId); } }); frame.setVisible(true); return plot; }
Example 7
Source File: SWTTimeSeriesDemo.java From SIMVA-SoS with Apache License 2.0 | 5 votes |
/** * Creates a chart. * * @param dataset a dataset. * * @return A chart. */ private static JFreeChart createChart(XYDataset dataset) { JFreeChart chart = ChartFactory.createTimeSeriesChart( "Legal & General Unit Trust Prices", // 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); XYItemRenderer r = plot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); } DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy")); return chart; }
Example 8
Source File: TimeSeriesChartDemo1.java From buffer_bci with GNU General Public License v3.0 | 5 votes |
/** * Creates a chart. * * @param dataset a dataset. * * @return A chart. */ private static JFreeChart createChart(XYDataset dataset) { JFreeChart chart = ChartFactory.createTimeSeriesChart( "Legal & General Unit Trust Prices", // 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); XYItemRenderer r = plot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); renderer.setDrawSeriesLineAsPath(true); } DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy")); return chart; }
Example 9
Source File: EyeCandySixtiesChartTheme.java From jasperreports with GNU Lesser General Public License v3.0 | 5 votes |
@Override protected JFreeChart createScatterChart() throws JRException { JFreeChart jfreeChart = super.createScatterChart(); XYPlot xyPlot = (XYPlot) jfreeChart.getPlot(); xyPlot.setRangeGridlinePaint(SCATTER_GRIDLINE_COLOR); xyPlot.setRangeGridlineStroke(new BasicStroke(0.75f)); xyPlot.setDomainGridlinesVisible(true); xyPlot.setDomainGridlinePaint(SCATTER_GRIDLINE_COLOR); xyPlot.setDomainGridlineStroke(new BasicStroke(0.75f)); xyPlot.setRangeZeroBaselinePaint(ChartThemesConstants.GRAY_PAINT_134); XYLineAndShapeRenderer lineRenderer = (XYLineAndShapeRenderer)xyPlot.getRenderer(); lineRenderer.setUseFillPaint(true); JRScatterPlot scatterPlot = (JRScatterPlot) getPlot(); boolean isShowLines = scatterPlot.getShowLines() == null ? false : scatterPlot.getShowLines(); lineRenderer.setBaseLinesVisible(isShowLines); XYDataset xyDataset = xyPlot.getDataset(); if (xyDataset != null) { for (int i = 0; i < xyDataset.getSeriesCount(); i++) { lineRenderer.setSeriesOutlinePaint(i, ChartThemesConstants.TRANSPARENT_PAINT); lineRenderer.setSeriesFillPaint(i, ChartThemesConstants.EYE_CANDY_SIXTIES_GRADIENT_PAINTS.get(i)); lineRenderer.setSeriesPaint(i, ChartThemesConstants.EYE_CANDY_SIXTIES_COLORS.get(i)); //lineRenderer.setSeriesShape(i, new Ellipse2D.Double(-3, -3, 6, 6)); } } return jfreeChart; }
Example 10
Source File: frmEditCurve.java From Course_Generator with GNU General Public License v3.0 | 5 votes |
/** * Creates the chart * * @param dataset Dataset to display * @return Return a JFreeChart object */ private JFreeChart CreateChartProfile(XYDataset dataset) { JFreeChart chart = ChartFactory.createXYAreaChart("", bundle.getString("frmEditCurve.chart.slope"), // "Slope" x // axis // label bundle.getString("frmEditCurve.chart.speed") + " (" + Utils.uSpeed2String(settings.Unit, settings.isPace) + ")", // "speed" y axis label dataset, // data PlotOrientation.VERTICAL, false, // include legend true, // tooltips false // urls ); chart.setBackgroundPaint(Color.white); // Panel background color XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.gray); plot.setRangeGridlinePaint(Color.gray); // XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); XYAreaRenderer renderer = new XYAreaRenderer(); // Green (safe color) renderer.setSeriesPaint(0, new Color(0x99, 0xff, 0x00)); renderer.setOutline(true); // Width of the outline renderer.setSeriesOutlineStroke(0, new BasicStroke(2.0f)); plot.setRenderer(renderer); // NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); // rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); return chart; }
Example 11
Source File: TimeSeriesChartDemo1.java From ECG-Viewer with GNU General Public License v2.0 | 5 votes |
/** * Creates a chart. * * @param dataset a dataset. * * @return A chart. */ private static JFreeChart createChart(XYDataset dataset) { JFreeChart chart = ChartFactory.createTimeSeriesChart( "Legal & General Unit Trust Prices", // 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); XYItemRenderer r = plot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); renderer.setDrawSeriesLineAsPath(true); } DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy")); return chart; }
Example 12
Source File: DSWorkbenchStatsFrame.java From dsworkbench with Apache License 2.0 | 5 votes |
private void setupPlotDrawing(XYPlot pPlot) { pPlot.setBackgroundPaint(Constants.DS_BACK_LIGHT); pPlot.setDomainGridlinePaint(Color.DARK_GRAY); pPlot.setRangeGridlinePaint(Color.DARK_GRAY); pPlot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); pPlot.setDomainCrosshairVisible(true); pPlot.setRangeCrosshairVisible(true); DateAxis axis = (DateAxis) pPlot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("dd.MM.yyyy HH:mm:ss")); }
Example 13
Source File: ObdDataPlotter.java From AndrOBD with GNU General Public License v3.0 | 5 votes |
/** * Creates a chart. * * @param dataset a dataset. * @return A chart. */ private JFreeChart createChart(XYDataset dataset) { chart = ChartFactory.createTimeSeriesChart( "OBD Data Graph", // title "Time", // x-axis label "Value", // 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.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); plot.getDomainAxis().setTickLabelFont(legendFont); DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("HH:mm:ss")); chart.getLegend().setItemFont(legendFont); return chart; }
Example 14
Source File: WinrateHistogramDialog.java From mylizzie with GNU General Public License v3.0 | 4 votes |
private void initCustomComponents() { WinrateHistogramTableModel winrateHistogramTableModel = new WinrateHistogramTableModel(tableWinrateHistory); tableWinrateHistory.setModel(winrateHistogramTableModel); XYSeries blackSeries = new XYSeries("Black"); XYSeries whiteSeries = new XYSeries("White"); XYSeries standardSeries = new XYSeries("50%"); for (int i = 0; i <= 50; ++i) { standardSeries.add(i, 50); } dataSet = new XYSeriesCollection(); dataSet.addSeries(blackSeries); dataSet.addSeries(whiteSeries); dataSet.addSeries(standardSeries); JFreeChart chart = ChartFactory.createXYLineChart( "", // chart title "", // x axis label "Win%", // y axis label dataSet, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls ); chart.setBackgroundPaint(Color.WHITE); // get a reference to the plot for further customisation... XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setDomainGridlinePaint(Color.LIGHT_GRAY); plot.setRangeGridlinePaint(Color.LIGHT_GRAY); NumberAxis range = (NumberAxis) plot.getRangeAxis(); range.setRange(0.0, 100.0); histogramChartPanel = new ChartPanel(chart); panelWinrateHistogram.add(histogramChartPanel); winrateHistogramTableModel.setRefreshObserver(new Consumer<WinrateHistogramTableModel>() { private long lastRefreshTime = System.currentTimeMillis(); @Override public void accept(WinrateHistogramTableModel model) { long currentTime = System.currentTimeMillis(); if (currentTime - lastRefreshTime < 250L) { return; } lastRefreshTime = currentTime; SwingUtilities.invokeLater(() -> { blackSeries.clear(); whiteSeries.clear(); standardSeries.clear(); for (int i = 0; i < model.getHistogramEntryList().size(); ++i) { WinrateHistogramEntry entry = model.getHistogramEntryList().get(i); standardSeries.add(entry.getMoveNumber(), 50); if (checkBoxHistogramShowBlack.isSelected()) { blackSeries.add(entry.getMoveNumber(), entry.getBlackWinrate()); } if (checkBoxHistogramShowWhite.isSelected()) { whiteSeries.add(entry.getMoveNumber(), entry.getWhiteWinrate()); } } if (model.getHistogramEntryList().size() < 50) { for (int i = model.getHistogramEntryList().size() - 1; i <= 50; ++i) { standardSeries.add(i, 50); } } histogramChartPanel.repaint(); }); } }); setPreferredSize(new Dimension( Lizzie.optionSetting.getWinrateHistogramWindowState().getWidth() , Lizzie.optionSetting.getWinrateHistogramWindowState().getHeight() )); splitPaneHistogram.setDividerLocation(0.3); pack(); histogramChartPanel.setPreferredSize(new Dimension(panelWinrateHistogram.getWidth(), panelWinrateHistogram.getHeight())); histogramChartPanel.setSize(panelWinrateHistogram.getWidth(), panelWinrateHistogram.getHeight()); pack(); }
Example 15
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 16
Source File: CombinedXYPlotDemo1.java From ECG-Viewer with GNU General Public License v2.0 | 4 votes |
/** * Creates an overlaid chart. * * @return The chart. */ private static JFreeChart createCombinedChart() { // create plot ... IntervalXYDataset data1 = createDataset1(); XYItemRenderer renderer1 = new XYLineAndShapeRenderer(true, false); renderer1.setBaseToolTipGenerator(new StandardXYToolTipGenerator( StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT, new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("0.00"))); renderer1.setSeriesStroke(0, new BasicStroke(4.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL)); renderer1.setSeriesPaint(0, Color.blue); DateAxis domainAxis = new DateAxis("Year"); domainAxis.setLowerMargin(0.0); domainAxis.setUpperMargin(0.02); ValueAxis rangeAxis = new NumberAxis("$billion"); XYPlot plot1 = new XYPlot(data1, null, rangeAxis, renderer1); plot1.setBackgroundPaint(Color.lightGray); plot1.setDomainGridlinePaint(Color.white); plot1.setRangeGridlinePaint(Color.white); // add a second dataset and renderer... IntervalXYDataset data2 = createDataset2(); XYBarRenderer renderer2 = new XYBarRenderer() { public Paint getItemPaint(int series, int item) { XYDataset dataset = getPlot().getDataset(); if (dataset.getYValue(series, item) >= 0.0) { return Color.red; } else { return Color.green; } } }; renderer2.setSeriesPaint(0, Color.red); renderer2.setDrawBarOutline(false); renderer2.setBaseToolTipGenerator(new StandardXYToolTipGenerator( StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT, new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("0.00"))); XYPlot plot2 = new XYPlot(data2, null, new NumberAxis("$billion"), renderer2); plot2.setBackgroundPaint(Color.lightGray); plot2.setDomainGridlinePaint(Color.white); plot2.setRangeGridlinePaint(Color.white); CombinedXYPlot cplot = new CombinedXYPlot(domainAxis, rangeAxis); cplot.add(plot1, 3); cplot.add(plot2, 2); cplot.setGap(8.0); cplot.setDomainGridlinePaint(Color.white); cplot.setDomainGridlinesVisible(true); // return a new chart containing the overlaid plot... JFreeChart chart = new JFreeChart("CombinedXYPlotDemo1", JFreeChart.DEFAULT_TITLE_FONT, cplot, false); chart.setBackgroundPaint(Color.white); LegendTitle legend = new LegendTitle(cplot); chart.addSubtitle(legend); return chart; }
Example 17
Source File: ChartJFreeChartOutputScatter.java From gama with GNU General Public License v3.0 | 4 votes |
@Override public void initChart(final IScope scope, final String chartname) { super.initChart(scope, chartname); final XYPlot pp = (XYPlot) chart.getPlot(); pp.setDomainGridlinePaint(axesColor); pp.setRangeGridlinePaint(axesColor); pp.setDomainCrosshairPaint(axesColor); pp.setRangeCrosshairPaint(axesColor); pp.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); pp.setDomainCrosshairVisible(false); pp.setRangeCrosshairVisible(false); pp.getDomainAxis().setAxisLinePaint(axesColor); pp.getDomainAxis().setTickLabelFont(getTickFont()); pp.getDomainAxis().setLabelFont(getLabelFont()); if (textColor != null) { pp.getDomainAxis().setLabelPaint(textColor); pp.getDomainAxis().setTickLabelPaint(textColor); } NumberAxis axis = (NumberAxis) pp.getRangeAxis(); axis = formatYAxis(scope, axis); pp.setRangeAxis(axis); if (ytickunit > 0) { ((NumberAxis) pp.getRangeAxis()).setTickUnit(new NumberTickUnit(ytickunit)); pp.setRangeGridlinesVisible(true); } else { pp.setRangeGridlinesVisible(GamaPreferences.Displays.CHART_GRIDLINES.getValue()); } // resetAutorange(scope); if (getType() == ChartOutput.SERIES_CHART) { if (xlabel == null) { xlabel = "time"; } } if (getType() == ChartOutput.XY_CHART) {} if (getType() == ChartOutput.SCATTER_CHART) {} if (!this.getXTickValueVisible(scope)) { pp.getDomainAxis().setTickMarksVisible(false); pp.getDomainAxis().setTickLabelsVisible(false); } }
Example 18
Source File: SimpleChartTheme.java From jasperreports with GNU Lesser General Public License v3.0 | 4 votes |
protected void handleXYPlotSettings(XYPlot p, JRChartPlot jrPlot) { PlotSettings plotSettings = getPlotSettings(); XYItemRenderer xyItemRenderer = p.getRenderer(); Paint[] paintSequence = getPaintSequence(plotSettings, jrPlot); if (paintSequence != null) { for (int i = 0; i < paintSequence.length; i++) { xyItemRenderer.setSeriesPaint(i, paintSequence[i]); } } Paint[] outlinePaintSequence = getOutlinePaintSequence(plotSettings); if (outlinePaintSequence != null) { for (int i = 0; i < outlinePaintSequence.length; i++) { xyItemRenderer.setSeriesOutlinePaint(i, outlinePaintSequence[i]); } } Stroke[] strokeSequence = getStrokeSequence(plotSettings); if (strokeSequence != null) { for (int i = 0; i < strokeSequence.length; i++) { xyItemRenderer.setSeriesStroke(i, strokeSequence[i]); } } Stroke[] outlineStrokeSequence = getOutlineStrokeSequence(plotSettings); if (outlineStrokeSequence != null) { for (int i = 0; i < outlineStrokeSequence.length; i++) { xyItemRenderer.setSeriesOutlineStroke(i, outlineStrokeSequence[i]); } } Boolean domainGridlineVisible = plotSettings.getDomainGridlineVisible(); if (domainGridlineVisible == null || domainGridlineVisible) { PaintProvider domainGridlinePaint = plotSettings.getDomainGridlinePaint(); if (domainGridlinePaint != null) { p.setDomainGridlinePaint(domainGridlinePaint.getPaint()); } Stroke domainGridlineStroke = plotSettings.getDomainGridlineStroke(); if (domainGridlineStroke != null) { p.setDomainGridlineStroke(domainGridlineStroke); } } Boolean rangeGridlineVisible = plotSettings.getRangeGridlineVisible(); if (rangeGridlineVisible == null || rangeGridlineVisible) { PaintProvider rangeGridlinePaint = plotSettings.getRangeGridlinePaint(); if (rangeGridlinePaint != null) { p.setRangeGridlinePaint(rangeGridlinePaint.getPaint()); } Stroke rangeGridlineStroke = plotSettings.getRangeGridlineStroke(); if (rangeGridlineStroke != null) { p.setRangeGridlineStroke(rangeGridlineStroke); } } // p.setRangeZeroBaselineVisible(true); }
Example 19
Source File: CombinedXYPlotDemo1.java From SIMVA-SoS with Apache License 2.0 | 4 votes |
/** * Creates an overlaid chart. * * @return The chart. */ private static JFreeChart createCombinedChart() { // create plot ... IntervalXYDataset data1 = createDataset1(); XYItemRenderer renderer1 = new XYLineAndShapeRenderer(true, false); renderer1.setBaseToolTipGenerator(new StandardXYToolTipGenerator( StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT, new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("0.00"))); renderer1.setSeriesStroke(0, new BasicStroke(4.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL)); renderer1.setSeriesPaint(0, Color.blue); DateAxis domainAxis = new DateAxis("Year"); domainAxis.setLowerMargin(0.0); domainAxis.setUpperMargin(0.02); ValueAxis rangeAxis = new NumberAxis("$billion"); XYPlot plot1 = new XYPlot(data1, null, rangeAxis, renderer1); plot1.setBackgroundPaint(Color.lightGray); plot1.setDomainGridlinePaint(Color.white); plot1.setRangeGridlinePaint(Color.white); // add a second dataset and renderer... IntervalXYDataset data2 = createDataset2(); XYBarRenderer renderer2 = new XYBarRenderer() { public Paint getItemPaint(int series, int item) { XYDataset dataset = getPlot().getDataset(); if (dataset.getYValue(series, item) >= 0.0) { return Color.red; } else { return Color.green; } } }; renderer2.setSeriesPaint(0, Color.red); renderer2.setDrawBarOutline(false); renderer2.setBaseToolTipGenerator(new StandardXYToolTipGenerator( StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT, new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("0.00"))); XYPlot plot2 = new XYPlot(data2, null, new NumberAxis("$billion"), renderer2); plot2.setBackgroundPaint(Color.lightGray); plot2.setDomainGridlinePaint(Color.white); plot2.setRangeGridlinePaint(Color.white); CombinedXYPlot cplot = new CombinedXYPlot(domainAxis, rangeAxis); cplot.add(plot1, 3); cplot.add(plot2, 2); cplot.setGap(8.0); cplot.setDomainGridlinePaint(Color.white); cplot.setDomainGridlinesVisible(true); // return a new chart containing the overlaid plot... JFreeChart chart = new JFreeChart("CombinedXYPlotDemo1", JFreeChart.DEFAULT_TITLE_FONT, cplot, false); chart.setBackgroundPaint(Color.white); LegendTitle legend = new LegendTitle(cplot); chart.addSubtitle(legend); return chart; }
Example 20
Source File: CombinedXYPlotDemo1.java From openstock with GNU General Public License v3.0 | 4 votes |
/** * Creates an overlaid chart. * * @return The chart. */ private static JFreeChart createCombinedChart() { // create plot ... IntervalXYDataset data1 = createDataset1(); XYItemRenderer renderer1 = new XYLineAndShapeRenderer(true, false); renderer1.setBaseToolTipGenerator(new StandardXYToolTipGenerator( StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT, new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("0.00"))); renderer1.setSeriesStroke(0, new BasicStroke(4.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL)); renderer1.setSeriesPaint(0, Color.blue); DateAxis domainAxis = new DateAxis("Year"); domainAxis.setLowerMargin(0.0); domainAxis.setUpperMargin(0.02); ValueAxis rangeAxis = new NumberAxis("$billion"); XYPlot plot1 = new XYPlot(data1, null, rangeAxis, renderer1); plot1.setBackgroundPaint(Color.lightGray); plot1.setDomainGridlinePaint(Color.white); plot1.setRangeGridlinePaint(Color.white); // add a second dataset and renderer... IntervalXYDataset data2 = createDataset2(); XYBarRenderer renderer2 = new XYBarRenderer() { public Paint getItemPaint(int series, int item) { XYDataset dataset = getPlot().getDataset(); if (dataset.getYValue(series, item) >= 0.0) { return Color.red; } else { return Color.green; } } }; renderer2.setSeriesPaint(0, Color.red); renderer2.setDrawBarOutline(false); renderer2.setBaseToolTipGenerator(new StandardXYToolTipGenerator( StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT, new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("0.00"))); XYPlot plot2 = new XYPlot(data2, null, new NumberAxis("$billion"), renderer2); plot2.setBackgroundPaint(Color.lightGray); plot2.setDomainGridlinePaint(Color.white); plot2.setRangeGridlinePaint(Color.white); CombinedXYPlot cplot = new CombinedXYPlot(domainAxis, rangeAxis); cplot.add(plot1, 3); cplot.add(plot2, 2); cplot.setGap(8.0); cplot.setDomainGridlinePaint(Color.white); cplot.setDomainGridlinesVisible(true); // return a new chart containing the overlaid plot... JFreeChart chart = new JFreeChart("CombinedXYPlotDemo1", JFreeChart.DEFAULT_TITLE_FONT, cplot, false); chart.setBackgroundPaint(Color.white); LegendTitle legend = new LegendTitle(cplot); chart.addSubtitle(legend); return chart; }