DefaultXYDataset ds = new DefaultXYDataset(); //generate random data as an example double[][] data = new double[2][1000]; for ( int i = 0; i < 1000; i++ ){ data[0][i] = i; data[1][i] = (Math.random() * 100); } ds.addSeries("Time", data); JFreeChart chart = ChartFactory.createXYLineChart("Test", "Time", "Y-Axis", ds, PlotOrientation.VERTICAL, false,false,false);
/** * Returns the key for a series. * * @param series the series index (in the range <code>0</code> to * <code>getSeriesCount() - 1</code>). * * @return The key for the series. * * @throws IllegalArgumentException if <code>series</code> is not in the * specified range. */ public Comparable getSeriesKey(int series) { if ((series < 0) || (series >= getSeriesCount())) { throw new IllegalArgumentException("Series index out of bounds"); } return (Comparable) this.seriesKeys.get(series); }
/** * Returns the x-value for an item within a series. * * @param series the series index (in the range {@code 0} to * {@code getSeriesCount() - 1}). * @param item the item index (in the range {@code 0} to * {@code getItemCount(series)}). * * @return The x-value. * * @throws ArrayIndexOutOfBoundsException if {@code series} is not * within the specified range. * @throws ArrayIndexOutOfBoundsException if {@code item} is not * within the specified range. * * @see #getXValue(int, int) */ @Override public Number getX(int series, int item) { return new Double(getXValue(series, item)); }
xyDataset = new DefaultXYDataset(); } else { xyzDataset = new DefaultXYZDataset(); xyDataset.addSeries(sparkline3dDataSeries.getSeriesLabel(), data); } else { xyzDataset.addSeries(sparkline3dDataSeries.getSeriesLabel(), data); for (int i = 0; i < xyDataset.getSeriesCount(); i++) { plot.getRenderer().setSeriesPaint(i, colors.get(i));
@Override public Dataset createDataset() { return new DefaultXYDataset(); }
private void refreshSeries(Map<Long, Long> data, Comparable<?> seriesKey) { int i = 0; double[][] seriesData; synchronized(data) { seriesData = new double[2][data.size()]; for(Map.Entry<Long, Long> xy: data.entrySet()) { seriesData[0][i] = xy.getKey()/1000.0; seriesData[1][i] = xy.getValue(); i++; } } xyDataset.addSeries(seriesKey, seriesData); }
/** * Returns the y-value for an item within a series. * * @param series the series index (in the range {@code 0} to * {@code getSeriesCount() - 1}). * @param item the item index (in the range {@code 0} to * {@code getItemCount(series)}). * * @return The y-value. * * @throws ArrayIndexOutOfBoundsException if {@code series} is not * within the specified range. * @throws ArrayIndexOutOfBoundsException if {@code item} is not * within the specified range. * * @see #getX(int, int) */ @Override public Number getY(int series, int item) { return new Double(getYValue(series, item)); }
@Inject public QueryTimeHistoryPanel(QueryTimeHistoryStatistic queryTimeStatistic) { super(); this.queryTimeStatistic = queryTimeStatistic; this.dataset = new DefaultXYDataset(); this.add(createChartPanel()); }
@Override public synchronized void refreshView() { logger.debug("refreshing histogram"); Map<Integer, Integer> histogramData = histogram.getCurrentHisogram(); double[][] data = new double[2][histogramData.size()]; int i =0; for(Map.Entry<Integer, Integer> entry: histogramData.entrySet()) { data[0][i] = entry.getKey().doubleValue(); data[1][i] = entry.getValue().doubleValue(); i++; } xyDataset.addSeries(SERIES_KEY, data); }
/** * Returns the y-value for an item within a series. * * @param series the series index (in the range <code>0</code> to * <code>getSeriesCount() - 1</code>). * @param item the item index (in the range <code>0</code> to * <code>getItemCount(series)</code>). * * @return The y-value. * * @throws ArrayIndexOutOfBoundsException if <code>series</code> is not * within the specified range. * @throws ArrayIndexOutOfBoundsException if <code>item</code> is not * within the specified range. * * @see #getX(int, int) */ public Number getY(int series, int item) { return new Double(getYValue(series, item)); }
/** * @param prcData * @return */ public static DefaultXYDataset createXYDataset(List<double[][]> prcData) { DefaultXYDataset dataset = new DefaultXYDataset(); double[][] data = new double[2][11]; double[] avPrec = new double[11]; double[] avRec = new double[11]; for (int i = 0; i < prcData.size(); i++) { double[] r = prcData.get(i)[0]; for (int j = 0; j < r.length; j++) { avRec[j] += r[j]; } double[] p = prcData.get(i)[1]; for (int j = 0; j < p.length; j++) { avPrec[j] += p[j]; } } for (int i = 0; i < avPrec.length; i++) { avPrec[i] = avPrec[i] / prcData.size(); avRec[i] = avRec[i] / prcData.size(); } data[0] = avRec; data[1] = avPrec; dataset.addSeries("PR-Curve", data); return dataset; }
@Inject public HistogramChartPanel(HistogramQueryStatistic histogram) { super(); this.histogram = histogram; this.xyDataset = new DefaultXYDataset(); this.add(createChartPanel()); }
@Override public void refreshView() { logger.debug("refreshing query Time History"); Map<Integer, Integer> histogramData = queryTimeStatistic.getCurrentHistory(); int size = histogramData.size(); double[][] data = new double[2][size]; int i=0; for(Map.Entry<Integer, Integer> entry: histogramData.entrySet()) { data[0][i] = entry.getKey().doubleValue(); data[1][i] = entry.getValue().doubleValue(); i++; } dataset.addSeries(SERIES_KEY, data); }
/** * Returns the key for a series. * * @param series the series index (in the range {@code 0} to * {@code getSeriesCount() - 1}). * * @return The key for the series. * * @throws IllegalArgumentException if {@code series} is not in the * specified range. */ @Override public Comparable getSeriesKey(int series) { if ((series < 0) || (series >= getSeriesCount())) { throw new IllegalArgumentException("Series index out of bounds"); } return (Comparable) this.seriesKeys.get(series); }
/** * Returns the x-value for an item within a series. * * @param series the series index (in the range <code>0</code> to * <code>getSeriesCount() - 1</code>). * @param item the item index (in the range <code>0</code> to * <code>getItemCount(series)</code>). * * @return The x-value. * * @throws ArrayIndexOutOfBoundsException if <code>series</code> is not * within the specified range. * @throws ArrayIndexOutOfBoundsException if <code>item</code> is not * within the specified range. * * @see #getXValue(int, int) */ public Number getX(int series, int item) { return new Double(getXValue(series, item)); }
public static XYDataset createXYDataSet(List<XYScatter> dataList, String dataName) { DefaultXYDataset dataSet = new DefaultXYDataset(); if(dataList==null ||dataList.size()==0){ return dataSet; } int size = dataList.size(); double[][] data = new double[2][size]; for (int i = 0; i < size; i++) { XYScatter behaviorBO = dataList.get(i); double x = behaviorBO.getX(); double y = behaviorBO.getY(); data[0][i] = x; data[1][i] = y; } dataSet.addSeries(dataName,data); return dataSet; } public static JFreeChart createChart(XYDataset xydataset, List<XYScatter> dataList,
@Inject public OperationTimeLineChartPanel(OperationTimeHistory statistic) { super(); this.statistic = statistic; this.xyDataset = new DefaultXYDataset(); this.setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS)); this.add(this.createChartPanel()); this.add(this.createCheckBoxPanel()); }
private void addSeries(Map<Long, CacheData> data, String element, String label) { if (data == null) { return; } int i = 0; double[][] seriesData = new double[2][data.size()]; Function<CacheData, Double> cacheDataValue = cacheDataMethodMap.get(element) .andThen(o -> o.toString()).andThen(Double::valueOf); Function<Long, Double> timePoint = (time) -> time / 1000.0; for(Map.Entry<Long, CacheData> xy: data.entrySet()) { seriesData[0][i] = timePoint.apply(xy.getKey()); seriesData[1][i] = cacheDataValue.apply(xy.getValue()); i++; } xyDataset.addSeries(I18n.get(label), seriesData); }
/** * Returns the number of items in the specified series. * * @param series the series index (in the range {@code 0} to * {@code getSeriesCount() - 1}). * * @return The item count. * * @throws IllegalArgumentException if {@code series} is not in the * specified range. */ @Override public int getItemCount(int series) { if ((series < 0) || (series >= getSeriesCount())) { throw new IllegalArgumentException("Series index out of bounds"); } double[][] seriesArray = (double[][]) this.seriesList.get(series); return seriesArray[0].length; }
public void setImageDataBounds(Rectangle2D imageDataBounds) { synchronized (imageLock) { this.imageDataBounds = (Rectangle2D) imageDataBounds.clone(); DefaultXYDataset xyDataset = new DefaultXYDataset(); xyDataset.addSeries("Image Data Bounds", new double[][]{ {imageDataBounds.getMinX(), imageDataBounds.getMaxX()}, {imageDataBounds.getMinY(), imageDataBounds.getMaxY()} }); setDataset(xyDataset); getDomainAxis().setRange(imageDataBounds.getMinX(), imageDataBounds.getMaxX()); getRangeAxis().setRange(imageDataBounds.getMinY(), imageDataBounds.getMaxY()); } }