UNPKG

@symblight/react-stockcharts

Version:

Highly customizable stock charts with ReactJS and d3

109 lines (91 loc) 4.12 kB
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } import React, { Component } from "react"; import PropTypes from "prop-types"; import LineSeries from "./LineSeries"; import StraightLine from "./StraightLine"; var ADXSeries = function (_Component) { _inherits(ADXSeries, _Component); function ADXSeries(props) { _classCallCheck(this, ADXSeries); var _this = _possibleConstructorReturn(this, (ADXSeries.__proto__ || Object.getPrototypeOf(ADXSeries)).call(this, props)); _this.yAccessorForPD = _this.yAccessorForPD.bind(_this); _this.yAccessorForMD = _this.yAccessorForMD.bind(_this); _this.yAccessorForADX = _this.yAccessorForADX.bind(_this); return _this; } _createClass(ADXSeries, [{ key: "yAccessorForPD", value: function yAccessorForPD(d) { var yAccessor = this.props.yAccessor; return yAccessor(d) && yAccessor(d).plusDI; } }, { key: "yAccessorForMD", value: function yAccessorForMD(d) { var yAccessor = this.props.yAccessor; return yAccessor(d) && yAccessor(d).minusDI; } }, { key: "yAccessorForADX", value: function yAccessorForADX(d) { var yAccessor = this.props.yAccessor; return yAccessor(d) && yAccessor(d).adxValue; } }, { key: "render", value: function render() { var _props = this.props, className = _props.className, stroke = _props.stroke, refLineOpacity = _props.refLineOpacity; var _props2 = this.props, overSold = _props2.overSold, middle = _props2.middle, overBought = _props2.overBought; return React.createElement( "g", { className: className }, React.createElement(LineSeries, { yAccessor: this.yAccessorForPD, stroke: stroke.dLine, fill: "none" }), React.createElement(LineSeries, { yAccessor: this.yAccessorForMD, stroke: stroke.kLine, fill: "none" }), React.createElement(LineSeries, { yAccessor: this.yAccessorForADX, stroke: stroke.ALine, fill: "none" }) ); } }]); return ADXSeries; }(Component); ADXSeries.propTypes = { className: PropTypes.string, yAccessor: PropTypes.func.isRequired, stroke: PropTypes.shape({ dLine: PropTypes.string.isRequired, kLine: PropTypes.string.isRequired, ALine: PropTypes.string.isRequired }).isRequired, overSold: PropTypes.number.isRequired, middle: PropTypes.number.isRequired, overBought: PropTypes.number.isRequired, refLineOpacity: PropTypes.number.isRequired }; ADXSeries.defaultProps = { className: "react-stockcharts-stochastic-series", stroke: { dLine: "#EA2BFF", kLine: "#74D400", ALine: "#ff0000" }, overSold: 100, middle: 50, overBought: 20, refLineOpacity: 0.3 }; export default ADXSeries; //# sourceMappingURL=ADXSeries.js.map