UNPKG

react-sparklines-typescript

Version:

react-sparklines rewritten in typescript and modern react patterns

59 lines 3 kB
"use strict"; var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); var react_1 = __importDefault(require("react")); var dataToPoints_1 = __importDefault(require("./dataProcessing/dataToPoints")); var SparklinesBars_1 = __importDefault(require("./SparklinesBars")); exports.SparklinesBars = SparklinesBars_1.default; var SparklinesNormalBand_1 = __importDefault(require("./SparklinesNormalBand")); exports.SparklinesNormalBand = SparklinesNormalBand_1.default; var SparklinesReferenceLine_1 = __importDefault(require("./SparklinesReferenceLine")); exports.SparklinesReferenceLine = SparklinesReferenceLine_1.default; var SparklinesLine_1 = __importDefault(require("./SparklinesLine")); exports.SparklinesLine = SparklinesLine_1.default; var SparklinesSpots_1 = __importDefault(require("./SparklinesSpots")); exports.SparklinesSpots = SparklinesSpots_1.default; var SparklinesText_1 = __importDefault(require("./SparklinesText")); exports.SparklinesText = SparklinesText_1.default; var SparklinesCurve_1 = __importDefault(require("./SparklinesCurve")); exports.SparklinesCurve = SparklinesCurve_1.default; var Sparklines = function (props) { var _a = props.data, data = _a === void 0 ? [] : _a, limit = props.limit, _b = props.width, width = _b === void 0 ? 240 : _b, _c = props.height, height = _c === void 0 ? 60 : _c, _d = props.preserveAspectRatio, preserveAspectRatio = _d === void 0 ? "none" : _d, _e = props.margin, margin = _e === void 0 ? 2 : _e, svgWidth = props.svgWidth, svgHeight = props.svgHeight, style = props.style, max = props.max, min = props.min; if (data.length === 0) { return null; } var points = dataToPoints_1.default({ data: data, limit: limit, width: width, height: height, margin: margin, max: max, min: min }); var svgOpts = { style: style, viewBox: "0 0 " + width + " " + height, preserveAspectRatio: preserveAspectRatio, }; if (svgWidth && svgWidth > 0) svgOpts.width = svgWidth; if (svgHeight && svgHeight > 0) svgOpts.height = svgHeight; return (react_1.default.createElement("svg", __assign({}, svgOpts), react_1.default.Children.map(props.children, function (child) { return react_1.default.cloneElement(child, { data: data, points: points, width: width, height: height, margin: margin, }); }))); }; exports.Sparklines = Sparklines; //# sourceMappingURL=Sparklines.js.map