A quick example to show how multiple moving averages can be applied to a chart. By default, the d3fc algorithms write the results back onto the datapoint within the supplied series data. Therefore, if you apply the the same algorithm, the results will be overwritten.
This behaviour can be changed by supplying merge
function that allows you to change where the results are stored:
// compute a 20 point ema
var ema20 = fc.indicator.algorithm.exponentialMovingAverage()
.value(function(d) { return d.close; })
// the merge function describes how the ema is 'stored' in each datapoint
.merge(function(datum, ema) { datum.ema20 = ema; })
.windowSize(20);
Modified http://colineberhardt.github.io/d3fc/Layout.js to a secure url
Modified http://colineberhardt.github.io/d3fc/d3fc.js to a secure url
https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js
https://colineberhardt.github.io/d3fc/Layout.js
https://colineberhardt.github.io/d3fc/d3fc.js