UNPKG

zhu-jiang-yi-yuan-mobile

Version:

南方医科大学珠江医院移动端

87 lines (76 loc) 2.53 kB
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } import { Const } from '../../utils'; import { Axis, Chart, Coordinate, Interaction, Interval, Legend, Tooltip } from 'bizcharts'; import { NConst } from 'nsn-const'; import { NType } from 'nsn-util'; import React from 'react'; import { Title } from '../title'; import './index.less'; var CLS_PREFIX = "".concat(Const.CLS_PREFIX, "-pie"); var Pie = function Pie(props) { var _props$data = props.data, data = _props$data === void 0 ? [] : _props$data, title = props.title, className = props.className; var axis = { x: 'name', y: 'value' }; var _formatter = function formatter(val, key) { var keyText = "".concat(key ? "".concat(key, "\uFF1A") : NConst.EMPTY); if (val) { if (NType.isNumber(val)) { return "".concat(keyText).concat((val * 100).toFixed(0), "%"); } if (NType.isString(val)) { return "".concat(keyText).concat((parseFloat(val) * 100).toFixed(0), "%"); } return "".concat(keyText).concat(val); } return "".concat(keyText).concat(NConst.DASHED); }; // var chartScale = _defineProperty({}, axis.y, { formatter: function formatter(val) { return _formatter(val); } }); return /*#__PURE__*/React.createElement("div", { className: "".concat(CLS_PREFIX, " ").concat(className || NConst.EMPTY) }, /*#__PURE__*/React.createElement(Title, { text: title }), /*#__PURE__*/React.createElement(Chart, Object.assign({}, { data: data }, { height: 150, scale: chartScale, renderer: "svg", autoFit: true, padding: [5, 5, 5, 5] }), /*#__PURE__*/React.createElement(Coordinate, { type: "theta", radius: 0.75 }), /*#__PURE__*/React.createElement(Tooltip, { showTitle: false }), /*#__PURE__*/React.createElement(Axis, { visible: false }), /*#__PURE__*/React.createElement(Legend, { visible: false }), /*#__PURE__*/React.createElement(Interval, { position: axis.y, adjust: "stack", color: axis.x, style: { lineWidth: 1, stroke: '#fff' }, label: [axis.y, { offset: 15, content: function content(data) { return _formatter(data[axis.y], data[axis.x]); } }] }), /*#__PURE__*/React.createElement(Interaction, { type: 'element-single-selected' }))); }; export { Pie };