public EegChannelModel(int size, PenStyle strokeStyle, String channelName) { this.dataSeries = sciChartBuilder.newXyDataSeries(Double.class, Double.class) .withFifoCapacity(size) .build(); this.strokeStyle = strokeStyle; this.channelName = channelName; }
private IRenderableSeries initFixedErrorBarsSeries(FastFixedErrorBarsRenderableSeries series) { final XyDataSeries<Double, Double> dataSeries = sciChartBuilder.newXyDataSeries(Double.class, Double.class).build(); double[] randomWalk = getRandomWalk(0d); for (int i = 0; i < POINTS_COUNT; i++) { dataSeries.append((double) i, randomWalk[i]); } series.setDataSeries(dataSeries); initAnimators(sciChartBuilder.newAnimator(series)); sweepAnimator = sciChartBuilder.newAnimator(series).withSweepTransformation().build(); return series; }
private IRenderableSeries initXySeries(XyRenderableSeriesBase series) { final XyDataSeries<Double, Double> dataSeries = sciChartBuilder.newXyDataSeries(Double.class, Double.class).build(); double[] randomWalk = getRandomWalk(0d); for (int i = 0; i < POINTS_COUNT; i++) { dataSeries.append((double) i, randomWalk[i]); } series.setDataSeries(dataSeries); initAnimators(sciChartBuilder.newAnimator(series)); sweepAnimator = sciChartBuilder.newAnimator(series).withSweepTransformation().build(); return series; }
static ChartTypeModel newHorizontallyStackedColumns(SciChartBuilder sciChartBuilder) { HorizontallyStackedColumnsCollection seriesCollection = new HorizontallyStackedColumnsCollection(); for (int i = 0; i < 5; i++) { final IXyDataSeries<Double, Double> dataSeries = sciChartBuilder.newXyDataSeries(Double.class, Double.class).withSeriesName("Series " + (i + 1)).build(); dataSeries.append(DashboardDataHelper.xValues, DashboardDataHelper.yValues[i]); StackedColumnRenderableSeries rSeries = sciChartBuilder.newStackedColumn().withDataSeries(dataSeries).withLinearGradientColors(seriesColors[i * 2 + 1], seriesColors[i * 2]).withStrokeStyle(seriesColors[i * 2]).build(); seriesCollection.add(rSeries); } String name = "Stacked columns side-by-side"; return new ChartTypeModel(seriesCollection, name); }
public RsiPaneModel(SciChartBuilder builder, PriceSeries prices) { super(builder, RSI, "0.0", false); final XyDataSeries<Date, Double> rsiSeries = builder.newXyDataSeries(Date.class, Double.class).withSeriesName("RSI").build(); rsiSeries.append(prices.getDateData(), MovingAverage.rsi(prices, 14)); addRenderableSeries(builder.newLineSeries().withDataSeries(rsiSeries).withYAxisId(RSI).build()); Collections.addAll(annotations, builder.newAxisMarkerAnnotation().withY1(rsiSeries.getYValues().get(rsiSeries.getCount() - 1)).withYAxisId(RSI).build()); } }
public RsiPaneModel(SciChartBuilder builder, PriceSeries prices) { super(builder, RSI, "0.0", false); final XyDataSeries<Date, Double> rsiSeries = builder.newXyDataSeries(Date.class, Double.class).withSeriesName("RSI").build(); rsiSeries.append(prices.getDateData(), MovingAverage.rsi(prices, 14)); addRenderableSeries(builder.newLineSeries().withDataSeries(rsiSeries).withStrokeStyle(0xFFC6E6FF, 1f).withYAxisId(RSI).build()); Collections.addAll(annotations, builder.newAxisMarkerAnnotation().withY1(rsiSeries.getYValues().get(rsiSeries.getCount() - 1)).withYAxisId(RSI).build()); } }
static ChartTypeModel newVerticallyStackedColumns(SciChartBuilder sciChartBuilder, boolean isOneHundredPercent) { VerticallyStackedColumnsCollection seriesCollection = new VerticallyStackedColumnsCollection(); seriesCollection.setIsOneHundredPercent(isOneHundredPercent); for (int i = 0; i < 5; i++) { final IXyDataSeries<Double, Double> dataSeries = sciChartBuilder.newXyDataSeries(Double.class, Double.class).withSeriesName("Series " + (i + 1)).build(); dataSeries.append(DashboardDataHelper.xValues, DashboardDataHelper.yValues[i]); StackedColumnRenderableSeries rSeries = sciChartBuilder.newStackedColumn().withDataSeries(dataSeries).withLinearGradientColors(seriesColors[i * 2 + 1], seriesColors[i * 2]).withStrokeStyle(seriesColors[i * 2]).build(); seriesCollection.add(rSeries); } String name = isOneHundredPercent ? "100% " : ""; name += "Stacked columns"; return new ChartTypeModel(seriesCollection, name); }
static ChartTypeModel newVerticallyStackedMountains(SciChartBuilder sciChartBuilder, boolean isOneHundredPercent) { VerticallyStackedMountainsCollection seriesCollection = new VerticallyStackedMountainsCollection(); seriesCollection.setIsOneHundredPercent(isOneHundredPercent); for (int i = 0; i < 5; i++) { final IXyDataSeries<Double, Double> dataSeries = sciChartBuilder.newXyDataSeries(Double.class, Double.class).withSeriesName("Series " + (i + 1)).build(); dataSeries.append(DashboardDataHelper.xValues, DashboardDataHelper.yValues[i]); StackedMountainRenderableSeries rSeries = sciChartBuilder.newStackedMountain().withDataSeries(dataSeries).withLinearGradientColors(seriesColors[i * 2 + 1], seriesColors[i * 2]).withStrokeStyle(seriesColors[i * 2]).build(); seriesCollection.add(rSeries); } String name = isOneHundredPercent ? "100% " : ""; name += "Stacked mountains"; return new ChartTypeModel(seriesCollection, name); } }
private XyScatterRenderableSeries getScatterRenderableSeries(IPointMarker pointMarker, @ColorInt int color, boolean negative) { final String seriesName = pointMarker instanceof EllipsePointMarker ? negative ? "Negative Ellipse" : "Positive Ellipse" : negative ? "Negative" : "Positive"; final IXyDataSeries<Integer, Double> dataSeries = sciChartBuilder.newXyDataSeries(Integer.class, Double.class).withSeriesName(seriesName).build(); for (int i = 0; i < 200; i++) { final double time = (i < 100) ? getRandom(random, 0, i + 10) / 100 : getRandom(random, 0, 200 - i + 10) / 100; final double y = negative ? -time * time * time : time * time * time; dataSeries.append(i, y); } return sciChartBuilder.newScatterSeries() .withDataSeries(dataSeries) .withStrokeStyle(color) .withPointMarker(sciChartBuilder.newPointMarker(pointMarker) .withSize(6, 6) .withStroke(0xFFFFFFFF, 0.1f) .withFill(color) .build()) .build(); }
public VolumePaneModel(SciChartBuilder builder, PriceSeries prices) { super(builder, VOLUME, "###E+0", false); final XyDataSeries<Date, Double> volumePrices = builder.newXyDataSeries(Date.class, Double.class).withSeriesName("Volume").build(); volumePrices.append(prices.getDateData(), ListUtil.select(prices.getVolumeData(), new Func1<Long, Double>() { @Override public Double func(Long arg) { return arg.doubleValue(); } })); addRenderableSeries(builder.newColumnSeries().withDataSeries(volumePrices).withYAxisId(VOLUME).build()); Collections.addAll(annotations, builder.newAxisMarkerAnnotation().withY1(volumePrices.getYValues().get(volumePrices.getCount() - 1)).withYAxisId(VOLUME).build()); } }
public VolumePaneModel(SciChartBuilder builder, PriceSeries prices) { super(builder, VOLUME, "###E+0", false); final XyDataSeries<Date, Double> volumePrices = builder.newXyDataSeries(Date.class, Double.class).withSeriesName("Volume").build(); volumePrices.append(prices.getDateData(), ListUtil.select(prices.getVolumeData(), new Func1<Long, Double>() { @Override public Double func(Long arg) { return arg.doubleValue(); } })); addRenderableSeries(builder.newColumnSeries().withDataSeries(volumePrices).withYAxisId(VOLUME).build()); Collections.addAll(annotations, builder.newAxisMarkerAnnotation().withY1(volumePrices.getYValues().get(volumePrices.getCount() - 1)).withYAxisId(VOLUME).build()); } }
@Override protected void initExample() { final IAxis xAxis = sciChartBuilder.newNumericAxis().build(); final IAxis yAxis = sciChartBuilder.newNumericAxis().build(); final RandomWalkGenerator randomWalkGenerator = new RandomWalkGenerator(); final DoubleSeries data1 = randomWalkGenerator.getRandomWalkSeries(POINTS_COUNT); randomWalkGenerator.reset(); final DoubleSeries data2 = randomWalkGenerator.getRandomWalkSeries(POINTS_COUNT); final XyDataSeries<Double, Double> ds1 = sciChartBuilder.newXyDataSeries(Double.class, Double.class).withSeriesName("Series #1").build(); final XyDataSeries<Double, Double> ds2 = sciChartBuilder.newXyDataSeries(Double.class, Double.class).withSeriesName("Series #2").build(); ds1.append(data1.xValues, data1.yValues); ds2.append(data2.xValues, data2.yValues); final FastLineRenderableSeries lineRs1 = sciChartBuilder.newLineSeries().withDataSeries(ds1).withSeriesInfoProvider(new FirstCustomSeriesInfoProvider()).withStrokeStyle(0xff6495ed, 2, true).build(); final FastLineRenderableSeries lineRs2 = sciChartBuilder.newLineSeries().withDataSeries(ds2).withSeriesInfoProvider(new SecondCustomSeriesInfoProvider()).withStrokeStyle(0xffe2460c, 2, true).build(); UpdateSuspender.using(surface, new Runnable() { @Override public void run() { Collections.addAll(surface.getXAxes(), xAxis); Collections.addAll(surface.getYAxes(), yAxis); Collections.addAll(surface.getRenderableSeries(), lineRs1, lineRs2); Collections.addAll(surface.getChartModifiers(), new TooltipModifier()); sciChartBuilder.newAnimator(lineRs1).withSweepTransformation().withInterpolator(new DecelerateInterpolator()).withDuration(3000).withStartDelay(350).start(); sciChartBuilder.newAnimator(lineRs2).withSweepTransformation().withInterpolator(new DecelerateInterpolator()).withDuration(3000).withStartDelay(350).start(); } }); }
@Override protected void initExample() { final IAxis xAxis = sciChartBuilder.newNumericAxis().withGrowBy(0.1d, 0.1d).withVisibleRange(1.1, 2.7).build(); final IAxis yAxis = sciChartBuilder.newNumericAxis().withGrowBy(0.1d, 0.1d).build(); final DoubleSeries fourierSeries = DataManager.getInstance().getFourierSeries(1.0, 0.1, 5000); final IXyDataSeries<Double, Double> dataSeries = sciChartBuilder.newXyDataSeries(Double.class, Double.class).build(); dataSeries.append(fourierSeries.xValues, fourierSeries.yValues); final FastLineRenderableSeries rSeries = sciChartBuilder.newLineSeries().withDataSeries(dataSeries).withStrokeStyle(0xFF279B27, 1f, true).build(); UpdateSuspender.using(surface, new Runnable() { @Override public void run() { Collections.addAll(surface.getXAxes(), xAxis); Collections.addAll(surface.getYAxes(), yAxis); Collections.addAll(surface.getRenderableSeries(), rSeries); Collections.addAll(surface.getChartModifiers(), sciChartBuilder.newModifierGroupWithDefaultModifiers().build()); sciChartBuilder.newAnimator(rSeries).withSweepTransformation().withInterpolator(new DecelerateInterpolator()).withDuration(3000).withStartDelay(350).start(); } }); } }
public MacdPaneModel(SciChartBuilder builder, PriceSeries prices) { super(builder, MACD, "0.00", false); final MovingAverage.MacdPoints macdPoints = MovingAverage.macd(prices.getCloseData(), 12, 25, 9); final XyDataSeries<Date, Double> histogramDataSeries = builder.newXyDataSeries(Date.class, Double.class).withSeriesName("Histogram").build(); histogramDataSeries.append(prices.getDateData(), macdPoints.divergenceValues); addRenderableSeries(builder.newColumnSeries().withDataSeries(histogramDataSeries).withYAxisId(MACD).build()); final XyyDataSeries<Date, Double> macdDataSeries = builder.newXyyDataSeries(Date.class, Double.class).withSeriesName("MACD").build(); macdDataSeries.append(prices.getDateData(), macdPoints.macdValues, macdPoints.signalValues); addRenderableSeries(builder.newBandSeries().withDataSeries(macdDataSeries).withYAxisId(MACD).build()); Collections.addAll(annotations, builder.newAxisMarkerAnnotation().withY1(histogramDataSeries.getYValues().get(histogramDataSeries.getCount() - 1)).withYAxisId(MACD).build(), builder.newAxisMarkerAnnotation().withY1(macdDataSeries.getYValues().get(macdDataSeries.getCount() - 1)).withYAxisId(MACD).build()); } }
public MacdPaneModel(SciChartBuilder builder, PriceSeries prices) { super(builder, MACD, "0.00", false); final MovingAverage.MacdPoints macdPoints = MovingAverage.macd(prices.getCloseData(), 12, 25, 9); final XyDataSeries<Date, Double> histogramDataSeries = builder.newXyDataSeries(Date.class, Double.class).withSeriesName("Histogram").build(); histogramDataSeries.append(prices.getDateData(), macdPoints.divergenceValues); addRenderableSeries(builder.newColumnSeries().withDataSeries(histogramDataSeries).withYAxisId(MACD).build()); final XyyDataSeries<Date, Double> macdDataSeries = builder.newXyyDataSeries(Date.class, Double.class).withSeriesName("MACD").build(); macdDataSeries.append(prices.getDateData(), macdPoints.macdValues, macdPoints.signalValues); addRenderableSeries(builder.newBandSeries().withDataSeries(macdDataSeries).withYAxisId(MACD).build()); Collections.addAll(annotations, builder.newAxisMarkerAnnotation().withY1(histogramDataSeries.getYValues().get(histogramDataSeries.getCount() - 1)).withYAxisId(MACD).build(), builder.newAxisMarkerAnnotation().withY1(macdDataSeries.getYValues().get(macdDataSeries.getCount() - 1)).withYAxisId(MACD).build()); } }
@Override protected void initExample() { final IAxis xBottomAxis = sciChartBuilder.newDateAxis().withGrowBy(0.1d, 0.1d).build(); final IAxis yRightAxis = sciChartBuilder.newNumericAxis().withGrowBy(0.1d, 0.1d).build(); final PriceSeries priceData = DataManager.getInstance().getPriceDataIndu(getActivity()); final IXyDataSeries<Date, Double> dataSeries = sciChartBuilder.newXyDataSeries(Date.class, Double.class).build(); dataSeries.append(priceData.getDateData(), priceData.getCloseData()); final FastMountainRenderableSeries rSeries = sciChartBuilder.newMountainSeries() .withDataSeries(dataSeries) .withStrokeStyle(0xAAFFC9A8, 1f, true) .withAreaFillLinearGradientColors(0xAAFF8D42, 0x88090E11) .build(); UpdateSuspender.using(surface, new Runnable() { @Override public void run() { Collections.addAll(surface.getXAxes(), xBottomAxis); Collections.addAll(surface.getYAxes(), yRightAxis); Collections.addAll(surface.getRenderableSeries(), rSeries); Collections.addAll(surface.getChartModifiers(), sciChartBuilder.newModifierGroupWithDefaultModifiers().build()); sciChartBuilder.newAnimator(rSeries).withWaveTransformation().withInterpolator(new DecelerateInterpolator()).withDuration(3000).withStartDelay(350).start(); } }); } }
@Override protected void initExample() { final IAxis xAxis = sciChartBuilder.newNumericAxis().withGrowBy(0.1, 0.1).withDrawMajorBands(true).withVisibleRange(1, 1.25).build(); final IAxis yAxis = sciChartBuilder.newNumericAxis().withGrowBy(0.5, 0.5).withDrawMajorBands(true).withVisibleRange(2.3, 3.3).build(); final DoubleSeries fourierSeries = DataManager.getInstance().getFourierSeries(1.0, 0.1, 5000); final XyDataSeries<Double, Double> dataSeries = sciChartBuilder.newXyDataSeries(Double.class, Double.class).build(); dataSeries.append(fourierSeries.xValues, fourierSeries.yValues); final FastLineRenderableSeries rSeries = sciChartBuilder.newLineSeries() .withDataSeries(dataSeries) .withStrokeStyle(0xFF99EE99, 1f, true) .withIsDigitalLine(true) .build(); UpdateSuspender.using(surface, new Runnable() { @Override public void run() { Collections.addAll(surface.getXAxes(), xAxis); Collections.addAll(surface.getYAxes(), yAxis); Collections.addAll(surface.getRenderableSeries(), rSeries); Collections.addAll(surface.getChartModifiers(), sciChartBuilder.newModifierGroupWithDefaultModifiers().build()); sciChartBuilder.newAnimator(rSeries).withWaveTransformation().withInterpolator(new DecelerateInterpolator()).withDuration(3000).withStartDelay(350).start(); } }); } }
public PricePaneModel(SciChartBuilder builder, PriceSeries prices) { super(builder, PRICES, "$0.0000", true); // Add the main OHLC chart final OhlcDataSeries<Date, Double> stockPrices = builder.newOhlcDataSeries(Date.class, Double.class).withSeriesName("OHLC").build(); stockPrices.append(prices.getDateData(), prices.getOpenData(), prices.getHighData(), prices.getLowData(), prices.getCloseData()); addRenderableSeries(builder.newCandlestickSeries().withDataSeries(stockPrices).withYAxisId(PRICES).build()); final XyDataSeries<Date, Double> maLow = builder.newXyDataSeries(Date.class, Double.class).withSeriesName("Low Line").build(); maLow.append(prices.getDateData(), MovingAverage.movingAverage(prices.getCloseData(), 50)); addRenderableSeries(builder.newLineSeries().withDataSeries(maLow).withStrokeStyle(0xFFFF3333, 2f).withYAxisId(PRICES).build()); final XyDataSeries<Date, Double> maHigh = builder.newXyDataSeries(Date.class, Double.class).withSeriesName("High Line").build(); maHigh.append(prices.getDateData(), MovingAverage.movingAverage(prices.getCloseData(), 200)); addRenderableSeries(builder.newLineSeries().withDataSeries(maHigh).withStrokeStyle(0xFF33DD33, 2f).withYAxisId(PRICES).build()); Collections.addAll(annotations, builder.newAxisMarkerAnnotation().withY1(stockPrices.getYValues().get(stockPrices.getCount() - 1)).withBackgroundColor(0xFFFF3333).withYAxisId(PRICES).build(), builder.newAxisMarkerAnnotation().withY1(maLow.getYValues().get(maLow.getCount() - 1)).withBackgroundColor(0xFFFF3333).withYAxisId(PRICES).build(), builder.newAxisMarkerAnnotation().withY1(maHigh.getYValues().get(maHigh.getCount() - 1)).withBackgroundColor(0xFF33DD33).withYAxisId(PRICES).build()); } }
public PricePaneModel(SciChartBuilder builder, PriceSeries prices) { super(builder, PRICES, "$0.0000", true); // Add the main OHLC chart final OhlcDataSeries<Date, Double> stockPrices = builder.newOhlcDataSeries(Date.class, Double.class).withSeriesName("EUR/USD").build(); stockPrices.append(prices.getDateData(), prices.getOpenData(), prices.getHighData(), prices.getLowData(), prices.getCloseData()); addRenderableSeries(builder.newCandlestickSeries().withDataSeries(stockPrices).withYAxisId(PRICES).build()); final XyDataSeries<Date, Double> maLow = builder.newXyDataSeries(Date.class, Double.class).withSeriesName("Low Line").build(); maLow.append(prices.getDateData(), MovingAverage.movingAverage(prices.getCloseData(), 50)); addRenderableSeries(builder.newLineSeries().withDataSeries(maLow).withStrokeStyle(0xFFFF3333, 1f).withYAxisId(PRICES).build()); final XyDataSeries<Date, Double> maHigh = builder.newXyDataSeries(Date.class, Double.class).withSeriesName("High Line").build(); maHigh.append(prices.getDateData(), MovingAverage.movingAverage(prices.getCloseData(), 200)); addRenderableSeries(builder.newLineSeries().withDataSeries(maHigh).withStrokeStyle(0xFF33DD33, 1f).withYAxisId(PRICES).build()); Collections.addAll(annotations, builder.newAxisMarkerAnnotation().withY1(stockPrices.getYValues().get(stockPrices.getCount() - 1)).withBackgroundColor(0xFFFF3333).withYAxisId(PRICES).build(), builder.newAxisMarkerAnnotation().withY1(maLow.getYValues().get(maLow.getCount() - 1)).withBackgroundColor(0xFFFF3333).withYAxisId(PRICES).build(), builder.newAxisMarkerAnnotation().withY1(maHigh.getYValues().get(maHigh.getCount() - 1)).withBackgroundColor(0xFF33DD33).withYAxisId(PRICES).build()); } }
@Override protected void initExample() { final IAxis xAxis = sciChartBuilder.newNumericAxis().withAxisAlignment(AxisAlignment.Top).withMajorTickLineStyle(0xFFFFFFFF, 2f, true).withTextFormatting("0.00").withDrawMinorTicks(false).withIsCenterAxis(true).withGrowBy(0.1, 0.1).build(); final IAxis yAxis = sciChartBuilder.newNumericAxis().withAxisAlignment(AxisAlignment.Left).withMajorTickLineStyle(0xFFFFFFFF, 2f, true).withTextFormatting("0.00").withDrawMinorTicks(false).withIsCenterAxis(true).withGrowBy(0.1, 0.1).build(); final DoubleSeries butterflyCurve = DataManager.getInstance().getButterflyCurve(20000); final XyDataSeries<Double, Double> dataSeries = sciChartBuilder.newXyDataSeries(Double.class, Double.class).withAcceptsUnsortedData().build(); dataSeries.append(butterflyCurve.xValues, butterflyCurve.yValues); final FastLineRenderableSeries rSeries = sciChartBuilder.newLineSeries().withDataSeries(dataSeries).build(); UpdateSuspender.using(surface, new Runnable() { @Override public void run() { surface.setLayoutManager(new CenterLayoutManager(xAxis, yAxis)); Collections.addAll(surface.getXAxes(), xAxis); Collections.addAll(surface.getYAxes(), yAxis); Collections.addAll(surface.getRenderableSeries(), rSeries); Collections.addAll(surface.getChartModifiers(), sciChartBuilder.newModifierGroupWithDefaultModifiers().build()); sciChartBuilder.newAnimator(rSeries).withSweepTransformation().withDuration(20000).withStartDelay(350).start(); } }); }