Example usage for org.jfree.chart JFreeChart getXYPlot

List of usage examples for org.jfree.chart JFreeChart getXYPlot

Introduction

In this page you can find the example usage for org.jfree.chart JFreeChart getXYPlot.

Prototype

public XYPlot getXYPlot() 

Source Link

Document

Returns the plot cast as an XYPlot .

Usage

From source file:org.jfree.chart.demo.TimeSeriesDemo2.java

/**
 * A demonstration application showing a quarterly time series containing a null value.
 *
 * @param title  the frame title.//from   w  ww. ja v  a 2s  . co m
 */
public TimeSeriesDemo2(final String title) {

    super(title);

    final TimeSeries series = new TimeSeries("Quarterly Data", Quarter.class);
    series.add(new Quarter(1, 2001), 500.2);
    series.add(new Quarter(2, 2001), 694.1);
    series.add(new Quarter(3, 2001), 734.4);
    series.add(new Quarter(4, 2001), 453.2);
    series.add(new Quarter(1, 2002), 500.2);
    series.add(new Quarter(2, 2002), null);
    series.add(new Quarter(3, 2002), 734.4);
    series.add(new Quarter(4, 2002), 453.2);
    final TimeSeriesCollection dataset = new TimeSeriesCollection(series);
    final JFreeChart chart = ChartFactory.createTimeSeriesChart("Time Series Demo 2", "Time", "Value", dataset,
            true, true, false);
    chart.getXYPlot().addRangeMarker(new ValueMarker(550.0));
    final Quarter q = new Quarter(2, 2002);
    chart.getXYPlot().addDomainMarker(new ValueMarker(q.getMiddleMillisecond()));
    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
    setContentPane(chartPanel);

}

From source file:org.jfree.chart.demo.HighLowChartDemo.java

/**
 * A demonstration application showing a high-low-open-close chart.
 *
 * @param title  the frame title.//w ww.j ava  2 s .co m
 */
public HighLowChartDemo(final String title) {

    super(title);

    final DefaultHighLowDataset dataset = DemoDatasetFactory.createHighLowDataset();
    final JFreeChart chart = ChartFactory.createHighLowChart("High-Low-Open-Close Demo", "Time", "Value",
            dataset, true);
    final DateAxis axis = (DateAxis) chart.getXYPlot().getDomainAxis();
    axis.setTickMarkPosition(DateTickMarkPosition.MIDDLE);
    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
    setContentPane(chartPanel);

}

From source file:gui.DendrogramChart.java

void setScaling(boolean autorange, double min, double max) {
    JFreeChart chart = ((ChartPanel) getComponent(0)).getChart();
    ValueAxis axis = chart.getXYPlot().getDomainAxis();

    axis.setAutoRange(autorange);/*  w w w  . j a  v a2s. c om*/
    if (!autorange) {
        axis.setLowerBound(min);
        axis.setUpperBound(max);
    }
}

From source file:monitoring.suhu.DynamicCharts.java

private JFreeChart createChart(final XYDataset dataset) {
    final JFreeChart result = ChartFactory.createTimeSeriesChart("Temperature Graph", "Time", "Celcius",
            dataset, true, true, false);
    final XYPlot plot = result.getXYPlot();
    ValueAxis axis = plot.getDomainAxis();
    axis.setAutoRange(true);/* w w  w  .  j  a v a  2s  .com*/
    axis.setFixedAutoRange(60000.0); // 60 seconds
    axis = plot.getRangeAxis();
    axis.setRange(0.0, 50.0);
    return result;
}

From source file:net.sf.jasperreports.customizers.marker.RangeValueMarkerCustomizer.java

@Override
public void customize(JFreeChart jfc, JRChart jrc) {
    if (jfc.getPlot() instanceof XYPlot) {
        Marker marker = createMarker();//  ww w  . j  a v  a  2 s .c o  m
        if (marker != null) {
            addMarker(jfc.getXYPlot(), marker);
        }
    }
}

From source file:xdevs.lib.util.ScopeView.java

public ScopeView(String windowsTitle, String title, String xTitle, String yTitle) {
    super(windowsTitle);
    XYSeriesCollection dataSet = new XYSeriesCollection();
    serie = new XYSeries(yTitle);
    dataSet.addSeries(serie);//from  w ww.j  a va  2s. c  o  m
    JFreeChart chart = ChartFactory.createXYStepChart(title, xTitle, yTitle, dataSet, PlotOrientation.VERTICAL,
            true, false, false);
    chart.getXYPlot().setDomainAxis(new NumberAxis());
    ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
    chartPanel.setMouseZoomable(true, false);
    setContentPane(chartPanel);
    addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            dispose();
        }
    });
    super.pack();
    RefineryUtilities.centerFrameOnScreen(this);
    this.setVisible(true);
}

From source file:net.sf.dynamicreports.test.jasper.chart.BubbleChartTest.java

@Override
public void test() {
    super.test();

    numberOfPagesTest(1);/*from  w  ww.ja  va  2s .  c  o m*/

    JFreeChart chart = getChart("summary.chart1", 0);
    XYItemRenderer renderer = chart.getXYPlot().getRenderer();
    Assert.assertEquals("renderer", XYBubbleRenderer.class, renderer.getClass());
    Assert.assertEquals("scale type", XYBubbleRenderer.SCALE_ON_BOTH_AXES,
            ((XYBubbleRenderer) renderer).getScaleType());
    xyzChartDataTest(chart, 0, "a",
            new Number[][] { { 1d, 2d, 0.25 }, { 2d, 3d, 0.5 }, { 3d, 4d, 0.75 }, { 4d, 5d, 1d } });
    xyzChartDataTest(chart, 1, "serie1",
            new Number[][] { { 2d, 1d, 0.25 }, { 3d, 2d, 0.5 }, { 4d, 3d, 0.75 }, { 5d, 4d, 1d } });

    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:org.nbrcp.demo.core.views.Barchart.java

private void setUpView() {
    final JFreeChart chart = ChartFactory.createXYBarChart("", "X", false, "Y", Data.getDataset(),
            PlotOrientation.HORIZONTAL, true, true, false);

    XYPlot plot = chart.getXYPlot();
    XYBarRenderer renderer = (XYBarRenderer) plot.getRenderer();
    renderer.setShadowVisible(false);/*from  ww w.j  ava 2s  .  c  o m*/
    renderer.setMargin(0.96);

    final ChartPanel panel = new ChartPanel(chart);
    panel.setMinimumDrawHeight(10);
    panel.setMaximumDrawHeight(2000);
    panel.setMinimumDrawWidth(10);
    panel.setMaximumDrawWidth(2000);
    panel.setSize(this.getSize());
    this.add(panel);
}

From source file:org.openmrs.web.servlet.ShowGraphServletTest.java

/**
 * @see ShowGraphServlet#getChart(HttpServletRequest)
 *///from w w w.j  a  va 2  s .c  o  m
@Test
@Verifies(value = "should set value axis label to concept numeric units if given units is null", method = "getChart(HttpServletRequest)")
public void getChart_shouldSetValueAxisLabelToConceptNumericUnitsIfGivenUnitsIsNull() throws Exception {
    MockHttpServletRequest request = new MockHttpServletRequest();
    request.setParameter("patientId", "7");
    request.setParameter("conceptId", "5497"); // cd4

    JFreeChart chart = new ShowGraphServlet().getChart(request);

    Assert.assertEquals("cells/mmL", chart.getXYPlot().getRangeAxis().getLabel());
}

From source file:subterranean.crimson.server.graphics.graphs.LineChart.java

private JFreeChart createChart(final XYDataset dataset) {
    final JFreeChart result = ChartFactory.createTimeSeriesChart("", "", "", dataset, false, false, false);

    XYPlot plot = result.getXYPlot();
    plot.setDataset(1, new TimeSeriesCollection(s2));

    plot.setBackgroundPaint(new Color(0x000000));
    plot.setDomainGridlinesVisible(false);
    plot.setDomainGridlinePaint(Color.lightGray);
    plot.setRangeGridlinesVisible(false);
    plot.setRangeGridlinePaint(Color.lightGray);

    ValueAxis xaxis = plot.getDomainAxis();
    xaxis.setAutoRange(true);/*from  w  w  w  . java 2s .c o  m*/

    xaxis.setFixedAutoRange(160000.0); // 160 seconds
    xaxis.setVerticalTickLabels(false);

    ValueAxis yaxis = plot.getRangeAxis();

    yaxis.setAutoRange(true);
    yaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    return result;
}