UNPKG

@antv/thumbnails-component

Version:

React Component for Thumbnails of Chart Types.

25 lines 1.08 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Thumbnail = void 0; var tslib_1 = require("tslib"); var React = (0, tslib_1.__importStar)(require("react")); var thumbnails_1 = (0, tslib_1.__importDefault)(require("@antv/thumbnails")); var Thumbnail = function (props) { var _a; var chart = props.chart, svg = props.svg, otherProps = (0, tslib_1.__rest)(props, ["chart", "svg"]); // default no-chart-img var src = 'https://gw.alipayobjects.com/zos/antfincdn/lP6YFnCEjy/nochartimg.svg'; // `svg` overwrites `chart` if (svg) { src = "data:image/svg+xml;utf8,".concat(encodeURIComponent(svg)); } else if (chart) { var svgForChart = (_a = thumbnails_1.default[chart]) === null || _a === void 0 ? void 0 : _a.svgCode; if (svgForChart) { src = "data:image/svg+xml;utf8,".concat(encodeURIComponent(svgForChart)); } } return React.createElement("img", (0, tslib_1.__assign)({ src: src }, otherProps)); }; exports.Thumbnail = Thumbnail; //# sourceMappingURL=Thumbnail.js.map