UNPKG

@alicloud/cloud-charts

Version:

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

52 lines (43 loc) 1.67 kB
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose"; import { CategoryLegend } from '@antv/g2/esm/dependents'; import ReactDOM from 'react-dom'; import React from 'react'; import TableLegend from './TableLegend'; import FoldableLegend from './FoldableLegend'; // @ts-ignore var ReactLegend = /*#__PURE__*/function (_CategoryLegend) { _inheritsLoose(ReactLegend, _CategoryLegend); function ReactLegend(props) { var _this; var cfg = props.cfg, container = props.container, chart = props.chart, legendConfig = props.legendConfig; _this = _CategoryLegend.call(this, cfg) || this; _this.container = void 0; _this.chart = void 0; _this.legendConfig = void 0; _this.container = container; _this.chart = chart; _this.legendConfig = legendConfig; return _this; } var _proto = ReactLegend.prototype; _proto.drawLegendContent = function drawLegendContent(group) { var _this$legendConfig; var items = this.get('items'); // const currentPoint = this.get('currentPoint'); // const startX = currentPoint.x; // const startY = currentPoint.y; var legend = (_this$legendConfig = this.legendConfig) !== null && _this$legendConfig !== void 0 && _this$legendConfig.table ? /*#__PURE__*/React.createElement(TableLegend, { config: this.legendConfig, legendItems: items, chart: this.chart }) : /*#__PURE__*/React.createElement(FoldableLegend, { config: this.legendConfig, legendItems: items, chart: this.chart }); ReactDOM.render(legend, this.container); }; return ReactLegend; }(CategoryLegend); export default ReactLegend;