List of usage examples for org.jfree.chart JFreeChart getXYPlot
public XYPlot getXYPlot()
From source file:net.sf.dynamicreports.design.transformation.chartcustomizer.DifferenceRendererCustomizer.java
@Override public void customize(JFreeChart chart, ReportParameters reportParameters) { XYLineAndShapeRenderer lineRenderer = (XYLineAndShapeRenderer) chart.getXYPlot().getRenderer(); XYDifferenceRenderer renderer = new XYDifferenceRenderer(); renderer.setBaseItemLabelsVisible(lineRenderer.getBaseItemLabelsVisible()); renderer.setBaseItemLabelFont(lineRenderer.getBaseItemLabelFont()); renderer.setBaseItemLabelPaint(lineRenderer.getBaseItemLabelPaint()); renderer.setBaseItemLabelGenerator(lineRenderer.getBaseItemLabelGenerator()); if (positiveColor != null) { renderer.setPositivePaint(positiveColor); }// ww w . j a va 2 s. c om if (negativeColor != null) { renderer.setNegativePaint(negativeColor); } if (showShapes != null) { renderer.setShapesVisible(showShapes); } chart.getXYPlot().setRenderer(renderer); }
From source file:net.sourceforge.processdash.ui.web.reports.XYChart.java
@Override protected Axis getAxis(JFreeChart chart, PlotOrientation dir) { try {// www . j a va 2 s . c o m XYPlot p = chart.getXYPlot(); if (dir.equals(p.getOrientation())) return p.getRangeAxis(); else return p.getDomainAxis(); } catch (Exception e) { return null; } }
From source file:net.sf.dynamicreports.test.jasper.chart.XyBarChartTest.java
@Override public void test() { super.test(); numberOfPagesTest(1);/*from w ww. j a v a 2 s . c o m*/ JFreeChart chart = getChart("summary.chart1", 0); XYPlot plot = chart.getXYPlot(); Assert.assertEquals("renderer", XYBarRenderer.class, plot.getRenderer().getClass()); Assert.assertTrue("show labels", plot.getRenderer().getBaseItemLabelsVisible()); //Assert.assertFalse("show tick labels", plot.getDomainAxis().isTickMarksVisible()); //Assert.assertFalse("show tick marks", plot.getDomainAxis().isTickLabelsVisible()); chart = getChart("summary.chart2", 0); Axis axis = chart.getXYPlot().getDomainAxis(); Assert.assertEquals("category label", "category", axis.getLabel()); Assert.assertEquals("category label color", Color.BLUE, axis.getLabelPaint()); Assert.assertEquals("category label font", new Font("Arial", Font.BOLD, 10), axis.getLabelFont()); Assert.assertEquals("tick label color", Color.CYAN, axis.getTickLabelPaint()); Assert.assertEquals("tick label font", new Font("Arial", Font.ITALIC, 10), axis.getTickLabelFont()); Assert.assertEquals("line color", Color.LIGHT_GRAY, axis.getAxisLinePaint()); chart = getChart("summary.chart3", 0); axis = chart.getXYPlot().getRangeAxis(); Assert.assertEquals("value label", "value", axis.getLabel()); Assert.assertEquals("value label color", Color.BLUE, axis.getLabelPaint()); Assert.assertEquals("value label font", new Font("Arial", Font.BOLD, 10), axis.getLabelFont()); Assert.assertEquals("tick label color", Color.CYAN, axis.getTickLabelPaint()); Assert.assertEquals("tick label font", new Font("Arial", Font.ITALIC, 10), axis.getTickLabelFont()); Assert.assertEquals("tick label mask", "10.00", ((NumberAxis) axis).getNumberFormatOverride().format(10)); Assert.assertEquals("line color", Color.LIGHT_GRAY, axis.getAxisLinePaint()); Assert.assertEquals("range min value", 1d, ((ValueAxis) axis).getLowerBound()); Assert.assertEquals("range max value", 15d, ((ValueAxis) axis).getUpperBound()); }
From source file:com.od.jtimeseries.ui.visualizer.chart.creator.AbstractXYChartCreator.java
private JFreeChart createChart() { final JFreeChart chart = buildChart(); chart.getXYPlot().setDomainAxis(new DateAxis()); DateAxis dateAxis = (DateAxis) chart.getXYPlot().getDomainAxis(); dateAxis.setDateFormatOverride(dateFormat); return chart; }
From source file:net.sf.dynamicreports.test.jasper.chart.XyStepChartTest.java
@Override public void test() { super.test(); numberOfPagesTest(1);//from w ww. j a va 2s. co m JFreeChart chart = getChart("summary.chart1", 0); XYItemRenderer renderer = chart.getXYPlot().getRenderer(); Assert.assertEquals("renderer", XYStepRenderer.class, renderer.getClass()); Assert.assertEquals("step point", 0.5d, ((XYStepRenderer) renderer).getStepPoint()); chart = getChart("summary.chart2", 0); Axis axis = chart.getXYPlot().getDomainAxis(); Assert.assertEquals("category label", "category", axis.getLabel()); Assert.assertEquals("category label color", Color.BLUE, axis.getLabelPaint()); Assert.assertEquals("category label font", new Font("Arial", Font.BOLD, 10), axis.getLabelFont()); Assert.assertEquals("tick label color", Color.CYAN, axis.getTickLabelPaint()); Assert.assertEquals("tick label font", new Font("Arial", Font.ITALIC, 10), axis.getTickLabelFont()); Assert.assertEquals("line color", Color.LIGHT_GRAY, axis.getAxisLinePaint()); chart = getChart("summary.chart3", 0); axis = chart.getXYPlot().getRangeAxis(); Assert.assertEquals("value label", "value", axis.getLabel()); Assert.assertEquals("value label color", Color.BLUE, axis.getLabelPaint()); Assert.assertEquals("value label font", new Font("Arial", Font.BOLD, 10), axis.getLabelFont()); Assert.assertEquals("tick label color", Color.CYAN, axis.getTickLabelPaint()); Assert.assertEquals("tick label font", new Font("Arial", Font.ITALIC, 10), axis.getTickLabelFont()); Assert.assertEquals("tick label mask", "10.00", ((NumberAxis) axis).getNumberFormatOverride().format(10)); Assert.assertEquals("line color", Color.LIGHT_GRAY, axis.getAxisLinePaint()); Assert.assertEquals("range min value", 1d, ((ValueAxis) axis).getLowerBound()); Assert.assertEquals("range max value", 15d, ((ValueAxis) axis).getUpperBound()); }
From source file:net.sf.dynamicreports.test.jasper.chart.ScatterChartTest.java
@Override public void test() { super.test(); numberOfPagesTest(1);//www . j a v a2 s. c o m JFreeChart chart = getChart("summary.chart1", 0); XYItemRenderer renderer = chart.getXYPlot().getRenderer(); Assert.assertEquals("renderer", XYLineAndShapeRenderer.class, renderer.getClass()); Assert.assertFalse("show shapes", ((XYLineAndShapeRenderer) renderer).getBaseShapesVisible()); Assert.assertFalse("show lines", ((XYLineAndShapeRenderer) renderer).getBaseLinesVisible()); xyChartDataTest(chart, 0, "Column2", new Number[][] { { 1d, 2d }, { 2d, 3d }, { 3d, 4d }, { 4d, 5d } }); xyChartDataTest(chart, 1, "Column1", new Number[][] { { 2d, 1d }, { 3d, 2d }, { 4d, 3d }, { 5d, 4d } }); chart = getChart("summary.chart2", 0); Axis axis = chart.getXYPlot().getDomainAxis(); Assert.assertEquals("category label", "category", axis.getLabel()); Assert.assertEquals("category label color", Color.BLUE, axis.getLabelPaint()); Assert.assertEquals("category label font", new Font("Arial", Font.BOLD, 10), axis.getLabelFont()); Assert.assertEquals("tick label color", Color.CYAN, axis.getTickLabelPaint()); Assert.assertEquals("tick label font", new Font("Arial", Font.ITALIC, 10), axis.getTickLabelFont()); Assert.assertEquals("line color", Color.LIGHT_GRAY, axis.getAxisLinePaint()); chart = getChart("summary.chart3", 0); axis = chart.getXYPlot().getRangeAxis(); Assert.assertEquals("value label", "value", axis.getLabel()); Assert.assertEquals("value label color", Color.BLUE, axis.getLabelPaint()); Assert.assertEquals("value label font", new Font("Arial", Font.BOLD, 10), axis.getLabelFont()); Assert.assertEquals("tick label color", Color.CYAN, axis.getTickLabelPaint()); Assert.assertEquals("tick label font", new Font("Arial", Font.ITALIC, 10), axis.getTickLabelFont()); Assert.assertEquals("tick label mask", "10.00", ((NumberAxis) axis).getNumberFormatOverride().format(10)); Assert.assertEquals("line color", Color.LIGHT_GRAY, axis.getAxisLinePaint()); }
From source file:net.sf.dynamicreports.test.jasper.chart.XyLineChartTest.java
@Override public void test() { super.test(); numberOfPagesTest(1);/*from ww w .j a v a 2s.c om*/ JFreeChart chart = getChart("summary.chart1", 0); XYItemRenderer renderer = chart.getXYPlot().getRenderer(); Assert.assertEquals("renderer", XYLineAndShapeRenderer.class, renderer.getClass()); Assert.assertFalse("show shapes", ((XYLineAndShapeRenderer) renderer).getBaseShapesVisible()); Assert.assertFalse("show lines", ((XYLineAndShapeRenderer) renderer).getBaseLinesVisible()); chart = getChart("summary.chart2", 0); Axis axis = chart.getXYPlot().getDomainAxis(); Assert.assertEquals("category label", "category", axis.getLabel()); Assert.assertEquals("category label color", Color.BLUE, axis.getLabelPaint()); Assert.assertEquals("category label font", new Font("Arial", Font.BOLD, 10), axis.getLabelFont()); Assert.assertEquals("tick label color", Color.CYAN, axis.getTickLabelPaint()); Assert.assertEquals("tick label font", new Font("Arial", Font.ITALIC, 10), axis.getTickLabelFont()); Assert.assertEquals("line color", Color.LIGHT_GRAY, axis.getAxisLinePaint()); chart = getChart("summary.chart3", 0); axis = chart.getXYPlot().getRangeAxis(); Assert.assertEquals("value label", "value", axis.getLabel()); Assert.assertEquals("value label color", Color.BLUE, axis.getLabelPaint()); Assert.assertEquals("value label font", new Font("Arial", Font.BOLD, 10), axis.getLabelFont()); Assert.assertEquals("tick label color", Color.CYAN, axis.getTickLabelPaint()); Assert.assertEquals("tick label font", new Font("Arial", Font.ITALIC, 10), axis.getTickLabelFont()); Assert.assertEquals("tick label mask", "10.00", ((NumberAxis) axis).getNumberFormatOverride().format(10)); Assert.assertEquals("line color", Color.LIGHT_GRAY, axis.getAxisLinePaint()); Assert.assertEquals("range min value", 1d, ((ValueAxis) axis).getLowerBound()); Assert.assertEquals("range max value", 15d, ((ValueAxis) axis).getUpperBound()); }
From source file:net.sf.dynamicreports.test.jasper.chart.MultiAxisChartTest.java
@Override public void test() { super.test(); numberOfPagesTest(1);//from w w w. j a v a 2 s. co m JFreeChart chart = getChart("summary.chart1", 0); XYItemRenderer renderer = chart.getXYPlot().getRenderer(); Assert.assertEquals("renderer", XYLineAndShapeRenderer.class, renderer.getClass()); TimeSeriesCollection dataset = (TimeSeriesCollection) chart.getXYPlot().getDataset(0); TimeSeries serie = (TimeSeries) dataset.getSeries().get(0); Assert.assertEquals("value", 1d, serie.getDataItem(0).getValue()); Assert.assertEquals("value", 2d, serie.getDataItem(1).getValue()); Assert.assertEquals("value", 3d, serie.getDataItem(2).getValue()); Assert.assertEquals("value", 4d, serie.getDataItem(3).getValue()); dataset = (TimeSeriesCollection) chart.getXYPlot().getDataset(1); serie = (TimeSeries) dataset.getSeries().get(0); Assert.assertEquals("value", 0d, serie.getDataItem(0).getValue()); Assert.assertEquals("value", 1d, serie.getDataItem(1).getValue()); Assert.assertEquals("value", 4d, serie.getDataItem(2).getValue()); Assert.assertEquals("value", 9d, serie.getDataItem(3).getValue()); JRChart chart2 = (JRChart) getJasperReport().getSummary().getElementByKey("summary.chart2"); JRChartPlot plot = chart2.getPlot(); Assert.assertTrue("plot", plot instanceof JRMultiAxisPlot); JRMultiAxisPlot multiAxisPlot = (JRMultiAxisPlot) plot; Assert.assertEquals("axes", 2, multiAxisPlot.getAxes().size()); JRChartAxis chartAxis = multiAxisPlot.getAxes().get(0); Assert.assertEquals("position", AxisPositionEnum.LEFT_OR_TOP, chartAxis.getPositionValue()); Assert.assertEquals("chart", JRChart.CHART_TYPE_TIMESERIES, chartAxis.getChart().getChartType()); chartAxis = multiAxisPlot.getAxes().get(1); Assert.assertEquals("position", AxisPositionEnum.RIGHT_OR_BOTTOM, chartAxis.getPositionValue()); Assert.assertEquals("chart", JRChart.CHART_TYPE_TIMESERIES, chartAxis.getChart().getChartType()); }
From source file:com.okmich.twitanalysis.gui.ApplicationFrame.java
private void setChartPanel(JPanel jpanel) { this.negativeSeries = new TimeSeries("Negative", Millisecond.class); this.postiveSeries = new TimeSeries("Positive", Millisecond.class); this.neutralSeries = new TimeSeries("Neutral", Millisecond.class); final TimeSeriesCollection dataset = new TimeSeriesCollection(this.negativeSeries); dataset.addSeries(this.postiveSeries); dataset.addSeries(this.neutralSeries); final JFreeChart chart = createChart(dataset); chart.getXYPlot().getRenderer(0).setSeriesPaint(0, Color.RED); chart.getXYPlot().getRenderer(0).setSeriesStroke(0, new BasicStroke(2.0f)); chart.getXYPlot().getRenderer(0).setSeriesPaint(1, Color.GREEN); chart.getXYPlot().getRenderer(0).setSeriesStroke(1, new BasicStroke(2.0f)); chart.getXYPlot().getRenderer(0).setSeriesPaint(2, Color.GRAY); chart.getXYPlot().getRenderer(0).setSeriesStroke(2, new BasicStroke(2.0f)); chart.getPlot().setBackgroundPaint(Color.BLACK); final ChartPanel chartPanel = new ChartPanel(chart); final JPanel tweetCountPanel = new JPanel(new FlowLayout(FlowLayout.CENTER)); tweetCountLabel = new JLabel(); setTweetCountLabel();//from www . j av a 2 s . co m tweetCountPanel.add(tweetCountLabel); jpanel.setLayout(new BorderLayout(10, 10)); jpanel.add(chartPanel, BorderLayout.CENTER); jpanel.add(tweetCountPanel, BorderLayout.SOUTH); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); setContentPane(jpanel); }
From source file:com.romraider.logger.ecu.ui.tab.LoggerChartPanel.java
private void addTrendLine(JFreeChart chart, int index, XYTrendline trendline, Color color) { XYPlot plot = chart.getXYPlot(); plot.setDataset(index, trendline);//w w w .ja va 2s . c o m plot.setRenderer(index, buildTrendLineRenderer(color)); }