UNPKG

@alicloud/cloud-charts

Version:

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

41 lines (40 loc) 2.65 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, item = _ref.item; var symbol = marker.symbol, style = marker.style; if (['line', 'smooth', 'hv', 'circle'].includes(typeof symbol === 'string' ? symbol : symbol === null || symbol === void 0 ? void 0 : symbol.name)) { var _ref2, _ref3, _ref4, _item$marker$dataFill, _item$marker; return /*#__PURE__*/_react["default"].createElement("div", { style: { width: (symbol || (symbol === null || symbol === void 0 ? void 0 : symbol.name)) === 'circle' ? (_ref2 = (style === null || style === void 0 ? void 0 : style.r) * 2) !== null && _ref2 !== void 0 ? _ref2 : 6 : 8, height: (symbol || (symbol === null || symbol === void 0 ? void 0 : symbol.name)) === 'circle' ? (_ref3 = (style === null || style === void 0 ? void 0 : style.r) * 2) !== null && _ref3 !== void 0 ? _ref3 : 6 : 2, background: (_ref4 = (_item$marker$dataFill = item === null || item === void 0 ? void 0 : (_item$marker = item.marker) === null || _item$marker === void 0 ? void 0 : _item$marker.dataFill) !== null && _item$marker$dataFill !== void 0 ? _item$marker$dataFill : style.stroke) !== null && _ref4 !== void 0 ? _ref4 : style.fill, opacity: disable ? 0.3 : 1, borderRadius: (symbol || (symbol === null || symbol === void 0 ? void 0 : symbol.name)) === 'circle' ? '50%' : 0 } }); } 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, 9) : 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 } }); } }