/** * Creates a series * * @param seriesSet * @param data * @param label * @param symbol * @param color */ private void createSeries( ISeriesSet seriesSet, double[] data, String label, PlotSymbolType symbol, Color color) { ILineSeries series = (ILineSeries) seriesSet.createSeries(SeriesType.LINE, label); // $NON-NLS-1$ series.setAntialias(SWT.ON); series.getLabel().setVisible(false); series.getLabel().setFont(chart.getFont()); series.setYSeries(data); series.setSymbolType(symbol); series.setSymbolColor(color); series.setLineColor(color); series.setXAxisId(0); series.setYAxisId(0); }
private void showData(List<IStoreItem> res) { Iterator<IStoreItem> iter = res.iterator(); // clear the graph ISeries[] coll = chart.getSeriesSet().getSeries(); for (int i = 0; i < coll.length; i++) { ISeries iSeries = coll[i]; chart.getSeriesSet().deleteSeries(iSeries.getId()); } while (iter.hasNext()) { ICollection iCollection = (ICollection) iter.next(); TimeFrequencyBins.BinnedData bins = null; if (iCollection.isTemporal()) { if (iCollection.size() > 1) { if (iCollection.size() <= MAX_SIZE) { IBaseTemporalCollection thisQ = (IBaseTemporalCollection) iCollection; bins = TimeFrequencyBins.doBins(iCollection, thisQ); String seriesName = iCollection.getName(); ILineSeries newSeries = (ILineSeries) chart.getSeriesSet().createSeries(SeriesType.LINE, seriesName); newSeries.setSymbolType(PlotSymbolType.NONE); newSeries.enableArea(true); newSeries.setLineColor(PlottingHelpers.colorFor(seriesName)); Date[] xData = new Date[bins.size() * 2]; double[] yData = new double[bins.size() * 2]; // put the data into series int ctr = 0; Iterator<Bin> iter2 = bins.iterator(); while (iter2.hasNext()) { Bin bin = (TimeFrequencyBins.Bin) iter2.next(); xData[ctr] = new Date(bin.lowerVal); yData[ctr++] = bin.freqVal; xData[ctr] = new Date(bin.upperVal); yData[ctr++] = bin.freqVal; } newSeries.setXDateSeries(xData); newSeries.setYSeries(yData); newSeries.enableStack(true); newSeries.enableArea(true); // adjust the axis range chart.getAxisSet().adjustRange(); IAxis xAxis = chart.getAxisSet().getXAxis(0); xAxis.enableCategory(false); // set the y axis min to be zero Range yRange = chart.getAxisSet().getYAxis(0).getRange(); chart.getAxisSet().getYAxis(0).setRange(new Range(0, yRange.upper)); chart.redraw(); } } } } }