How to use the d3fc.indicator function in d3fc

To help you get started, we’ve selected a few d3fc examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ScottLogic / StockFlux / packages / stockflux-bitflux / src / assets / js / chart / primary.js View on Github external
right: yAxisWidth
      })
      .decorate(function(selection) {
          selection.enter()
              .selectAll('defs')
              .data([0])
              .enter()
              .append('defs')
              .html('');
      });

    // Create and apply the Moving Average
    var movingAverage = fc.indicator.algorithm.movingAverage();
    var bollingerAlgorithm = fc.indicator.algorithm.bollingerBands();

    function updateMultiSeries() {
        var baseChart = [gridlines, currentSeries.option, closeLine];
        var indicators = currentIndicators.map(function(indicator) { return indicator.option; });
        return baseChart.concat(indicators, crosshair);
    }

    function updateYValueAccessorUsed() {
        movingAverage.value(currentYValueAccessor);
        bollingerAlgorithm.value(currentYValueAccessor);
        closeLine.value(currentYValueAccessor);
        switch (currentSeries.valueString) {
        case 'line':
        case 'point':
            currentSeries.option.yValue(currentYValueAccessor);
github ScottLogic / StockFlux / packages / stockflux-bitflux / src / assets / js / chart / primary.js View on Github external
})
      .decorate(function(selection) {
          selection.enter()
              .selectAll('defs')
              .data([0])
              .enter()
              .append('defs')
              .html('');
      });

    // Create and apply the Moving Average
    var movingAverage = fc.indicator.algorithm.movingAverage();
    var bollingerAlgorithm = fc.indicator.algorithm.bollingerBands();

    function updateMultiSeries() {
        var baseChart = [gridlines, currentSeries.option, closeLine];
        var indicators = currentIndicators.map(function(indicator) { return indicator.option; });
        return baseChart.concat(indicators, crosshair);
    }

    function updateYValueAccessorUsed() {
        movingAverage.value(currentYValueAccessor);
        bollingerAlgorithm.value(currentYValueAccessor);
        closeLine.value(currentYValueAccessor);
        switch (currentSeries.valueString) {
        case 'line':
        case 'point':
            currentSeries.option.yValue(currentYValueAccessor);
            break;
github ScottLogic / StockFlux / packages / stockflux-bitflux / src / assets / js / chart / secondary / rsi.js View on Github external
export default function() {
    var dispatch = d3.dispatch(event.viewChange);
    var renderer = fc.indicator.renderer.relativeStrengthIndex();
    var algorithm = fc.indicator.algorithm.relativeStrengthIndex()
        .value(function(d) { return d.close; });
    var tickValues = [renderer.lowerValue(), 50, renderer.upperValue()];

    var chart = base()
        .series([renderer])
        .yTickValues(tickValues)
        .on(event.viewChange, function(domain) {
            dispatch[event.viewChange](domain);
        });

    function rsi(selection) {
        var model = selection.datum();
        algorithm(model.data);

        chart.trackingLatest(model.trackingLatest)
github ScottLogic / StockFlux / packages / stockflux-bitflux / src / assets / js / chart / secondary / rsi.js View on Github external
export default function() {
    var dispatch = d3.dispatch(event.viewChange);
    var renderer = fc.indicator.renderer.relativeStrengthIndex();
    var algorithm = fc.indicator.algorithm.relativeStrengthIndex()
        .value(function(d) { return d.close; });
    var tickValues = [renderer.lowerValue(), 50, renderer.upperValue()];

    var chart = base()
        .series([renderer])
        .yTickValues(tickValues)
        .on(event.viewChange, function(domain) {
            dispatch[event.viewChange](domain);
        });

    function rsi(selection) {
        var model = selection.datum();
        algorithm(model.data);

        chart.trackingLatest(model.trackingLatest)
            .xDomain(model.viewDomain)
github ScottLogic / StockFlux / packages / stockflux-bitflux / src / assets / js / initialiseModel.js View on Github external
return d.movingAverage;
      });
    movingAverage.id = util.uid();

    var movingAverageOption = model.menu.option(
      'Moving Average',
      'movingAverage',
      movingAverage,
      'bf-icon-moving-average-indicator',
      true
    );
    movingAverageOption.option.extentAccessor = function(d) {
      return d.movingAverage;
    };

    var bollingerBands = fc.indicator.renderer.bollingerBands();
    bollingerBands.id = util.uid();

    var bollingerBandsOption = model.menu.option(
      'Bollinger Bands',
      'bollinger',
      bollingerBands,
      'bf-icon-bollinger-bands-indicator',
      true
    );
    bollingerBandsOption.option.extentAccessor = [
      function(d) {
        return d.bollingerBands.lower;
      },
      function(d) {
        return d.bollingerBands.upper;
      }
github ScottLogic / StockFlux / packages / stockflux-bitflux / src / assets / js / chart / secondary / macd.js View on Github external
export default function() {
    var dispatch = d3.dispatch(event.viewChange);
    var zeroLine = fc.annotation.line()
        .value(0)
        .label('');
    var renderer = fc.indicator.renderer.macd();
    var algorithm = fc.indicator.algorithm.macd();

    var chart = base()
        .series([zeroLine, renderer])
        .yTicks(5)
        .mapping(function(series) {
            return series === zeroLine ? [0] : this;
        })
        .decorate(function(g) {
            g.enter()
                .attr('class', function(d, i) {
                    return ['multi zero', 'multi'][i];
                });
        })
        .on(event.viewChange, function(domain) {
            dispatch[event.viewChange](domain);
        });
github ScottLogic / StockFlux / packages / stockflux-bitflux / src / assets / js / chart / secondary / macd.js View on Github external
export default function() {
    var dispatch = d3.dispatch(event.viewChange);
    var zeroLine = fc.annotation.line()
        .value(0)
        .label('');
    var renderer = fc.indicator.renderer.macd();
    var algorithm = fc.indicator.algorithm.macd();

    var chart = base()
        .series([zeroLine, renderer])
        .yTicks(5)
        .mapping(function(series) {
            return series === zeroLine ? [0] : this;
        })
        .decorate(function(g) {
            g.enter()
                .attr('class', function(d, i) {
                    return ['multi zero', 'multi'][i];
                });
        })
        .on(event.viewChange, function(domain) {
            dispatch[event.viewChange](domain);