List of usage examples for org.jfree.chart JFreeChart getXYPlot
public XYPlot getXYPlot()
From source file:com.intel.stl.ui.configuration.view.HoQLifeBarChartPanel.java
@Override public void initComponents() { dataset = new XYSeriesCollection(); JFreeChart chart = ComponentFactory.createXYBarChart(K0342_PORT_VL_TITLE.getValue(), K1069_HOQLIFE.getValue(), dataset, (XYItemLabelGenerator) null); XYPlot plot = chart.getXYPlot(); plot.setDomainPannable(true);/*from w ww . j a v a 2s . c o m*/ plot.setRangePannable(true); final String vlLabel = "<html>" + K0342_PORT_VL_TITLE.getValue() + ": "; final String hoqLabel = "<br>" + K1069_HOQLIFE.getValue() + ": "; XYBarRenderer renderer = (XYBarRenderer) plot.getRenderer(); renderer.setBarAlignmentFactor(0); renderer.setMargin(0.2); renderer.setSeriesToolTipGenerator(0, new XYToolTipGenerator() { @Override public String generateToolTip(XYDataset dataset, int arg1, int arg2) { int vlNum = (int) dataset.getXValue(arg1, arg2); int hoqCount = (int) dataset.getYValue(arg1, arg2); return vlLabel + vlNum + hoqLabel + hoqCount + "</html>"; } }); NumberAxis yAxis = (NumberAxis) plot.getRangeAxis(); yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); NumberAxis xAxis = (NumberAxis) plot.getDomainAxis(); xAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); chartPanel = new ChartPanel(chart); chartPanel.setMouseWheelEnabled(true); chartPanel.setPreferredSize(PREFERRED_CHART_SIZE); propsPanel.add(chartPanel); }
From source file:Demo.HistGraph.java
private JFreeChart CreateChart(String para) { // read .dat file double[] value = Utils.GetParaTab(para); // generate chart HistogramDataset dataset = new HistogramDataset(); dataset.setType(HistogramType.FREQUENCY); dataset.addSeries(para, value, 20);/* ww w . ja v a 2 s . c o m*/ String plotTitle = para; String xaxis = "value"; String yaxis = "frequecy"; PlotOrientation orientation = PlotOrientation.VERTICAL; boolean show = false; boolean toolTips = false; boolean urls = false; JFreeChart chart = ChartFactory.createHistogram(plotTitle, xaxis, yaxis, dataset, orientation, show, toolTips, urls); final XYPlot xyPlot = chart.getXYPlot(); final XYBarRenderer renderer = (XYBarRenderer) xyPlot.getRenderer(); renderer.setSeriesPaint(0, Color.BLUE); return chart; }
From source file:net.sf.clichart.chart.AbstractChartBuilder.java
private void setOptions(JFreeChart chart, Options options) { setAxisLimits(chart.getXYPlot().getRangeAxis(), options.getMinYValue(), options.getMaxYValue(), options.forceYRange());/*from w w w . j a v a 2s. c o m*/ setAxisRenderer(chart.getXYPlot(), 0, options.isBarChart(), options.hasDataPoints(), options.getLineWeight()); if (options.getColourOverrides() != null) { Plot plot = chart.getPlot(); DrawingSupplierWrapper drawingSupplierWrapper = new DrawingSupplierWrapper(); drawingSupplierWrapper.addColourOverrides(options.getColourOverrides()); plot.setDrawingSupplier(drawingSupplierWrapper); } }
From source file:org.esa.beam.pixex.output.ScatterPlotDecoratingStrategyTest.java
@Test public void testCreateScatterPlotsForSingleProduct() throws Exception { Measurement[] productMeasurements = new Measurement[] { new Measurement(0, "someName", PRODUCT_ID_0, -1, -1, null, null, new Object[] { 7, 4.0 }, true), new Measurement(1, "someOtherName", PRODUCT_ID_0, -1, -1, null, null, new Object[] { 9, 3.0 }, true) };// w w w . j a v a 2 s .c o m assertTrue(strategy.plotMaps.isEmpty()); final Product product = createProduct("newProduct"); strategy.writeHeader(null, product); strategy.writeMeasurements(product, null, productMeasurements); assertEquals(1, strategy.plotMaps.size()); final int scatterPlotCountForProduct = strategy.plotMaps.get(PRODUCT_ID_0).size(); assertEquals(2, scatterPlotCountForProduct); JFreeChart sstPlot = strategy.plotMaps.get(PRODUCT_ID_0).get(variableCombinations[0]); assertEquals("original_sst", sstPlot.getXYPlot().getDomainAxis().getLabel()); assertEquals("product_sst", sstPlot.getXYPlot().getRangeAxis().getLabel()); assertEquals("Scatter plot of 'original_sst' and 'product_sst' for product 'newProduct'", sstPlot.getTitle().getText()); XYDataset sstDataset = sstPlot.getXYPlot().getDataset(); assertNotNull(sstDataset); assertEquals(1, sstDataset.getSeriesCount()); int seriesIndex = 0; assertEquals(2, sstDataset.getItemCount(0)); assertEquals(6, sstDataset.getX(seriesIndex, 0)); assertEquals(7, sstDataset.getY(seriesIndex, 0)); assertEquals(8, sstDataset.getX(seriesIndex, 1)); assertEquals(9, sstDataset.getY(seriesIndex, 1)); JFreeChart tsmPlot = strategy.plotMaps.get(PRODUCT_ID_0).get(variableCombinations[1]); assertEquals("original_tsm", tsmPlot.getXYPlot().getDomainAxis().getLabel()); assertEquals("product_tsm", tsmPlot.getXYPlot().getRangeAxis().getLabel()); assertEquals("Scatter plot of 'original_tsm' and 'product_tsm' for product 'newProduct'", tsmPlot.getTitle().getText()); XYDataset tsmDataset = tsmPlot.getXYPlot().getDataset(); assertNotNull(tsmDataset); assertEquals(1, tsmDataset.getSeriesCount()); assertEquals(2, tsmDataset.getItemCount(0)); assertEquals(2.0, tsmDataset.getX(seriesIndex, 0)); assertEquals(3.0, tsmDataset.getY(seriesIndex, 0)); assertEquals(3.0, tsmDataset.getX(seriesIndex, 1)); assertEquals(4.0, tsmDataset.getY(seriesIndex, 1)); }
From source file:org.n52.io.measurement.img.ChartIoHandler.java
private XYPlot createPlotArea(JFreeChart chart) { XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(WHITE);//from www . j ava 2 s . c om plot.setDomainGridlinePaint(LIGHT_GRAY); plot.setRangeGridlinePaint(LIGHT_GRAY); plot.setAxisOffset(new RectangleInsets(2.0, 2.0, 2.0, 2.0)); showCrosshairsOnAxes(plot); configureDomainAxis(plot); showGridlinesOnChart(plot); configureTimeAxis(plot); configureTitle(chart); addNotice(chart); return plot; }
From source file:democsv.XYLineChart_AWT.java
public XYLineChart_AWT(String applicationTitle, String chartTitle) { super(applicationTitle); JFreeChart xylineChart = ChartFactory.createXYLineChart(chartTitle, "Category", "Score", createDataset(), PlotOrientation.VERTICAL, true, true, false); ChartPanel chartPanel = new ChartPanel(xylineChart); chartPanel.setPreferredSize(new java.awt.Dimension(560, 367)); final XYPlot plot = xylineChart.getXYPlot(); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesPaint(0, Color.RED); renderer.setSeriesPaint(1, Color.GREEN); renderer.setSeriesPaint(2, Color.YELLOW); renderer.setSeriesStroke(0, new BasicStroke(4.0f)); renderer.setSeriesStroke(1, new BasicStroke(3.0f)); renderer.setSeriesStroke(2, new BasicStroke(2.0f)); plot.setRenderer(renderer);/*from w w w . java 2 s. c o m*/ setContentPane(chartPanel); }
From source file:graficarfreechart.GraficarFreeChart.java
public GraficarFreeChart(String applicationTitle, String chartTitle) { super(applicationTitle); JFreeChart xylineChart = ChartFactory.createXYLineChart(chartTitle, "Category", "Score", dataset, PlotOrientation.VERTICAL, true, true, false); ChartPanel chartPanel = new ChartPanel(xylineChart); chartPanel.setPreferredSize(new java.awt.Dimension(560, 367)); final XYPlot plot = xylineChart.getXYPlot(); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesPaint(0, Color.RED); renderer.setSeriesPaint(1, Color.GREEN); renderer.setSeriesPaint(2, Color.YELLOW); renderer.setSeriesStroke(0, new BasicStroke(4.0f)); renderer.setSeriesStroke(1, new BasicStroke(3.0f)); renderer.setSeriesStroke(2, new BasicStroke(2.0f)); plot.setRenderer(renderer);// w w w.jav a 2s . c o m setContentPane(chartPanel); }
From source file:lu.lippmann.cdb.common.gui.ts.TimeSeriesChartUtil.java
private static void fillWithMultipleAxis(final Instances dataSet, final int dateIdx, final TimeSeriesCollection tsDataset, final JFreeChart tsChart) { final int numInstances = dataSet.numInstances(); int axisNumber = 0; final Calendar cal = Calendar.getInstance(); for (final Integer i : WekaDataStatsUtil.getNumericAttributesIndexes(dataSet)) { final TimeSeries ts = new TimeSeries(dataSet.attribute(i).name()); for (int k = 0; k < numInstances; k++) { final long timeInMilliSec = (long) dataSet.instance(k).value(dateIdx); cal.setTimeInMillis(timeInMilliSec); if (dataSet.instance(k).isMissing(i)) { ts.addOrUpdate(new Millisecond(cal.getTime()), null); } else { ts.addOrUpdate(new Millisecond(cal.getTime()), dataSet.instance(k).value(i)); }/* ww w. j a v a2 s .co m*/ } if (!ts.isEmpty()) { if (axisNumber == 0) { tsDataset.addSeries(ts); } else { final XYPlot plot = tsChart.getXYPlot(); final NumberAxis axisToAdd = new NumberAxis(dataSet.attribute(i).name()); axisToAdd.setAutoRangeIncludesZero(false); plot.setRangeAxis(axisNumber, axisToAdd); final TimeSeriesCollection t = new TimeSeriesCollection(); t.addSeries(ts); plot.setDataset(axisNumber, t); plot.mapDatasetToRangeAxis(axisNumber, axisNumber); final StandardXYItemRenderer renderer2 = new StandardXYItemRenderer(); renderer2.setSeriesPaint(0, ColorHelper.getColorForAString(dataSet.attribute(i).name())); plot.setRenderer(axisNumber, renderer2); } axisNumber++; } } }
From source file:com.intel.stl.ui.monitor.view.TrafficChartsCreator.java
protected JFreeChart getDataRateChart(Dataset dataset) { JFreeChart chart = ComponentFactory.createXYAreaChart(STLConstants.K0035_TIME.getValue(), STLConstants.K0703_MB_PER_SEC.getValue(), (XYDataset) dataset, false); NumberAxis rangeAxis = (NumberAxis) chart.getXYPlot().getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setAutoRangeIncludesZero(false); return chart; }
From source file:com.tencent.wstt.apt.chart.CPURealTimeChart.java
@Override public JFreeChart createChart() { final JFreeChart chart = ChartFactory.createTimeSeriesChart("CPU", "", "CPU%", dataset, true, true, false);/* w w w . j a va2 s. c o m*/ //?? chart.getTitle().setFont(new Font("", Font.BOLD, 20)); XYPlot xyPlot = (XYPlot) chart.getXYPlot(); ValueAxis domainAxis = xyPlot.getDomainAxis(); ValueAxis rangeAxis = xyPlot.getRangeAxis(); domainAxis.setLabelFont(new Font("", Font.BOLD, 14)); domainAxis.setTickLabelFont(new Font("", Font.BOLD, 12)); rangeAxis.setLabelFont(new Font("", Font.BOLD, 14)); rangeAxis.setTickLabelFont(new Font("", Font.BOLD, 12)); return chart; }