UNPKG

@alicloud/cloud-charts

Version:

![](https://img.shields.io/npm/v/@alicloud/cloud-charts?color=%23ff8200)

43 lines (37 loc) 1.74 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); exports.__esModule = true; exports["default"] = LegendMarker; var _react = _interopRequireDefault(require("react")); /** * 根据marker配置项绘制legend marker */ function LegendMarker(_ref) { var marker = _ref.marker, _ref$disable = _ref.disable, disable = _ref$disable === void 0 ? false : _ref$disable; var symbol = marker.symbol, style = marker.style; if (['line', 'smooth', 'hv'].includes(typeof symbol === 'string' ? symbol : symbol === null || symbol === void 0 ? void 0 : symbol.name)) { return /*#__PURE__*/_react["default"].createElement("div", { style: { width: 8, height: 2, background: style.stroke, opacity: disable ? 0.3 : 1 } }); } else { var _style$fill, _style$fill$split, _style$fill$split$, _style$stroke; // 处理渐变 var fill = style !== null && style !== void 0 && (_style$fill = style.fill) !== null && _style$fill !== void 0 && _style$fill.startsWith('l(') ? (_style$fill$split = style.fill.split(' ')) === null || _style$fill$split === void 0 ? void 0 : (_style$fill$split$ = _style$fill$split[1]) === null || _style$fill$split$ === void 0 ? void 0 : _style$fill$split$.slice(2) : style.fill; return /*#__PURE__*/_react["default"].createElement("div", { style: { width: 8, height: 8, background: (symbol === null || symbol === void 0 ? void 0 : symbol.name) === 'symbol' ? (_style$stroke = style === null || style === void 0 ? void 0 : style.stroke) !== null && _style$stroke !== void 0 ? _style$stroke : fill : fill, opacity: disable ? 0.3 : 1 } }); } }