ct-react-stockcharts
Version:
Highly customizable stock charts with ReactJS and d3
47 lines (35 loc) • 867 B
JavaScript
import { merge, slidingWindow, identity } from "../utils";
export default function () {
var windowSize = 1,
accumulator = identity,
mergeAs = identity;
function algorithm(data) {
var defaultAlgorithm = slidingWindow().windowSize(windowSize).accumulator(accumulator);
var calculator = merge().algorithm(defaultAlgorithm).merge(mergeAs);
var newData = calculator(data);
return newData;
}
algorithm.accumulator = function (x) {
if (!arguments.length) {
return accumulator;
}
accumulator = x;
return algorithm;
};
algorithm.windowSize = function (x) {
if (!arguments.length) {
return windowSize;
}
windowSize = x;
return algorithm;
};
algorithm.merge = function (x) {
if (!arguments.length) {
return mergeAs;
}
mergeAs = x;
return algorithm;
};
return algorithm;
}
//# sourceMappingURL=index.js.map