How to use the d3fc.annotation 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 / 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];
                });
github ScottLogic / StockFlux / packages / stockflux-bitflux / src / assets / js / chart / primary.js View on Github external
var crosshair = fc.tool.crosshair()
      .xLabel('')
      .yLabel('')
      .on('trackingmove', function(updatedCrosshairData) {
          if (updatedCrosshairData.length > 0) {
              dispatch.crosshairChange(updatedCrosshairData[0].datum);
          } else {
              dispatch.crosshairChange(undefined);
          }
      })
      .on('trackingend', function() {
          dispatch.crosshairChange(undefined);
      });
    crosshair.id = util.uid();

    var gridlines = fc.annotation.gridline()
      .xTicks(0);
    var closeLine = fc.annotation.line()
      .orient('horizontal')
      .value(currentYValueAccessor)
      .label('')
      .decorate(function(g) {
          g.classed('close-line', true);
      });
    closeLine.id = util.uid();

    var multi = fc.series.multi()
        .key(function(series) { return series.id; })
        .mapping(function(series) {
            switch (series) {
            case closeLine:
                return [this.data[this.data.length - 1]];
github ScottLogic / StockFlux / packages / stockflux-bitflux / src / assets / js / chart / primary.js View on Github external
.yLabel('')
      .on('trackingmove', function(updatedCrosshairData) {
          if (updatedCrosshairData.length > 0) {
              dispatch.crosshairChange(updatedCrosshairData[0].datum);
          } else {
              dispatch.crosshairChange(undefined);
          }
      })
      .on('trackingend', function() {
          dispatch.crosshairChange(undefined);
      });
    crosshair.id = util.uid();

    var gridlines = fc.annotation.gridline()
      .xTicks(0);
    var closeLine = fc.annotation.line()
      .orient('horizontal')
      .value(currentYValueAccessor)
      .label('')
      .decorate(function(g) {
          g.classed('close-line', true);
      });
    closeLine.id = util.uid();

    var multi = fc.series.multi()
        .key(function(series) { return series.id; })
        .mapping(function(series) {
            switch (series) {
            case closeLine:
                return [this.data[this.data.length - 1]];
            case crosshair:
                return crosshairData;