UNPKG

@mui/x-charts

Version:

The community edition of the charts components (MUI X).

384 lines (383 loc) 17.3 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports.ScatterChart = void 0; var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")); var React = _interopRequireWildcard(require("react")); var _propTypes = _interopRequireDefault(require("prop-types")); var _ScatterPlot = require("./ScatterPlot"); var _ResponsiveChartContainer = require("../ResponsiveChartContainer"); var _ChartsAxis = require("../ChartsAxis"); var _ChartsTooltip = require("../ChartsTooltip"); var _ChartsLegend = require("../ChartsLegend"); var _ChartsAxisHighlight = require("../ChartsAxisHighlight"); var _ChartsVoronoiHandler = require("../ChartsVoronoiHandler/ChartsVoronoiHandler"); var _jsxRuntime = require("react/jsx-runtime"); function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); } function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; } /** * Demos: * * - [Scatter](https://mui.com/x/react-charts/scatter/) * - [Scatter demonstration](https://mui.com/x/react-charts/scatter-demo/) * * API: * * - [ScatterChart API](https://mui.com/x/api/charts/scatter-chart/) */ const ScatterChart = exports.ScatterChart = /*#__PURE__*/React.forwardRef(function ScatterChart(props, ref) { const { xAxis, yAxis, series, tooltip, axisHighlight, voronoiMaxRadius, disableVoronoi, legend, width, height, margin, colors, sx, topAxis, leftAxis, rightAxis, bottomAxis, children, slots, slotProps } = props; return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_ResponsiveChartContainer.ResponsiveChartContainer, { ref: ref, series: series.map(s => (0, _extends2.default)({ type: 'scatter' }, s)), width: width, height: height, margin: margin, colors: colors, xAxis: xAxis, yAxis: yAxis, sx: sx, children: [!disableVoronoi && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsVoronoiHandler.ChartsVoronoiHandler, { voronoiMaxRadius: voronoiMaxRadius }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsAxis.ChartsAxis, { topAxis: topAxis, leftAxis: leftAxis, rightAxis: rightAxis, bottomAxis: bottomAxis, slots: slots, slotProps: slotProps }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ScatterPlot.ScatterPlot, { slots: slots, slotProps: slotProps }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsLegend.ChartsLegend, (0, _extends2.default)({}, legend, { slots: slots, slotProps: slotProps })), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsAxisHighlight.ChartsAxisHighlight, (0, _extends2.default)({ x: "none", y: "none" }, axisHighlight)), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsTooltip.ChartsTooltip, (0, _extends2.default)({ trigger: "item" }, tooltip)), children] }); }); process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = { // ----------------------------- Warning -------------------------------- // | These PropTypes are generated from the TypeScript type definitions | // | To update them edit the TypeScript types and run "yarn proptypes" | // ---------------------------------------------------------------------- axisHighlight: _propTypes.default.shape({ x: _propTypes.default.oneOf(['band', 'line', 'none']), y: _propTypes.default.oneOf(['band', 'line', 'none']) }), /** * Indicate which axis to display the bottom of the charts. * Can be a string (the id of the axis) or an object `ChartsXAxisProps`. * @default xAxisIds[0] The id of the first provided axis */ bottomAxis: _propTypes.default.oneOfType([_propTypes.default.shape({ axisId: _propTypes.default.string, classes: _propTypes.default.object, disableLine: _propTypes.default.bool, disableTicks: _propTypes.default.bool, fill: _propTypes.default.string, label: _propTypes.default.string, labelFontSize: _propTypes.default.number, labelStyle: _propTypes.default.object, position: _propTypes.default.oneOf(['bottom', 'top']), slotProps: _propTypes.default.object, slots: _propTypes.default.object, stroke: _propTypes.default.string, tickFontSize: _propTypes.default.number, tickInterval: _propTypes.default.oneOfType([_propTypes.default.oneOf(['auto']), _propTypes.default.array, _propTypes.default.func]), tickLabelInterval: _propTypes.default.oneOfType([_propTypes.default.oneOf(['auto']), _propTypes.default.func]), tickLabelStyle: _propTypes.default.object, tickMaxStep: _propTypes.default.number, tickMinStep: _propTypes.default.number, tickNumber: _propTypes.default.number, tickSize: _propTypes.default.number }), _propTypes.default.string]), children: _propTypes.default.node, className: _propTypes.default.string, /** * Color palette used to colorize multiple series. */ colors: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.string), _propTypes.default.func]), /** * An array of objects that can be used to populate series and axes data using their `dataKey` property. */ dataset: _propTypes.default.arrayOf(_propTypes.default.object), desc: _propTypes.default.string, /** * If `true`, the charts will not listen to the mouse move event. * It might break interactive features, but will improve performance. * @default false */ disableAxisListener: _propTypes.default.bool, /** * If true, the interaction will not use the Voronoi cell and fall back to hover events. * @default false */ disableVoronoi: _propTypes.default.bool, /** * The height of the chart in px. If not defined, it takes the height of the parent element. * @default undefined */ height: _propTypes.default.number, /** * Indicate which axis to display the left of the charts. * Can be a string (the id of the axis) or an object `ChartsYAxisProps`. * @default yAxisIds[0] The id of the first provided axis */ leftAxis: _propTypes.default.oneOfType([_propTypes.default.shape({ axisId: _propTypes.default.string, classes: _propTypes.default.object, disableLine: _propTypes.default.bool, disableTicks: _propTypes.default.bool, fill: _propTypes.default.string, label: _propTypes.default.string, labelFontSize: _propTypes.default.number, labelStyle: _propTypes.default.object, position: _propTypes.default.oneOf(['left', 'right']), slotProps: _propTypes.default.object, slots: _propTypes.default.object, stroke: _propTypes.default.string, tickFontSize: _propTypes.default.number, tickInterval: _propTypes.default.oneOfType([_propTypes.default.oneOf(['auto']), _propTypes.default.array, _propTypes.default.func]), tickLabelInterval: _propTypes.default.oneOfType([_propTypes.default.oneOf(['auto']), _propTypes.default.func]), tickLabelStyle: _propTypes.default.object, tickMaxStep: _propTypes.default.number, tickMinStep: _propTypes.default.number, tickNumber: _propTypes.default.number, tickSize: _propTypes.default.number }), _propTypes.default.string]), /** * @deprecated Consider using `slotProps.legend` instead. */ legend: _propTypes.default.shape({ classes: _propTypes.default.object, direction: _propTypes.default.oneOf(['column', 'row']), hidden: _propTypes.default.bool, position: _propTypes.default.shape({ horizontal: _propTypes.default.oneOf(['left', 'middle', 'right']).isRequired, vertical: _propTypes.default.oneOf(['bottom', 'middle', 'top']).isRequired }), slotProps: _propTypes.default.object, slots: _propTypes.default.object }), /** * The margin between the SVG and the drawing area. * It's used for leaving some space for extra information such as the x- and y-axis or legend. * Accepts an object with the optional properties: `top`, `bottom`, `left`, and `right`. * @default object Depends on the charts type. */ margin: _propTypes.default.shape({ bottom: _propTypes.default.number, left: _propTypes.default.number, right: _propTypes.default.number, top: _propTypes.default.number }), /** * Indicate which axis to display the right of the charts. * Can be a string (the id of the axis) or an object `ChartsYAxisProps`. * @default null */ rightAxis: _propTypes.default.oneOfType([_propTypes.default.shape({ axisId: _propTypes.default.string, classes: _propTypes.default.object, disableLine: _propTypes.default.bool, disableTicks: _propTypes.default.bool, fill: _propTypes.default.string, label: _propTypes.default.string, labelFontSize: _propTypes.default.number, labelStyle: _propTypes.default.object, position: _propTypes.default.oneOf(['left', 'right']), slotProps: _propTypes.default.object, slots: _propTypes.default.object, stroke: _propTypes.default.string, tickFontSize: _propTypes.default.number, tickInterval: _propTypes.default.oneOfType([_propTypes.default.oneOf(['auto']), _propTypes.default.array, _propTypes.default.func]), tickLabelInterval: _propTypes.default.oneOfType([_propTypes.default.oneOf(['auto']), _propTypes.default.func]), tickLabelStyle: _propTypes.default.object, tickMaxStep: _propTypes.default.number, tickMinStep: _propTypes.default.number, tickNumber: _propTypes.default.number, tickSize: _propTypes.default.number }), _propTypes.default.string]), series: _propTypes.default.arrayOf(_propTypes.default.shape({ color: _propTypes.default.string, data: _propTypes.default.arrayOf(_propTypes.default.shape({ id: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]).isRequired, x: _propTypes.default.number.isRequired, y: _propTypes.default.number.isRequired })).isRequired, disableHover: _propTypes.default.bool, highlightScope: _propTypes.default.shape({ faded: _propTypes.default.oneOf(['global', 'none', 'series']), highlighted: _propTypes.default.oneOf(['item', 'none', 'series']) }), id: _propTypes.default.string, label: _propTypes.default.string, markerSize: _propTypes.default.number, type: _propTypes.default.oneOf(['scatter']), valueFormatter: _propTypes.default.func, xAxisKey: _propTypes.default.string, yAxisKey: _propTypes.default.string })).isRequired, /** * The props used for each component slot. * @default {} */ slotProps: _propTypes.default.object, /** * Overridable component slots. * @default {} */ slots: _propTypes.default.object, sx: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object, _propTypes.default.bool])), _propTypes.default.func, _propTypes.default.object]), title: _propTypes.default.string, tooltip: _propTypes.default.shape({ axisContent: _propTypes.default.elementType, classes: _propTypes.default.object, itemContent: _propTypes.default.elementType, slotProps: _propTypes.default.object, slots: _propTypes.default.object, trigger: _propTypes.default.oneOf(['axis', 'item', 'none']) }), /** * Indicate which axis to display the top of the charts. * Can be a string (the id of the axis) or an object `ChartsXAxisProps`. * @default null */ topAxis: _propTypes.default.oneOfType([_propTypes.default.shape({ axisId: _propTypes.default.string, classes: _propTypes.default.object, disableLine: _propTypes.default.bool, disableTicks: _propTypes.default.bool, fill: _propTypes.default.string, label: _propTypes.default.string, labelFontSize: _propTypes.default.number, labelStyle: _propTypes.default.object, position: _propTypes.default.oneOf(['bottom', 'top']), slotProps: _propTypes.default.object, slots: _propTypes.default.object, stroke: _propTypes.default.string, tickFontSize: _propTypes.default.number, tickInterval: _propTypes.default.oneOfType([_propTypes.default.oneOf(['auto']), _propTypes.default.array, _propTypes.default.func]), tickLabelInterval: _propTypes.default.oneOfType([_propTypes.default.oneOf(['auto']), _propTypes.default.func]), tickLabelStyle: _propTypes.default.object, tickMaxStep: _propTypes.default.number, tickMinStep: _propTypes.default.number, tickNumber: _propTypes.default.number, tickSize: _propTypes.default.number }), _propTypes.default.string]), viewBox: _propTypes.default.shape({ height: _propTypes.default.number, width: _propTypes.default.number, x: _propTypes.default.number, y: _propTypes.default.number }), /** * Defines the maximal distance between a scatter point and the pointer that triggers the interaction. * If `undefined`, the radius is assumed to be infinite. * @default undefined */ voronoiMaxRadius: _propTypes.default.number, /** * The width of the chart in px. If not defined, it takes the width of the parent element. * @default undefined */ width: _propTypes.default.number, /** * The configuration of the x-axes. * If not provided, a default axis config is used with id set to `DEFAULT_X_AXIS_KEY`. */ xAxis: _propTypes.default.arrayOf(_propTypes.default.shape({ axisId: _propTypes.default.string, classes: _propTypes.default.object, data: _propTypes.default.array, dataKey: _propTypes.default.string, disableLine: _propTypes.default.bool, disableTicks: _propTypes.default.bool, fill: _propTypes.default.string, hideTooltip: _propTypes.default.bool, id: _propTypes.default.string, label: _propTypes.default.string, labelFontSize: _propTypes.default.number, labelStyle: _propTypes.default.object, max: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]), min: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]), position: _propTypes.default.oneOf(['bottom', 'left', 'right', 'top']), scaleType: _propTypes.default.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']), slotProps: _propTypes.default.object, slots: _propTypes.default.object, stroke: _propTypes.default.string, tickFontSize: _propTypes.default.number, tickInterval: _propTypes.default.oneOfType([_propTypes.default.oneOf(['auto']), _propTypes.default.array, _propTypes.default.func]), tickLabelInterval: _propTypes.default.oneOfType([_propTypes.default.oneOf(['auto']), _propTypes.default.func]), tickLabelStyle: _propTypes.default.object, tickMaxStep: _propTypes.default.number, tickMinStep: _propTypes.default.number, tickNumber: _propTypes.default.number, tickSize: _propTypes.default.number, valueFormatter: _propTypes.default.func })), /** * The configuration of the y-axes. * If not provided, a default axis config is used with id set to `DEFAULT_Y_AXIS_KEY`. */ yAxis: _propTypes.default.arrayOf(_propTypes.default.shape({ axisId: _propTypes.default.string, classes: _propTypes.default.object, data: _propTypes.default.array, dataKey: _propTypes.default.string, disableLine: _propTypes.default.bool, disableTicks: _propTypes.default.bool, fill: _propTypes.default.string, hideTooltip: _propTypes.default.bool, id: _propTypes.default.string, label: _propTypes.default.string, labelFontSize: _propTypes.default.number, labelStyle: _propTypes.default.object, max: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]), min: _propTypes.default.oneOfType([_propTypes.default.instanceOf(Date), _propTypes.default.number]), position: _propTypes.default.oneOf(['bottom', 'left', 'right', 'top']), scaleType: _propTypes.default.oneOf(['band', 'linear', 'log', 'point', 'pow', 'sqrt', 'time', 'utc']), slotProps: _propTypes.default.object, slots: _propTypes.default.object, stroke: _propTypes.default.string, tickFontSize: _propTypes.default.number, tickInterval: _propTypes.default.oneOfType([_propTypes.default.oneOf(['auto']), _propTypes.default.array, _propTypes.default.func]), tickLabelInterval: _propTypes.default.oneOfType([_propTypes.default.oneOf(['auto']), _propTypes.default.func]), tickLabelStyle: _propTypes.default.object, tickMaxStep: _propTypes.default.number, tickMinStep: _propTypes.default.number, tickNumber: _propTypes.default.number, tickSize: _propTypes.default.number, valueFormatter: _propTypes.default.func })) } : void 0;