UNPKG

@bluecateng/pelagos-charts

Version:
61 lines 1.87 kB
import PropTypes from 'prop-types'; import { sum } from 'd3-array'; import { Layer } from '@bluecateng/pelagos'; import './Chart.less'; import getColorClass from './getColorClass'; import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; const getHintValue = d => d[1]; const MultiHint = ({ title, headerValue, values, groupIndex, showTotal, totalLabel, headerFormatter, groupFormatter, valueFormatter, getBgClass, variant, option }) => /*#__PURE__*/_jsxs(Layer, { as: "ul", className: "Chart Chart__hint", children: [/*#__PURE__*/_jsxs("li", { children: [/*#__PURE__*/_jsx("span", { children: title }), /*#__PURE__*/_jsx("span", { children: headerFormatter(headerValue) })] }), values == null ? void 0 : values.map(([group, value]) => /*#__PURE__*/_jsxs("li", { children: [/*#__PURE__*/_jsx("span", { className: `Chart__hintColor ${getBgClass(group, headerValue, value, getColorClass('bg', variant, option, groupIndex.get(group)))}` }), /*#__PURE__*/_jsx("span", { children: groupFormatter(group) }), /*#__PURE__*/_jsx("span", { children: valueFormatter(value) })] }, group)), showTotal && /*#__PURE__*/_jsxs("li", { children: [/*#__PURE__*/_jsx("span", { className: "Chart__hintTotal", children: totalLabel }), /*#__PURE__*/_jsx("span", { children: valueFormatter(values ? sum(values, getHintValue) : 0) })] })] }); MultiHint.propTypes = { title: PropTypes.string, headerValue: PropTypes.any, values: PropTypes.array, groupIndex: PropTypes.object, showTotal: PropTypes.bool, totalLabel: PropTypes.string, headerFormatter: PropTypes.func, groupFormatter: PropTypes.func, valueFormatter: PropTypes.func, getBgClass: PropTypes.func, variant: PropTypes.number, option: PropTypes.number }; export default MultiHint;