List of usage examples for org.jfree.data XYSeriesCollection XYSeriesCollection
public XYSeriesCollection(final XYSeries series)
From source file:edu.caltechUcla.sselCassel.projects.jMarkets.shared.interfaces.PriceChart.java
public void test() { XYSeries testSeries = new XYSeries("Test Series"); testSeries.add(10, 10);//from www .j av a 2s.c o m testSeries.add(20, 20); testSeries.add(30, 30); XYSeriesCollection collection = new XYSeriesCollection(testSeries); NumberAxis yAxis = new NumberAxis("Y Axis"); NumberAxis xAxis = new NumberAxis("X Axis"); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); XYPlot plot = new XYPlot(collection, xAxis, yAxis, renderer); JFreeChart chart = new JFreeChart("Price Chart", new Font("Arial", 0, 12), plot, true); ChartPanel chartPanel = new ChartPanel(chart, false, false, false, false, false); JFrame frame = new JFrame(); frame.getContentPane().add(chartPanel); frame.setVisible(true); frame.pack(); }
From source file:de.berlios.statcvs.xml.report.CommitActivityChart.java
/** * @param settings/* w ww .j a v a 2 s.c o m*/ * @param defaultFilename * @param defaultSubtitle */ public CommitActivityChart(CvsContent content, ReportSettings settings) { super(settings, "commitactivity%1.png", I18n.tr("Commit Activity%1")); Grouper grouper = settings.getGrouper(new AuthorGrouper()); Map seriesByGroup = new HashMap(); XYSeries series = createXYSeries(grouper.getName() + " " + I18n.tr("(All)"), settings.getRevisionIterator(content)); XYDataset dataset = new XYSeriesCollection(series); addPlot(createPlot(dataset, series.getName())); Iterator it = settings.getRevisionIterator(content); while (it.hasNext()) { CvsRevision rev = (CvsRevision) it.next(); Object group = grouper.getGroup(rev); XYSeries groupSeries = (XYSeries) seriesByGroup.get(group); if (groupSeries == null) { groupSeries = new XYSeries(grouper.getName(group)); seriesByGroup.put(group, groupSeries); } addToXYSeries(groupSeries, rev); } Iterator it2 = seriesByGroup.keySet().iterator(); while (it2.hasNext()) { Object group = it2.next(); dataset = new XYSeriesCollection((XYSeries) seriesByGroup.get(group)); addPlot(createPlot(dataset, grouper.getName(group))); } setup(false); }
From source file:com.sixrr.metrics.ui.charts.DistributionDialog.java
private XYSeriesCollection createDistributionSeries() { final double[] strippedData = GraphUtils.stripNulls(datapoints); final XYSeries series = new XYSeries(metricName); Arrays.sort(strippedData);//from w ww . ja v a2 s .c o m if (strippedData[0] != 0.0) { series.add(0.0, 0.0); } for (int i = 0; i < strippedData.length; i++) { int j = i + 1; while (j < strippedData.length && strippedData[i] == strippedData[j]) { i++; j++; } series.add(strippedData[i], (double) (i + 1) * 100.0 / (double) strippedData.length); } return new XYSeriesCollection(series); }
From source file:ucar.unidata.idv.control.chart.ScatterPlotChartWrapper.java
/** * Create the chart/*from w w w . j ava 2 s. co m*/ */ private void createChart() { if (chartPanel != null) { return; } // create a dataset... XYSeries series1 = new XYSeries("Series 1"); dataset = new XYSeriesCollection(series1); String name = getName(); if (name == null) { name = "Scatter Plot"; } // create the chart... chart = createScatterPlot(name, "Domain", "Range", PlotOrientation.VERTICAL, true, false, false); initXYPlot(plot); plot.setRenderer(new MyRenderer(LineState.SHAPE_POINT)); doMakeChartPanel(chart); }
From source file:ucar.unidata.idv.control.chart.ScatterPlotChartWrapper.java
/** * Create the charts//from w w w. jav a 2 s .c o m * * @throws RemoteException On badness * @throws VisADException On badness */ public void loadData() throws VisADException, RemoteException { try { createChart(); for (int dataSetIdx = 0; dataSetIdx < plot.getDatasetCount(); dataSetIdx++) { XYSeriesCollection dataset = (XYSeriesCollection) plot.getDataset(dataSetIdx); dataset.removeAllSeries(); } ((MyScatterPlot) plot).removeAllSeries(); Hashtable props = new Hashtable(); props.put(TrackDataSource.PROP_TRACKTYPE, TrackDataSource.ID_TIMETRACE); List dataChoiceWrappers = getDataChoiceWrappers(); int dataSetCnt = 0; for (int paramIdx = 0; paramIdx < dataChoiceWrappers.size(); paramIdx += 2) { if (paramIdx + 1 >= dataChoiceWrappers.size()) { break; } DataChoiceWrapper wrapper1 = (DataChoiceWrapper) dataChoiceWrappers.get(paramIdx); DataChoiceWrapper wrapper2 = (DataChoiceWrapper) dataChoiceWrappers.get(paramIdx + 1); DataChoice dataChoice1 = wrapper1.getDataChoice(); DataChoice dataChoice2 = wrapper2.getDataChoice(); FlatField data1 = getFlatField((FieldImpl) dataChoice1.getData(null, props)); FlatField data2 = getFlatField((FieldImpl) dataChoice2.getData(null, props)); Unit unit1 = ucar.visad.Util.getDefaultRangeUnits((FlatField) data1)[0]; Unit unit2 = ucar.visad.Util.getDefaultRangeUnits((FlatField) data2)[0]; NumberAxis rangeAxis = new NumberAxis(wrapper2.getLabel(unit2)); NumberAxis domainAxis = new NumberAxis(wrapper1.getLabel(unit1)); domainAxis.setAutoRange(getAutoRange()); Color c = wrapper1.getColor(paramIdx); MyRenderer renderer = new MyRenderer(wrapper1.getLineState().getShape()); domainAxis.setLabelPaint(c); rangeAxis.setLabelPaint(c); renderer.setSeriesPaint(0, c); double[][] samples1 = data1.getValues(false); double[][] samples2 = data2.getValues(false); double[] timeValues1 = getTimeValues(samples1, data1); double[] timeValues2 = getTimeValues(samples2, data2); double[][] values1 = filterData(samples1[0], timeValues1); double[][] values2 = filterData(samples2[0], timeValues2); if (values1.length > 1) { this.timeValues1 = values1[1]; this.timeValues2 = values2[1]; } double[][] values = { values1[0], values2[0] }; ((MyScatterPlot) plot).addSeries(values); //Add in a dummy dataset XYSeriesCollection dataset = new XYSeriesCollection(new XYSeries("")); if (!getAutoRange()) { NumberAxis oldRangeAxis = (NumberAxis) plot.getRangeAxis(dataSetCnt); NumberAxis oldDomainAxis = (NumberAxis) plot.getDomainAxis(dataSetCnt); if ((oldRangeAxis != null) && (oldDomainAxis != null)) { rangeAxis.setRange(oldRangeAxis.getRange()); domainAxis.setRange(oldDomainAxis.getRange()); } } plot.setDataset(dataSetCnt, dataset); plot.setRenderer(dataSetCnt, renderer); plot.setRangeAxis(dataSetCnt, rangeAxis, false); plot.setDomainAxis(dataSetCnt, domainAxis, false); plot.mapDatasetToRangeAxis(dataSetCnt, dataSetCnt); plot.mapDatasetToDomainAxis(dataSetCnt, dataSetCnt); if (!getAutoRange()) { rangeAxis.setAutoRange(false); domainAxis.setAutoRange(false); } dataSetCnt++; } } catch (Exception exc) { LogUtil.logException("Error creating data set", exc); } }