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()); } }
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()); } }
final IAxis yAxis = sciChartBuilder.newNumericAxis().withGrowBy(0.2d, 0.2d).build(); final IXyDataSeries<Double, Double> originalData = sciChartBuilder.newXyDataSeries(Double.class, Double.class).withSeriesName("Original").build(); final IXyDataSeries<Double, Double> splineData = sciChartBuilder.newXyDataSeries(Double.class, Double.class).withSeriesName("Spline").build();
final IAxis yAxis = sciChartBuilder.newNumericAxis().withAutoRangeMode(AutoRange.Always).withGrowBy(0.05d, 0.05d).build(); final XyDataSeries<Double, Double> ds1 = sciChartBuilder.newXyDataSeries(Double.class, Double.class).withSeriesName("Green Series").build(); final XyDataSeries<Double, Double> ds2 = sciChartBuilder.newXyDataSeries(Double.class, Double.class).withSeriesName("Red Series").build(); final XyDataSeries<Double, Double> ds3 = sciChartBuilder.newXyDataSeries(Double.class, Double.class).withSeriesName("Grey Series").build(); final XyDataSeries<Double, Double> ds4 = sciChartBuilder.newXyDataSeries(Double.class, Double.class).withSeriesName("Gold Series").build();
double[] yValues3 = new double[]{20.0, 4.1, 4.2, 10.4, 10.8, 1.1, 11.5, 3.4, 4.6, 5.1, 5.7, 14.4, 16.0, 13.7, 10.1, 6.4, 3.5, 2.5, 1.4, 10.4, 8.1, 10.0, 15.0}; final IXyDataSeries<Double, Double> ds1 = sciChartBuilder.newXyDataSeries(Double.class, Double.class).withSeriesName("data 1").build(); final IXyDataSeries<Double, Double> ds2 = sciChartBuilder.newXyDataSeries(Double.class, Double.class).withSeriesName("data 2").build(); final IXyDataSeries<Double, Double> ds3 = sciChartBuilder.newXyDataSeries(Double.class, Double.class).withSeriesName("data 3").build();
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();
@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 CustomSeriesInfoProvider()).withStrokeStyle(0xff6495ed, 2, true).build(); final FastLineRenderableSeries lineRs2 = sciChartBuilder.newLineSeries().withDataSeries(ds2).withSeriesInfoProvider(new CustomSeriesInfoProvider()).withStrokeStyle(0xffe2460c, 2, true).build(); final CursorModifier cursorModifier = new CursorModifier(R.layout.example_custom_cursor_modifier_tooltip_container); 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(), cursorModifier); final DisplayMetrics displayMetrics = getActivity().getResources().getDisplayMetrics(); final float thickness = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 2f, displayMetrics); new SolidPenStyle(0xAAFFA500, false, thickness, null).initPaint(cursorModifier.getCrosshairPaint()); sciChartBuilder.newAnimator(lineRs1).withSweepTransformation().withInterpolator(new DecelerateInterpolator()).withDuration(3000).withStartDelay(350).start(); sciChartBuilder.newAnimator(lineRs2).withSweepTransformation().withInterpolator(new DecelerateInterpolator()).withDuration(3000).withStartDelay(350).start(); } }); }
final IAxis yAxis = sciChartBuilder.newNumericAxis().withGrowBy(0.1, 0.1).withAxisAlignment(AxisAlignment.Left).build(); final XyDataSeries<Double, Double> dataSeries1 = sciChartBuilder.newXyDataSeries(Double.class, Double.class).withSeriesName("Lissajous Curve").withAcceptsUnsortedData().build(); final XyDataSeries<Double, Double> dataSeries2 = sciChartBuilder.newXyDataSeries(Double.class, Double.class).withSeriesName("Sinewave").withAcceptsUnsortedData().build();
@Override protected void initExample() { final IAxis xAxis = sciChartBuilder.newNumericAxis().withAxisInfoProvider(new CustomAxisInfoProvider()).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(), sciChartBuilder.newModifierGroup().withRolloverModifier().build().build()); 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().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(); } }); }
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 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()); } }
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 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 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()); } }
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); } }
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 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); }