Add settings page for managing forecasting API key and URL via UI

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
jtricerolph 2026-07-20 14:37:36 +00:00
parent cae411eae7
commit 1c411e402e
19809 changed files with 1962608 additions and 97 deletions

View file

@ -0,0 +1,22 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.RechartsReduxContext = void 0;
var _react = require("react");
/*
* This is a copy of the React-Redux context type, but with our own store type.
* We could import directly from react-redux like this:
* import { ReactReduxContextValue } from 'react-redux/src/components/Context';
* but that makes typescript angry with some errors I am not sure how to resolve
* so copy it is.
*/
/**
* We need to use our own independent Redux context because we need to avoid interfering with other people's Redux stores
* in case they decide to install and use Recharts in another Redux app which is likely to happen.
*
* https://react-redux.js.org/using-react-redux/accessing-store#providing-custom-context
*/
var RechartsReduxContext = exports.RechartsReduxContext = /*#__PURE__*/(0, _react.createContext)(null);

View file

@ -0,0 +1,52 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.RechartsStoreProvider = RechartsStoreProvider;
var _react = _interopRequireWildcard(require("react"));
var React = _react;
var _reactRedux = require("react-redux");
var _store = require("./store");
var _PanoramaContext = require("../context/PanoramaContext");
var _RechartsReduxContext = require("./RechartsReduxContext");
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
function RechartsStoreProvider(_ref) {
var preloadedState = _ref.preloadedState,
children = _ref.children,
reduxStoreName = _ref.reduxStoreName;
var isPanorama = (0, _PanoramaContext.useIsPanorama)();
/*
* Why the ref? Redux official documentation recommends to use store as a singleton,
* and reuse that everywhere: https://redux-toolkit.js.org/api/configureStore#basic-example
*
* Which is correct! Except that is considering deploying Redux in an app.
* Recharts as a library supports multiple charts on the same page.
* And each of these charts needs its own store independent of others!
*
* The alternative is to have everything in the store keyed by the chart id.
* Which would make working with everything a little bit more painful because we need the chart id everywhere.
*/
var storeRef = (0, _react.useRef)(null);
/*
* Panorama means that this chart is not its own chart, it's only a "preview"
* being rendered as a child of Brush.
* In such case, it should not have a store on its own - it should implicitly inherit
* whatever data is in the "parent" or "root" chart.
* Which here is represented by not having a Provider at all. All selectors will use the root store by default.
*/
if (isPanorama) {
return children;
}
if (storeRef.current == null) {
storeRef.current = (0, _store.createRechartsStore)(preloadedState, reduxStoreName);
}
// @ts-expect-error React-Redux types demand that the context internal value is not null, but we have that as default.
var nonNullContext = _RechartsReduxContext.RechartsReduxContext;
return /*#__PURE__*/React.createElement(_reactRedux.Provider, {
context: nonNullContext,
store: storeRef.current
}, children);
}

View file

@ -0,0 +1,16 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.ReportChartProps = ReportChartProps;
var _react = require("react");
var _rootPropsSlice = require("./rootPropsSlice");
var _hooks = require("./hooks");
function ReportChartProps(props) {
var dispatch = (0, _hooks.useAppDispatch)();
(0, _react.useEffect)(() => {
dispatch((0, _rootPropsSlice.updateOptions)(props));
}, [dispatch, props]);
return null;
}

View file

@ -0,0 +1,18 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.ReportEventSettings = void 0;
var _react = require("react");
var _hooks = require("./hooks");
var _eventSettingsSlice = require("./eventSettingsSlice");
var _propsAreEqual = require("../util/propsAreEqual");
var ReportEventSettingsImpl = props => {
var dispatch = (0, _hooks.useAppDispatch)();
(0, _react.useEffect)(() => {
dispatch((0, _eventSettingsSlice.setEventSettings)(props));
}, [dispatch, props]);
return null;
};
var ReportEventSettings = exports.ReportEventSettings = /*#__PURE__*/(0, _react.memo)(ReportEventSettingsImpl, _propsAreEqual.propsAreEqual);

View file

@ -0,0 +1,43 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.ReportMainChartProps = void 0;
var _react = require("react");
var _PanoramaContext = require("../context/PanoramaContext");
var _layoutSlice = require("./layoutSlice");
var _hooks = require("./hooks");
var _propsAreEqual = require("../util/propsAreEqual");
/**
* "Main" props are props that are only accepted on the main chart,
* as opposed to the small panorama chart inside a Brush.
*/
function ReportMainChartPropsImpl(_ref) {
var layout = _ref.layout,
margin = _ref.margin;
var dispatch = (0, _hooks.useAppDispatch)();
/*
* Skip dispatching properties in panorama chart for two reasons:
* 1. The root chart should be deciding on these properties, and
* 2. Brush reads these properties from redux store, and so they must remain stable
* to avoid circular dependency and infinite re-rendering.
*/
var isPanorama = (0, _PanoramaContext.useIsPanorama)();
/*
* useEffect here is required to avoid the "Cannot update a component while rendering a different component" error.
* https://github.com/facebook/react/issues/18178
*
* Reported in https://github.com/recharts/recharts/issues/5514
*/
(0, _react.useEffect)(() => {
if (!isPanorama) {
dispatch((0, _layoutSlice.setLayout)(layout));
dispatch((0, _layoutSlice.setMargin)(margin));
}
}, [dispatch, isPanorama, layout, margin]);
return null;
}
var ReportMainChartProps = exports.ReportMainChartProps = /*#__PURE__*/(0, _react.memo)(ReportMainChartPropsImpl, _propsAreEqual.propsAreEqual);

View file

@ -0,0 +1,16 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.ReportPolarOptions = ReportPolarOptions;
var _react = require("react");
var _hooks = require("./hooks");
var _polarOptionsSlice = require("./polarOptionsSlice");
function ReportPolarOptions(props) {
var dispatch = (0, _hooks.useAppDispatch)();
(0, _react.useEffect)(() => {
dispatch((0, _polarOptionsSlice.updatePolarOptions)(props));
}, [dispatch, props]);
return null;
}

View file

@ -0,0 +1,72 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.SetPolarGraphicalItem = exports.SetCartesianGraphicalItem = void 0;
var _react = require("react");
var _hooks = require("./hooks");
var _graphicalItemsSlice = require("./graphicalItemsSlice");
var SetCartesianGraphicalItemImpl = props => {
var dispatch = (0, _hooks.useAppDispatch)();
var prevPropsRef = (0, _react.useRef)(null);
(0, _react.useLayoutEffect)(() => {
if (prevPropsRef.current === null) {
dispatch((0, _graphicalItemsSlice.addCartesianGraphicalItem)(props));
} else if (prevPropsRef.current !== props) {
dispatch((0, _graphicalItemsSlice.replaceCartesianGraphicalItem)({
prev: prevPropsRef.current,
next: props
}));
}
prevPropsRef.current = props;
}, [dispatch, props]);
(0, _react.useLayoutEffect)(() => {
return () => {
if (prevPropsRef.current) {
dispatch((0, _graphicalItemsSlice.removeCartesianGraphicalItem)(prevPropsRef.current));
/*
* Here we have to reset the ref to null because in StrictMode, the effect will run twice,
* but it will keep the same ref value from the first render.
*
* In browser, React will clear the ref after the first effect cleanup,
* so that wouldn't be an issue.
*
* In StrictMode, however, the ref is kept,
* and in the hook above the code checks for `prevPropsRef.current === null`
* which would be false so it would not dispatch the `addCartesianGraphicalItem` action again.
*
* https://github.com/recharts/recharts/issues/6022
*/
prevPropsRef.current = null;
}
};
}, [dispatch]);
return null;
};
var SetCartesianGraphicalItem = exports.SetCartesianGraphicalItem = /*#__PURE__*/(0, _react.memo)(SetCartesianGraphicalItemImpl);
var SetPolarGraphicalItemImpl = props => {
var dispatch = (0, _hooks.useAppDispatch)();
var prevPropsRef = (0, _react.useRef)(null);
(0, _react.useLayoutEffect)(() => {
if (prevPropsRef.current === null) {
dispatch((0, _graphicalItemsSlice.addPolarGraphicalItem)(props));
} else if (prevPropsRef.current !== props) {
dispatch((0, _graphicalItemsSlice.replacePolarGraphicalItem)({
prev: prevPropsRef.current,
next: props
}));
}
prevPropsRef.current = props;
}, [dispatch, props]);
(0, _react.useLayoutEffect)(() => {
return () => {
if (prevPropsRef.current) {
dispatch((0, _graphicalItemsSlice.removePolarGraphicalItem)(prevPropsRef.current));
prevPropsRef.current = null;
}
};
}, [dispatch]);
return null;
};
var SetPolarGraphicalItem = exports.SetPolarGraphicalItem = /*#__PURE__*/(0, _react.memo)(SetPolarGraphicalItemImpl);

View file

@ -0,0 +1,70 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.SetLegendPayload = SetLegendPayload;
exports.SetPolarLegendPayload = SetPolarLegendPayload;
var _react = require("react");
var _PanoramaContext = require("../context/PanoramaContext");
var _chartLayoutContext = require("../context/chartLayoutContext");
var _hooks = require("./hooks");
var _legendSlice = require("./legendSlice");
function SetLegendPayload(_ref) {
var legendPayload = _ref.legendPayload;
var dispatch = (0, _hooks.useAppDispatch)();
var isPanorama = (0, _PanoramaContext.useIsPanorama)();
var prevPayloadRef = (0, _react.useRef)(null);
(0, _react.useLayoutEffect)(() => {
if (isPanorama) {
return;
}
if (prevPayloadRef.current === null) {
dispatch((0, _legendSlice.addLegendPayload)(legendPayload));
} else if (prevPayloadRef.current !== legendPayload) {
dispatch((0, _legendSlice.replaceLegendPayload)({
prev: prevPayloadRef.current,
next: legendPayload
}));
}
prevPayloadRef.current = legendPayload;
}, [dispatch, isPanorama, legendPayload]);
(0, _react.useLayoutEffect)(() => {
return () => {
if (prevPayloadRef.current) {
dispatch((0, _legendSlice.removeLegendPayload)(prevPayloadRef.current));
prevPayloadRef.current = null;
}
};
}, [dispatch]);
return null;
}
function SetPolarLegendPayload(_ref2) {
var legendPayload = _ref2.legendPayload;
var dispatch = (0, _hooks.useAppDispatch)();
var layout = (0, _hooks.useAppSelector)(_chartLayoutContext.selectChartLayout);
var prevPayloadRef = (0, _react.useRef)(null);
(0, _react.useLayoutEffect)(() => {
if (layout !== 'centric' && layout !== 'radial') {
return;
}
if (prevPayloadRef.current === null) {
dispatch((0, _legendSlice.addLegendPayload)(legendPayload));
} else if (prevPayloadRef.current !== legendPayload) {
dispatch((0, _legendSlice.replaceLegendPayload)({
prev: prevPayloadRef.current,
next: legendPayload
}));
}
prevPayloadRef.current = legendPayload;
}, [dispatch, layout, legendPayload]);
(0, _react.useLayoutEffect)(() => {
return () => {
if (prevPayloadRef.current) {
dispatch((0, _legendSlice.removeLegendPayload)(prevPayloadRef.current));
prevPayloadRef.current = null;
}
};
}, [dispatch]);
return null;
}

View file

@ -0,0 +1,40 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.SetTooltipEntrySettings = SetTooltipEntrySettings;
var _react = require("react");
var _hooks = require("./hooks");
var _tooltipSlice = require("./tooltipSlice");
var _PanoramaContext = require("../context/PanoramaContext");
function SetTooltipEntrySettings(_ref) {
var tooltipEntrySettings = _ref.tooltipEntrySettings;
var dispatch = (0, _hooks.useAppDispatch)();
var isPanorama = (0, _PanoramaContext.useIsPanorama)();
var prevSettingsRef = (0, _react.useRef)(null);
(0, _react.useLayoutEffect)(() => {
if (isPanorama) {
// Panorama graphical items should never contribute to Tooltip payload.
return;
}
if (prevSettingsRef.current === null) {
dispatch((0, _tooltipSlice.addTooltipEntrySettings)(tooltipEntrySettings));
} else if (prevSettingsRef.current !== tooltipEntrySettings) {
dispatch((0, _tooltipSlice.replaceTooltipEntrySettings)({
prev: prevSettingsRef.current,
next: tooltipEntrySettings
}));
}
prevSettingsRef.current = tooltipEntrySettings;
}, [tooltipEntrySettings, dispatch, isPanorama]);
(0, _react.useLayoutEffect)(() => {
return () => {
if (prevSettingsRef.current) {
dispatch((0, _tooltipSlice.removeTooltipEntrySettings)(prevSettingsRef.current));
prevSettingsRef.current = null;
}
};
}, [dispatch]);
return null;
}

38
frontend/node_modules/recharts/lib/state/brushSlice.js generated vendored Normal file
View file

@ -0,0 +1,38 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.setBrushSettings = exports.brushSlice = exports.brushReducer = void 0;
var _toolkit = require("@reduxjs/toolkit");
/**
* From all Brush properties, only height has a default value and will always be defined.
* Other properties are nullable and will be computed from offsets and margins if they are not set.
*/
var initialState = {
x: 0,
y: 0,
width: 0,
height: 0,
padding: {
top: 0,
right: 0,
bottom: 0,
left: 0
}
};
var brushSlice = exports.brushSlice = (0, _toolkit.createSlice)({
name: 'brush',
initialState,
reducers: {
setBrushSettings(_state, action) {
if (action.payload == null) {
return initialState;
}
return action.payload;
}
}
});
var setBrushSettings = exports.setBrushSettings = brushSlice.actions.setBrushSettings;
var brushReducer = exports.brushReducer = brushSlice.reducer;

View file

@ -0,0 +1,191 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.updateYAxisWidth = exports.replaceZAxis = exports.replaceYAxis = exports.replaceXAxis = exports.removeZAxis = exports.removeYAxis = exports.removeXAxis = exports.defaultAxisId = exports.cartesianAxisReducer = exports.addZAxis = exports.addYAxis = exports.addXAxis = void 0;
var _toolkit = require("@reduxjs/toolkit");
var _immer = require("immer");
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
/**
* @inline
*/
var defaultAxisId = exports.defaultAxisId = 0;
/**
* Properties shared in X, Y, and Z axes.
* User defined axis settings, coming from props.
*/
/**
* Controls how Recharts calculates "nice" tick values for numerical axes.
*
* - `'none'`: Recharts does not apply any tick-rounding algorithm; tick positions are
* determined entirely by d3, evenly spaced but not rounded to human-friendly numbers.
* There is no domain-extension logic applied in this mode.
*
* - `'auto'` *(default)*: Recharts automatically decides whether and how to apply tick
* niceties based on the domain definition. When the domain contains an `'auto'` keyword,
* Recharts uses the `'adaptive'` algorithm and may extend the domain slightly to
* produce clean tick labels. Otherwise, it applies the same algorithm while keeping
* ticks within the fixed domain. This mirrors the default behavior from Recharts v2.
*
* - `'adaptive'`: Always applies the space-efficient algorithm (`getAdaptiveStep`),
* which fills the available range as densely as possible while still rounding steps
* to reasonable numbers (e.g. 10, 20, 25). May produce less "round-looking" labels
* than `'snap125'`, but wastes less space. The domain-extension logic still applies
* when the domain contains an `'auto'` keyword.
*
* - `'snap125'`: Always applies the round-numbers algorithm (`getSnap125Step`), which
* snaps step sizes to values from the set {1, 2, 2.5, 5} × 10. Produces very
* human-friendly labels (e.g. 0, 5, 10, 15, 20) but may leave blank space at the
* edges of the chart. The domain-extension logic still applies when the domain
* contains an `'auto'` keyword.
*
* @see {@link https://recharts.github.io/guide/axisTicks/}
* @inline
*/
/**
* These are the external props, visible for users as they set them using our public API.
* There is all sorts of internal computed things based on these, but they will come through selectors.
*
* Properties shared between X and Y axes
*/
/**
* Z axis is special because it's never displayed. It controls the size of Scatter dots,
* but it never displays ticks anywhere.
*/
var initialState = {
xAxis: {},
yAxis: {},
zAxis: {}
};
/**
* This is the slice where each individual Axis element pushes its own configuration.
* Prefer to use this one instead of axisSlice.
*/
var cartesianAxisSlice = (0, _toolkit.createSlice)({
name: 'cartesianAxis',
initialState,
reducers: {
addXAxis: {
reducer(state, action) {
state.xAxis[action.payload.id] = (0, _immer.castDraft)(action.payload);
},
prepare: (0, _toolkit.prepareAutoBatched)()
},
replaceXAxis: {
reducer(state, action) {
var _action$payload = action.payload,
prev = _action$payload.prev,
next = _action$payload.next;
if (state.xAxis[prev.id] !== undefined) {
if (prev.id !== next.id) {
delete state.xAxis[prev.id];
}
state.xAxis[next.id] = (0, _immer.castDraft)(next);
}
},
prepare: (0, _toolkit.prepareAutoBatched)()
},
removeXAxis: {
reducer(state, action) {
delete state.xAxis[action.payload.id];
},
prepare: (0, _toolkit.prepareAutoBatched)()
},
addYAxis: {
reducer(state, action) {
state.yAxis[action.payload.id] = (0, _immer.castDraft)(action.payload);
},
prepare: (0, _toolkit.prepareAutoBatched)()
},
replaceYAxis: {
reducer(state, action) {
var _action$payload2 = action.payload,
prev = _action$payload2.prev,
next = _action$payload2.next;
if (state.yAxis[prev.id] !== undefined) {
if (prev.id !== next.id) {
delete state.yAxis[prev.id];
}
state.yAxis[next.id] = (0, _immer.castDraft)(next);
}
},
prepare: (0, _toolkit.prepareAutoBatched)()
},
removeYAxis: {
reducer(state, action) {
delete state.yAxis[action.payload.id];
},
prepare: (0, _toolkit.prepareAutoBatched)()
},
addZAxis: {
reducer(state, action) {
state.zAxis[action.payload.id] = (0, _immer.castDraft)(action.payload);
},
prepare: (0, _toolkit.prepareAutoBatched)()
},
replaceZAxis: {
reducer(state, action) {
var _action$payload3 = action.payload,
prev = _action$payload3.prev,
next = _action$payload3.next;
if (state.zAxis[prev.id] !== undefined) {
if (prev.id !== next.id) {
delete state.zAxis[prev.id];
}
state.zAxis[next.id] = (0, _immer.castDraft)(next);
}
},
prepare: (0, _toolkit.prepareAutoBatched)()
},
removeZAxis: {
reducer(state, action) {
delete state.zAxis[action.payload.id];
},
prepare: (0, _toolkit.prepareAutoBatched)()
},
updateYAxisWidth(state, action) {
var _action$payload4 = action.payload,
id = _action$payload4.id,
width = _action$payload4.width;
var axis = state.yAxis[id];
if (axis) {
var _history$;
var history = axis.widthHistory || [];
// An oscillation is detected when the new width is the same as the width before the last one.
// This is a simple A -> B -> A pattern. If the next width is B, and the difference is less than 1 pixel, we ignore it.
if (history.length === 3 && history[0] === history[2] && width === history[1] && width !== axis.width && Math.abs(width - ((_history$ = history[0]) !== null && _history$ !== void 0 ? _history$ : 0)) <= 1) {
return;
}
var newHistory = [...history, width].slice(-3);
state.yAxis[id] = _objectSpread(_objectSpread({}, axis), {}, {
width,
widthHistory: newHistory
});
}
}
}
});
var _cartesianAxisSlice$a = cartesianAxisSlice.actions,
addXAxis = exports.addXAxis = _cartesianAxisSlice$a.addXAxis,
replaceXAxis = exports.replaceXAxis = _cartesianAxisSlice$a.replaceXAxis,
removeXAxis = exports.removeXAxis = _cartesianAxisSlice$a.removeXAxis,
addYAxis = exports.addYAxis = _cartesianAxisSlice$a.addYAxis,
replaceYAxis = exports.replaceYAxis = _cartesianAxisSlice$a.replaceYAxis,
removeYAxis = exports.removeYAxis = _cartesianAxisSlice$a.removeYAxis,
addZAxis = exports.addZAxis = _cartesianAxisSlice$a.addZAxis,
replaceZAxis = exports.replaceZAxis = _cartesianAxisSlice$a.replaceZAxis,
removeZAxis = exports.removeZAxis = _cartesianAxisSlice$a.removeZAxis,
updateYAxisWidth = exports.updateYAxisWidth = _cartesianAxisSlice$a.updateYAxisWidth;
var cartesianAxisReducer = exports.cartesianAxisReducer = cartesianAxisSlice.reducer;

View file

@ -0,0 +1,69 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.setDataStartEndIndexes = exports.setComputedData = exports.setChartData = exports.initialChartDataState = exports.chartDataReducer = void 0;
var _toolkit = require("@reduxjs/toolkit");
var _immer = require("immer");
/**
* This is the data that's coming through main chart `data` prop
* Recharts is very flexible in what it accepts so the type is very flexible too.
* This will typically be an object, and various components will provide various `dataKey`
* that dictates how to pull data from that object.
*
* TL;DR: before dataKey
*
* @inline
*/
/**
* So this is the same unknown type as ChartData but this is after the dataKey has been applied.
* We still don't know what the type is - that depends on what exactly it was before the dataKey application,
* and the dataKey can return whatever anyway - but let's keep it separate as a form of documentation.
*
* TL;DR: ChartData after dataKey.
*/
var initialChartDataState = exports.initialChartDataState = {
chartData: undefined,
computedData: undefined,
dataStartIndex: 0,
dataEndIndex: 0
};
var chartDataSlice = (0, _toolkit.createSlice)({
name: 'chartData',
initialState: initialChartDataState,
reducers: {
setChartData(state, action) {
state.chartData = (0, _immer.castDraft)(action.payload);
if (action.payload == null) {
state.dataStartIndex = 0;
state.dataEndIndex = 0;
return;
}
if (action.payload.length > 0 && state.dataEndIndex !== action.payload.length - 1) {
state.dataEndIndex = action.payload.length - 1;
}
},
setComputedData(state, action) {
state.computedData = action.payload;
},
setDataStartEndIndexes(state, action) {
var _action$payload = action.payload,
startIndex = _action$payload.startIndex,
endIndex = _action$payload.endIndex;
if (startIndex != null) {
state.dataStartIndex = startIndex;
}
if (endIndex != null) {
state.dataEndIndex = endIndex;
}
}
}
});
var _chartDataSlice$actio = chartDataSlice.actions,
setChartData = exports.setChartData = _chartDataSlice$actio.setChartData,
setDataStartEndIndexes = exports.setDataStartEndIndexes = _chartDataSlice$actio.setDataStartEndIndexes,
setComputedData = exports.setComputedData = _chartDataSlice$actio.setComputedData;
var chartDataReducer = exports.chartDataReducer = chartDataSlice.reducer;

View file

@ -0,0 +1,51 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.replaceErrorBar = exports.removeErrorBar = exports.errorBarReducer = exports.addErrorBar = void 0;
var _toolkit = require("@reduxjs/toolkit");
/**
* ErrorBars have lot more settings but all the others are scoped to the component itself.
* Only some of them required to be reported to the global store because XAxis and YAxis need to know
* if the error bar is contributing to extending the axis domain.
*/
var initialState = {};
var errorBarSlice = (0, _toolkit.createSlice)({
name: 'errorBars',
initialState,
reducers: {
addErrorBar: (state, action) => {
var _action$payload = action.payload,
itemId = _action$payload.itemId,
errorBar = _action$payload.errorBar;
if (!state[itemId]) {
state[itemId] = [];
}
state[itemId].push(errorBar);
},
replaceErrorBar: (state, action) => {
var _action$payload2 = action.payload,
itemId = _action$payload2.itemId,
prev = _action$payload2.prev,
next = _action$payload2.next;
if (state[itemId]) {
state[itemId] = state[itemId].map(e => e.dataKey === prev.dataKey && e.direction === prev.direction ? next : e);
}
},
removeErrorBar: (state, action) => {
var _action$payload3 = action.payload,
itemId = _action$payload3.itemId,
errorBar = _action$payload3.errorBar;
if (state[itemId]) {
state[itemId] = state[itemId].filter(e => e.dataKey !== errorBar.dataKey || e.direction !== errorBar.direction);
}
}
}
});
var _errorBarSlice$action = errorBarSlice.actions,
addErrorBar = exports.addErrorBar = _errorBarSlice$action.addErrorBar,
replaceErrorBar = exports.replaceErrorBar = _errorBarSlice$action.replaceErrorBar,
removeErrorBar = exports.removeErrorBar = _errorBarSlice$action.removeErrorBar;
var errorBarReducer = exports.errorBarReducer = errorBarSlice.reducer;

View file

@ -0,0 +1,28 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.setEventSettings = exports.initialEventSettingsState = exports.eventSettingsReducer = void 0;
var _toolkit = require("@reduxjs/toolkit");
var _immer = require("immer");
var initialEventSettingsState = exports.initialEventSettingsState = {
throttleDelay: 'raf',
throttledEvents: ['mousemove', 'touchmove', 'pointermove', 'scroll', 'wheel']
};
var eventSettingsSlice = (0, _toolkit.createSlice)({
name: 'eventSettings',
initialState: initialEventSettingsState,
reducers: {
setEventSettings: (state, action) => {
if (action.payload.throttleDelay != null) {
state.throttleDelay = action.payload.throttleDelay;
}
if (action.payload.throttledEvents != null) {
state.throttledEvents = (0, _immer.castDraft)(action.payload.throttledEvents);
}
}
}
});
var setEventSettings = exports.setEventSettings = eventSettingsSlice.actions.setEventSettings;
var eventSettingsReducer = exports.eventSettingsReducer = eventSettingsSlice.reducer;

View file

@ -0,0 +1,121 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.externalEventsMiddleware = exports.externalEventAction = void 0;
var _toolkit = require("@reduxjs/toolkit");
var _tooltipSelectors = require("./selectors/tooltipSelectors");
var _createEventProxy = require("../util/createEventProxy");
var externalEventAction = exports.externalEventAction = (0, _toolkit.createAction)('externalEvent');
var externalEventsMiddleware = exports.externalEventsMiddleware = (0, _toolkit.createListenerMiddleware)();
/*
* We need a Map keyed by event type because this middleware handles MULTIPLE different event types
* (click, mouseenter, mouseleave, mousedown, mouseup, contextmenu, dblclick, touchstart, touchmove, touchend)
* from the same DOM element. Different event types should NOT cancel each other's animation frames.
* For example, a click event and a mousemove event can happen in quick succession and both should be processed.
* This is different from mouseMoveMiddleware which only handles one event type and uses a single rafId.
*/
var rafIdMap = new Map();
var timeoutIdMap = new Map();
var latestEventMap = new Map();
externalEventsMiddleware.startListening({
actionCreator: externalEventAction,
effect: (action, listenerApi) => {
var _action$payload = action.payload,
handler = _action$payload.handler,
reactEvent = _action$payload.reactEvent;
if (handler == null) {
return;
}
var eventType = reactEvent.type;
var eventProxy = (0, _createEventProxy.createEventProxy)(reactEvent);
latestEventMap.set(eventType, {
handler,
reactEvent: eventProxy
});
// Cancel any pending execution for this event type
var existingRafId = rafIdMap.get(eventType);
if (existingRafId !== undefined) {
cancelAnimationFrame(existingRafId);
rafIdMap.delete(eventType);
}
var state = listenerApi.getState();
var _state$eventSettings = state.eventSettings,
throttleDelay = _state$eventSettings.throttleDelay,
throttledEvents = _state$eventSettings.throttledEvents;
/*
* reactEvent.type gives us the event type as a string, e.g., 'click', 'mousemove', etc.
* which is the same as the names used in throttledEvents array
* but that array is strictly typed as ReadonlyArray<keyof GlobalEventHandlersEventMap> | 'all' | undefined
* so that we can have relevant autocomplete and type checking elsewhere.
* This makes TypeScript panic because it refuses to call .includes() on ReadonlyArray<keyof GlobalEventHandlersEventMap>
* with a string argument.
* To satisfy TypeScript, we need to explicitly typecast throttledEvents here.
*/
var eventListAsString = throttledEvents;
// Check if this event type should be throttled
// throttledEvents can be 'all' or an array of event names
var isThrottled = eventListAsString === 'all' || (eventListAsString === null || eventListAsString === void 0 ? void 0 : eventListAsString.includes(eventType));
var existingTimeoutId = timeoutIdMap.get(eventType);
if (existingTimeoutId !== undefined && (typeof throttleDelay !== 'number' || !isThrottled)) {
clearTimeout(existingTimeoutId);
timeoutIdMap.delete(eventType);
}
var callback = () => {
var latestAction = latestEventMap.get(eventType);
try {
if (!latestAction) {
// This happens if the event was consumed by the leading edge and no new event came in
return;
}
var latestHandler = latestAction.handler,
latestEvent = latestAction.reactEvent;
var currentState = listenerApi.getState();
var nextState = {
activeCoordinate: (0, _tooltipSelectors.selectActiveTooltipCoordinate)(currentState),
activeDataKey: (0, _tooltipSelectors.selectActiveTooltipDataKey)(currentState),
activeIndex: (0, _tooltipSelectors.selectActiveTooltipIndex)(currentState),
activeLabel: (0, _tooltipSelectors.selectActiveLabel)(currentState),
activeTooltipIndex: (0, _tooltipSelectors.selectActiveTooltipIndex)(currentState),
isTooltipActive: (0, _tooltipSelectors.selectIsTooltipActive)(currentState)
};
if (latestHandler) {
latestHandler(nextState, latestEvent);
}
} finally {
rafIdMap.delete(eventType);
timeoutIdMap.delete(eventType);
latestEventMap.delete(eventType);
}
};
if (!isThrottled) {
// Execute immediately
callback();
return;
}
if (throttleDelay === 'raf') {
var rafId = requestAnimationFrame(callback);
rafIdMap.set(eventType, rafId);
} else if (typeof throttleDelay === 'number') {
if (!timeoutIdMap.has(eventType)) {
/*
* Leading edge execution - execute immediately on the first event
* and then start the cooldown period to throttle subsequent events.
*/
callback();
// Start cooldown
var timeoutId = setTimeout(callback, throttleDelay);
timeoutIdMap.set(eventType, timeoutId);
}
} else {
// Should not happen based on type, but fallback to immediate
callback();
}
}
});

View file

@ -0,0 +1,86 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.replacePolarGraphicalItem = exports.replaceCartesianGraphicalItem = exports.removePolarGraphicalItem = exports.removeCartesianGraphicalItem = exports.graphicalItemsReducer = exports.addPolarGraphicalItem = exports.addCartesianGraphicalItem = void 0;
var _toolkit = require("@reduxjs/toolkit");
var _immer = require("immer");
/**
* Unique ID of the graphical item.
* This is used to identify the graphical item in the state and in the React tree.
* This is required for every graphical item - it's either provided by the user or generated automatically.
*/
var initialState = {
cartesianItems: [],
polarItems: []
};
var graphicalItemsSlice = (0, _toolkit.createSlice)({
name: 'graphicalItems',
initialState,
reducers: {
addCartesianGraphicalItem: {
reducer(state, action) {
state.cartesianItems.push((0, _immer.castDraft)(action.payload));
},
prepare: (0, _toolkit.prepareAutoBatched)()
},
replaceCartesianGraphicalItem: {
reducer(state, action) {
var _action$payload = action.payload,
prev = _action$payload.prev,
next = _action$payload.next;
var index = (0, _toolkit.current)(state).cartesianItems.indexOf((0, _immer.castDraft)(prev));
if (index > -1) {
state.cartesianItems[index] = (0, _immer.castDraft)(next);
}
},
prepare: (0, _toolkit.prepareAutoBatched)()
},
removeCartesianGraphicalItem: {
reducer(state, action) {
var index = (0, _toolkit.current)(state).cartesianItems.indexOf((0, _immer.castDraft)(action.payload));
if (index > -1) {
state.cartesianItems.splice(index, 1);
}
},
prepare: (0, _toolkit.prepareAutoBatched)()
},
addPolarGraphicalItem: {
reducer(state, action) {
state.polarItems.push((0, _immer.castDraft)(action.payload));
},
prepare: (0, _toolkit.prepareAutoBatched)()
},
removePolarGraphicalItem: {
reducer(state, action) {
var index = (0, _toolkit.current)(state).polarItems.indexOf((0, _immer.castDraft)(action.payload));
if (index > -1) {
state.polarItems.splice(index, 1);
}
},
prepare: (0, _toolkit.prepareAutoBatched)()
},
replacePolarGraphicalItem: {
reducer(state, action) {
var _action$payload2 = action.payload,
prev = _action$payload2.prev,
next = _action$payload2.next;
var index = (0, _toolkit.current)(state).polarItems.indexOf((0, _immer.castDraft)(prev));
if (index > -1) {
state.polarItems[index] = (0, _immer.castDraft)(next);
}
},
prepare: (0, _toolkit.prepareAutoBatched)()
}
}
});
var _graphicalItemsSlice$ = graphicalItemsSlice.actions,
addCartesianGraphicalItem = exports.addCartesianGraphicalItem = _graphicalItemsSlice$.addCartesianGraphicalItem,
replaceCartesianGraphicalItem = exports.replaceCartesianGraphicalItem = _graphicalItemsSlice$.replaceCartesianGraphicalItem,
removeCartesianGraphicalItem = exports.removeCartesianGraphicalItem = _graphicalItemsSlice$.removeCartesianGraphicalItem,
addPolarGraphicalItem = exports.addPolarGraphicalItem = _graphicalItemsSlice$.addPolarGraphicalItem,
removePolarGraphicalItem = exports.removePolarGraphicalItem = _graphicalItemsSlice$.removePolarGraphicalItem,
replacePolarGraphicalItem = exports.replacePolarGraphicalItem = _graphicalItemsSlice$.replacePolarGraphicalItem;
var graphicalItemsReducer = exports.graphicalItemsReducer = graphicalItemsSlice.reducer;

54
frontend/node_modules/recharts/lib/state/hooks.js generated vendored Normal file
View file

@ -0,0 +1,54 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.useAppDispatch = void 0;
exports.useAppSelector = useAppSelector;
var _withSelector = require("use-sync-external-store/shim/with-selector");
var _react = require("react");
var _RechartsReduxContext = require("./RechartsReduxContext");
var noopDispatch = a => a;
var useAppDispatch = () => {
var context = (0, _react.useContext)(_RechartsReduxContext.RechartsReduxContext);
if (context) {
return context.store.dispatch;
}
return noopDispatch;
};
exports.useAppDispatch = useAppDispatch;
var noop = () => {};
var addNestedSubNoop = () => noop;
var refEquality = (a, b) => a === b;
/**
* This is a recharts variant of `useSelector` from 'react-redux' package.
*
* The difference is that react-redux version will throw an Error when used outside of Redux context.
*
* This, recharts version, will return undefined instead.
*
* This is because we want to allow using our components outside the Chart wrapper,
* and have people provide all props explicitly.
*
* If however they use the component inside a chart wrapper then those props become optional,
* and we read them from Redux state instead.
*
* @param selector for pulling things out of Redux store; will not be called if the store is not accessible
* @return whatever the selector returned; or undefined when outside of Redux store
*/
function useAppSelector(selector) {
var context = (0, _react.useContext)(_RechartsReduxContext.RechartsReduxContext);
var outOfContextSelector = (0, _react.useMemo)(() => {
if (!context) {
return noop;
}
return state => {
if (state == null) {
return undefined;
}
return selector(state);
};
}, [context, selector]);
return (0, _withSelector.useSyncExternalStoreWithSelector)(context ? context.subscription.addNestedSub : addNestedSubNoop, context ? context.store.getState : noop, context ? context.store.getState : noop, outOfContextSelector, refEquality);
}

View file

@ -0,0 +1,187 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.keyboardEventsMiddleware = exports.keyDownAction = exports.focusAction = exports.blurAction = void 0;
var _toolkit = require("@reduxjs/toolkit");
var _tooltipSlice = require("./tooltipSlice");
var _tooltipSelectors = require("./selectors/tooltipSelectors");
var _selectors = require("./selectors/selectors");
var _axisSelectors = require("./selectors/axisSelectors");
var _combineActiveTooltipIndex = require("./selectors/combiners/combineActiveTooltipIndex");
var _selectTooltipEventType = require("./selectors/selectTooltipEventType");
var keyDownAction = exports.keyDownAction = (0, _toolkit.createAction)('keyDown');
var focusAction = exports.focusAction = (0, _toolkit.createAction)('focus');
var blurAction = exports.blurAction = (0, _toolkit.createAction)('blur');
var keyboardEventsMiddleware = exports.keyboardEventsMiddleware = (0, _toolkit.createListenerMiddleware)();
var rafId = null;
var timeoutId = null;
var latestKeyboardActionPayload = null;
keyboardEventsMiddleware.startListening({
actionCreator: keyDownAction,
effect: (action, listenerApi) => {
latestKeyboardActionPayload = action.payload;
if (rafId !== null) {
cancelAnimationFrame(rafId);
rafId = null;
}
var state = listenerApi.getState();
var _state$eventSettings = state.eventSettings,
throttleDelay = _state$eventSettings.throttleDelay,
throttledEvents = _state$eventSettings.throttledEvents;
var isThrottled = throttledEvents === 'all' || throttledEvents.includes('keydown');
if (timeoutId !== null && (typeof throttleDelay !== 'number' || !isThrottled)) {
clearTimeout(timeoutId);
timeoutId = null;
}
var callback = () => {
try {
var currentState = listenerApi.getState();
var accessibilityLayerIsActive = currentState.rootProps.accessibilityLayer !== false;
if (!accessibilityLayerIsActive) {
return;
}
var keyboardInteraction = currentState.tooltip.keyboardInteraction;
var key = latestKeyboardActionPayload;
if (key !== 'ArrowRight' && key !== 'ArrowLeft' && key !== 'Enter') {
return;
}
// TODO this is lacking index for charts that do not support numeric indexes
var resolvedIndex = (0, _combineActiveTooltipIndex.combineActiveTooltipIndex)(keyboardInteraction, (0, _tooltipSelectors.selectTooltipDisplayedData)(currentState), (0, _axisSelectors.selectTooltipAxisDataKey)(currentState), (0, _tooltipSelectors.selectTooltipAxisDomain)(currentState));
var currentIndex = resolvedIndex == null ? -1 : Number(resolvedIndex);
var isOutsideDomain = !Number.isFinite(currentIndex) || currentIndex < 0;
var tooltipTicks = (0, _tooltipSelectors.selectTooltipAxisTicks)(currentState);
var displayedData = (0, _tooltipSelectors.selectTooltipDisplayedData)(currentState);
var tooltipEventType = (0, _selectTooltipEventType.selectTooltipEventType)(currentState, currentState.tooltip.settings.shared);
if (key === 'Enter') {
if (isOutsideDomain) {
return;
}
var _coordinate = (0, _selectors.selectCoordinateForDefaultIndex)(currentState, tooltipEventType, 'hover', String(keyboardInteraction.index));
listenerApi.dispatch((0, _tooltipSlice.setKeyboardInteraction)({
active: !keyboardInteraction.active,
activeIndex: keyboardInteraction.index,
activeCoordinate: _coordinate
}));
return;
}
var direction = (0, _axisSelectors.selectChartDirection)(currentState);
var directionMultiplier = direction === 'left-to-right' ? 1 : -1;
var movement = key === 'ArrowRight' ? 1 : -1;
var nextIndex;
if (isOutsideDomain) {
var axisDataKey = (0, _axisSelectors.selectTooltipAxisDataKey)(currentState);
var domain = (0, _tooltipSelectors.selectTooltipAxisDomain)(currentState);
var effectiveMovement = movement * directionMultiplier;
// Build a minimal TooltipInteractionState for the candidate-index check.
var mkInteraction = i => ({
active: false,
index: String(i),
dataKey: undefined,
graphicalItemId: undefined,
coordinate: undefined
});
nextIndex = -1;
if (effectiveMovement > 0) {
for (var i = 0; i < displayedData.length; i++) {
if ((0, _combineActiveTooltipIndex.combineActiveTooltipIndex)(mkInteraction(i), displayedData, axisDataKey, domain) != null) {
nextIndex = i;
break;
}
}
} else {
for (var _i = displayedData.length - 1; _i >= 0; _i--) {
if ((0, _combineActiveTooltipIndex.combineActiveTooltipIndex)(mkInteraction(_i), displayedData, axisDataKey, domain) != null) {
nextIndex = _i;
break;
}
}
}
if (nextIndex < 0) {
return;
}
} else {
nextIndex = currentIndex + movement * directionMultiplier;
var dataLength = (tooltipTicks === null || tooltipTicks === void 0 ? void 0 : tooltipTicks.length) || displayedData.length;
if (dataLength === 0 || nextIndex >= dataLength || nextIndex < 0) {
return;
}
}
var coordinate = (0, _selectors.selectCoordinateForDefaultIndex)(currentState, tooltipEventType, 'hover', String(nextIndex));
listenerApi.dispatch((0, _tooltipSlice.setKeyboardInteraction)({
active: true,
activeIndex: nextIndex.toString(),
activeCoordinate: coordinate
}));
} finally {
rafId = null;
timeoutId = null;
}
};
if (!isThrottled) {
callback();
return;
}
if (throttleDelay === 'raf') {
rafId = requestAnimationFrame(callback);
} else if (typeof throttleDelay === 'number') {
if (timeoutId === null) {
callback();
latestKeyboardActionPayload = null;
timeoutId = setTimeout(() => {
if (latestKeyboardActionPayload) {
callback();
} else {
timeoutId = null;
rafId = null;
}
}, throttleDelay);
}
}
}
});
keyboardEventsMiddleware.startListening({
actionCreator: focusAction,
effect: (_action, listenerApi) => {
var state = listenerApi.getState();
var accessibilityLayerIsActive = state.rootProps.accessibilityLayer !== false;
if (!accessibilityLayerIsActive) {
return;
}
var keyboardInteraction = state.tooltip.keyboardInteraction;
if (keyboardInteraction.active) {
return;
}
if (keyboardInteraction.index == null) {
var nextIndex = '0';
var tooltipEventType = (0, _selectTooltipEventType.selectTooltipEventType)(state, state.tooltip.settings.shared);
var coordinate = (0, _selectors.selectCoordinateForDefaultIndex)(state, tooltipEventType, 'hover', String(nextIndex));
listenerApi.dispatch((0, _tooltipSlice.setKeyboardInteraction)({
active: true,
activeIndex: nextIndex,
activeCoordinate: coordinate
}));
}
}
});
keyboardEventsMiddleware.startListening({
actionCreator: blurAction,
effect: (_action, listenerApi) => {
var state = listenerApi.getState();
var accessibilityLayerIsActive = state.rootProps.accessibilityLayer !== false;
if (!accessibilityLayerIsActive) {
return;
}
var keyboardInteraction = state.tooltip.keyboardInteraction;
if (keyboardInteraction.active) {
listenerApi.dispatch((0, _tooltipSlice.setKeyboardInteraction)({
active: false,
activeIndex: keyboardInteraction.index,
activeCoordinate: keyboardInteraction.coordinate
}));
}
}
});

View file

@ -0,0 +1,48 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.setScale = exports.setMargin = exports.setLayout = exports.setChartSize = exports.chartLayoutReducer = void 0;
var _toolkit = require("@reduxjs/toolkit");
var initialState = {
layoutType: 'horizontal',
width: 0,
height: 0,
margin: {
top: 5,
right: 5,
bottom: 5,
left: 5
},
scale: 1
};
var chartLayoutSlice = (0, _toolkit.createSlice)({
name: 'chartLayout',
initialState,
reducers: {
setLayout(state, action) {
state.layoutType = action.payload;
},
setChartSize(state, action) {
state.width = action.payload.width;
state.height = action.payload.height;
},
setMargin(state, action) {
var _action$payload$top, _action$payload$right, _action$payload$botto, _action$payload$left;
state.margin.top = (_action$payload$top = action.payload.top) !== null && _action$payload$top !== void 0 ? _action$payload$top : 0;
state.margin.right = (_action$payload$right = action.payload.right) !== null && _action$payload$right !== void 0 ? _action$payload$right : 0;
state.margin.bottom = (_action$payload$botto = action.payload.bottom) !== null && _action$payload$botto !== void 0 ? _action$payload$botto : 0;
state.margin.left = (_action$payload$left = action.payload.left) !== null && _action$payload$left !== void 0 ? _action$payload$left : 0;
},
setScale(state, action) {
state.scale = action.payload;
}
}
});
var _chartLayoutSlice$act = chartLayoutSlice.actions,
setMargin = exports.setMargin = _chartLayoutSlice$act.setMargin,
setLayout = exports.setLayout = _chartLayoutSlice$act.setLayout,
setChartSize = exports.setChartSize = _chartLayoutSlice$act.setChartSize,
setScale = exports.setScale = _chartLayoutSlice$act.setScale;
var chartLayoutReducer = exports.chartLayoutReducer = chartLayoutSlice.reducer;

View file

@ -0,0 +1,79 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.setLegendSize = exports.setLegendSettings = exports.replaceLegendPayload = exports.removeLegendPayload = exports.legendReducer = exports.addLegendPayload = void 0;
var _toolkit = require("@reduxjs/toolkit");
var _immer = require("immer");
/**
* The properties inside this state update independently of each other and quite often.
* When selecting, never select the whole state because you are going to get
* unnecessary re-renders. Select only the properties you need.
*
* This is why this state type is not exported - don't use it directly.
*/
var initialState = {
settings: {
layout: 'horizontal',
align: 'center',
verticalAlign: 'bottom',
itemSorter: 'value'
},
size: {
width: 0,
height: 0
},
payload: []
};
var legendSlice = (0, _toolkit.createSlice)({
name: 'legend',
initialState,
reducers: {
setLegendSize(state, action) {
state.size.width = action.payload.width;
state.size.height = action.payload.height;
},
setLegendSettings(state, action) {
state.settings.align = action.payload.align;
state.settings.layout = action.payload.layout;
state.settings.verticalAlign = action.payload.verticalAlign;
state.settings.itemSorter = action.payload.itemSorter;
},
addLegendPayload: {
reducer(state, action) {
state.payload.push((0, _immer.castDraft)(action.payload));
},
prepare: (0, _toolkit.prepareAutoBatched)()
},
replaceLegendPayload: {
reducer(state, action) {
var _action$payload = action.payload,
prev = _action$payload.prev,
next = _action$payload.next;
var index = (0, _toolkit.current)(state).payload.indexOf((0, _immer.castDraft)(prev));
if (index > -1) {
state.payload[index] = (0, _immer.castDraft)(next);
}
},
prepare: (0, _toolkit.prepareAutoBatched)()
},
removeLegendPayload: {
reducer(state, action) {
var index = (0, _toolkit.current)(state).payload.indexOf((0, _immer.castDraft)(action.payload));
if (index > -1) {
state.payload.splice(index, 1);
}
},
prepare: (0, _toolkit.prepareAutoBatched)()
}
}
});
var _legendSlice$actions = legendSlice.actions,
setLegendSize = exports.setLegendSize = _legendSlice$actions.setLegendSize,
setLegendSettings = exports.setLegendSettings = _legendSlice$actions.setLegendSettings,
addLegendPayload = exports.addLegendPayload = _legendSlice$actions.addLegendPayload,
replaceLegendPayload = exports.replaceLegendPayload = _legendSlice$actions.replaceLegendPayload,
removeLegendPayload = exports.removeLegendPayload = _legendSlice$actions.removeLegendPayload;
var legendReducer = exports.legendReducer = legendSlice.reducer;

View file

@ -0,0 +1,115 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.mouseMoveMiddleware = exports.mouseMoveAction = exports.mouseClickMiddleware = exports.mouseClickAction = void 0;
var _toolkit = require("@reduxjs/toolkit");
var _tooltipSlice = require("./tooltipSlice");
var _selectActivePropsFromChartPointer = require("./selectors/selectActivePropsFromChartPointer");
var _selectTooltipEventType = require("./selectors/selectTooltipEventType");
var _getRelativeCoordinate = require("../util/getRelativeCoordinate");
var mouseClickAction = exports.mouseClickAction = (0, _toolkit.createAction)('mouseClick');
var mouseClickMiddleware = exports.mouseClickMiddleware = (0, _toolkit.createListenerMiddleware)();
// TODO: there's a bug here when you click the chart the activeIndex resets to zero
mouseClickMiddleware.startListening({
actionCreator: mouseClickAction,
effect: (action, listenerApi) => {
var mousePointer = action.payload;
var activeProps = (0, _selectActivePropsFromChartPointer.selectActivePropsFromChartPointer)(listenerApi.getState(), (0, _getRelativeCoordinate.getRelativeCoordinate)(mousePointer));
if ((activeProps === null || activeProps === void 0 ? void 0 : activeProps.activeIndex) != null) {
listenerApi.dispatch((0, _tooltipSlice.setMouseClickAxisIndex)({
activeIndex: activeProps.activeIndex,
activeDataKey: undefined,
activeCoordinate: activeProps.activeCoordinate
}));
}
}
});
var mouseMoveAction = exports.mouseMoveAction = (0, _toolkit.createAction)('mouseMove');
var mouseMoveMiddleware = exports.mouseMoveMiddleware = (0, _toolkit.createListenerMiddleware)();
/*
* This single rafId is safe because:
* 1. Each chart has its own Redux store instance with its own middleware
* 2. mouseMoveAction only fires from one DOM element (the chart wrapper)
* 3. Rapid mousemove events from the same element SHOULD debounce - we only care about the latest position
* This is different from externalEventsMiddleware which handles multiple event types
* (click, mouseenter, mouseleave, etc.) that should NOT cancel each other.
*/
var rafId = null;
var timeoutId = null;
var latestChartPointer = null;
mouseMoveMiddleware.startListening({
actionCreator: mouseMoveAction,
effect: (action, listenerApi) => {
var mousePointer = action.payload;
var state = listenerApi.getState();
var _state$eventSettings = state.eventSettings,
throttleDelay = _state$eventSettings.throttleDelay,
throttledEvents = _state$eventSettings.throttledEvents;
var isThrottled = throttledEvents === 'all' || (throttledEvents === null || throttledEvents === void 0 ? void 0 : throttledEvents.includes('mousemove'));
// Cancel any pending execution
if (rafId !== null) {
cancelAnimationFrame(rafId);
rafId = null;
}
if (timeoutId !== null && (typeof throttleDelay !== 'number' || !isThrottled)) {
clearTimeout(timeoutId);
timeoutId = null;
}
/*
* Here it is important to resolve the chart pointer _before_ the callback,
* because once we leave the current event loop, the mousePointer event object will lose
* reference to currentTarget which getRelativeCoordinate uses.
*/
latestChartPointer = (0, _getRelativeCoordinate.getRelativeCoordinate)(mousePointer);
var callback = () => {
/*
* Here we read a fresh state again inside the callback to ensure we have the latest state values
* after any potential actions that may have been dispatched between the original event and this callback.
*/
var currentState = listenerApi.getState();
var tooltipEventType = (0, _selectTooltipEventType.selectTooltipEventType)(currentState, currentState.tooltip.settings.shared);
if (!latestChartPointer) {
rafId = null;
timeoutId = null;
return;
}
/*
* This functionality only applies to charts that have axes.
* Graphical items have its own mouse events handling mechanism where they attach events directly to the items.
*/
if (tooltipEventType === 'axis') {
var activeProps = (0, _selectActivePropsFromChartPointer.selectActivePropsFromChartPointer)(currentState, latestChartPointer);
if ((activeProps === null || activeProps === void 0 ? void 0 : activeProps.activeIndex) != null) {
listenerApi.dispatch((0, _tooltipSlice.setMouseOverAxisIndex)({
activeIndex: activeProps.activeIndex,
activeDataKey: undefined,
activeCoordinate: activeProps.activeCoordinate
}));
} else {
// this is needed to clear tooltip state when the mouse moves out of the inRange (svg - offset) function, but not yet out of the svg
listenerApi.dispatch((0, _tooltipSlice.mouseLeaveChart)());
}
}
rafId = null;
timeoutId = null;
};
if (!isThrottled) {
callback();
return;
}
if (throttleDelay === 'raf') {
rafId = requestAnimationFrame(callback);
} else if (typeof throttleDelay === 'number') {
if (timeoutId === null) {
timeoutId = setTimeout(callback, throttleDelay);
}
}
}
});

View file

@ -0,0 +1,48 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.optionsReducer = exports.createEventEmitter = exports.arrayTooltipSearcher = void 0;
var _toolkit = require("@reduxjs/toolkit");
var _DataUtils = require("../util/DataUtils");
/**
* These chart options are decided internally, by Recharts,
* and will not change during the lifetime of the chart.
*
* Changing these options can be done by swapping the root element
* which will make a brand-new Redux store.
*
* If you want to store options that can be changed by the user,
* use UpdatableChartOptions in rootPropsSlice.ts.
*/
var arrayTooltipSearcher = (data, strIndex) => {
if (!strIndex) return undefined;
if (!Array.isArray(data)) return undefined;
var numIndex = Number.parseInt(strIndex, 10);
if ((0, _DataUtils.isNan)(numIndex)) {
return undefined;
}
return data[numIndex];
};
exports.arrayTooltipSearcher = arrayTooltipSearcher;
var initialState = {
chartName: '',
tooltipPayloadSearcher: () => undefined,
eventEmitter: undefined,
defaultTooltipEventType: 'axis'
};
var optionsSlice = (0, _toolkit.createSlice)({
name: 'options',
initialState,
reducers: {
createEventEmitter: state => {
if (state.eventEmitter == null) {
state.eventEmitter = Symbol('rechartsEventEmitter');
}
}
}
});
var optionsReducer = exports.optionsReducer = optionsSlice.reducer;
var createEventEmitter = exports.createEventEmitter = optionsSlice.actions.createEventEmitter;

View file

@ -0,0 +1,36 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.removeRadiusAxis = exports.removeAngleAxis = exports.polarAxisReducer = exports.addRadiusAxis = exports.addAngleAxis = void 0;
var _toolkit = require("@reduxjs/toolkit");
var _immer = require("immer");
var initialState = {
radiusAxis: {},
angleAxis: {}
};
var polarAxisSlice = (0, _toolkit.createSlice)({
name: 'polarAxis',
initialState,
reducers: {
addRadiusAxis(state, action) {
state.radiusAxis[action.payload.id] = (0, _immer.castDraft)(action.payload);
},
removeRadiusAxis(state, action) {
delete state.radiusAxis[action.payload.id];
},
addAngleAxis(state, action) {
state.angleAxis[action.payload.id] = (0, _immer.castDraft)(action.payload);
},
removeAngleAxis(state, action) {
delete state.angleAxis[action.payload.id];
}
}
});
var _polarAxisSlice$actio = polarAxisSlice.actions,
addRadiusAxis = exports.addRadiusAxis = _polarAxisSlice$actio.addRadiusAxis,
removeRadiusAxis = exports.removeRadiusAxis = _polarAxisSlice$actio.removeRadiusAxis,
addAngleAxis = exports.addAngleAxis = _polarAxisSlice$actio.addAngleAxis,
removeAngleAxis = exports.removeAngleAxis = _polarAxisSlice$actio.removeAngleAxis;
var polarAxisReducer = exports.polarAxisReducer = polarAxisSlice.reducer;

View file

@ -0,0 +1,29 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.updatePolarOptions = exports.polarOptionsReducer = void 0;
var _toolkit = require("@reduxjs/toolkit");
var initialState = null;
var reducers = {
updatePolarOptions: (state, action) => {
if (state === null) {
return action.payload;
}
state.startAngle = action.payload.startAngle;
state.endAngle = action.payload.endAngle;
state.cx = action.payload.cx;
state.cy = action.payload.cy;
state.innerRadius = action.payload.innerRadius;
state.outerRadius = action.payload.outerRadius;
return state;
}
};
var polarOptionsSlice = (0, _toolkit.createSlice)({
name: 'polarOptions',
initialState,
reducers
});
var updatePolarOptions = exports.updatePolarOptions = polarOptionsSlice.actions.updatePolarOptions;
var polarOptionsReducer = exports.polarOptionsReducer = polarOptionsSlice.reducer;

View file

@ -0,0 +1,18 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.reduxDevtoolsJsonStringifyReplacer = reduxDevtoolsJsonStringifyReplacer;
function reduxDevtoolsJsonStringifyReplacer(key, value) {
if (value instanceof HTMLElement) {
return "HTMLElement <".concat(value.tagName, " class=\"").concat(value.className, "\">");
}
if (value === window) {
return 'global.window';
}
if (key === 'children' && typeof value === 'object' && value !== null) {
return '<<CHILDREN>>';
}
return value;
}

View file

@ -0,0 +1,54 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.removeLine = exports.removeDot = exports.removeArea = exports.referenceElementsSlice = exports.referenceElementsReducer = exports.addLine = exports.addDot = exports.addArea = void 0;
var _toolkit = require("@reduxjs/toolkit");
var _immer = require("immer");
var initialState = {
dots: [],
areas: [],
lines: []
};
var referenceElementsSlice = exports.referenceElementsSlice = (0, _toolkit.createSlice)({
name: 'referenceElements',
initialState,
reducers: {
addDot: (state, action) => {
state.dots.push(action.payload);
},
removeDot: (state, action) => {
var index = (0, _toolkit.current)(state).dots.findIndex(dot => dot === action.payload);
if (index !== -1) {
state.dots.splice(index, 1);
}
},
addArea: (state, action) => {
state.areas.push(action.payload);
},
removeArea: (state, action) => {
var index = (0, _toolkit.current)(state).areas.findIndex(area => area === action.payload);
if (index !== -1) {
state.areas.splice(index, 1);
}
},
addLine: (state, action) => {
state.lines.push((0, _immer.castDraft)(action.payload));
},
removeLine: (state, action) => {
var index = (0, _toolkit.current)(state).lines.findIndex(line => line === action.payload);
if (index !== -1) {
state.lines.splice(index, 1);
}
}
}
});
var _referenceElementsSli = referenceElementsSlice.actions,
addDot = exports.addDot = _referenceElementsSli.addDot,
removeDot = exports.removeDot = _referenceElementsSli.removeDot,
addArea = exports.addArea = _referenceElementsSli.addArea,
removeArea = exports.removeArea = _referenceElementsSli.removeArea,
addLine = exports.addLine = _referenceElementsSli.addLine,
removeLine = exports.removeLine = _referenceElementsSli.removeLine;
var referenceElementsReducer = exports.referenceElementsReducer = referenceElementsSlice.reducer;

View file

@ -0,0 +1,45 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.setRenderedTicks = exports.renderedTicksSlice = exports.renderedTicksReducer = exports.removeRenderedTicks = void 0;
var _toolkit = require("@reduxjs/toolkit");
var _immer = require("immer");
/**
* @fileOverview this stores actually rendered ticks.
*
* What we do is that we have the domain -> ticks mapping in the cartesianSlice,
* which is fine but the result then goes to CartesianAxis where we use DOM measurement
* to decide which ticks to actually render.
*
* This renderedTickSlice stores those actually rendered ticks so that we can return them from a hook later.
*/
var initialState = {
xAxis: {},
yAxis: {}
};
var renderedTicksSlice = exports.renderedTicksSlice = (0, _toolkit.createSlice)({
name: 'renderedTicks',
initialState,
reducers: {
setRenderedTicks: (state, action) => {
var _action$payload = action.payload,
axisType = _action$payload.axisType,
axisId = _action$payload.axisId,
ticks = _action$payload.ticks;
state[axisType][axisId] = (0, _immer.castDraft)(ticks);
},
removeRenderedTicks: (state, action) => {
var _action$payload2 = action.payload,
axisType = _action$payload2.axisType,
axisId = _action$payload2.axisId;
delete state[axisType][axisId];
}
}
});
var _renderedTicksSlice$a = renderedTicksSlice.actions,
setRenderedTicks = exports.setRenderedTicks = _renderedTicksSlice$a.setRenderedTicks,
removeRenderedTicks = exports.removeRenderedTicks = _renderedTicksSlice$a.removeRenderedTicks;
var renderedTicksReducer = exports.renderedTicksReducer = renderedTicksSlice.reducer;

View file

@ -0,0 +1,47 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.updateOptions = exports.rootPropsReducer = exports.initialState = void 0;
var _toolkit = require("@reduxjs/toolkit");
/**
* These are chart options that users can choose - which means they can also
* choose to change them which should trigger a re-render.
*/
var initialState = exports.initialState = {
accessibilityLayer: true,
barCategoryGap: '10%',
barGap: 4,
barSize: undefined,
className: undefined,
maxBarSize: undefined,
stackOffset: 'none',
syncId: undefined,
syncMethod: 'index',
baseValue: undefined,
reverseStackOrder: false
};
var rootPropsSlice = (0, _toolkit.createSlice)({
name: 'rootProps',
initialState,
reducers: {
updateOptions: (state, action) => {
var _action$payload$barGa;
state.accessibilityLayer = action.payload.accessibilityLayer;
state.barCategoryGap = action.payload.barCategoryGap;
state.barGap = (_action$payload$barGa = action.payload.barGap) !== null && _action$payload$barGa !== void 0 ? _action$payload$barGa : initialState.barGap;
state.barSize = action.payload.barSize;
state.maxBarSize = action.payload.maxBarSize;
state.stackOffset = action.payload.stackOffset;
state.syncId = action.payload.syncId;
state.syncMethod = action.payload.syncMethod;
state.className = action.payload.className;
state.baseValue = action.payload.baseValue;
state.reverseStackOrder = action.payload.reverseStackOrder;
}
}
});
var rootPropsReducer = exports.rootPropsReducer = rootPropsSlice.reducer;
var updateOptions = exports.updateOptions = rootPropsSlice.actions.updateOptions;

View file

@ -0,0 +1,98 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.selectGraphicalItemStackedData = exports.selectArea = void 0;
var _reselect = require("reselect");
var _Area = require("../../cartesian/Area");
var _axisSelectors = require("./axisSelectors");
var _chartLayoutContext = require("../../context/chartLayoutContext");
var _dataSelectors = require("./dataSelectors");
var _ChartUtils = require("../../util/ChartUtils");
var _getStackSeriesIdentifier = require("../../util/stacks/getStackSeriesIdentifier");
var _rootPropsSelectors = require("./rootPropsSelectors");
var _graphicalItemSelectors = require("./graphicalItemSelectors");
var selectXAxisWithScale = (state, graphicalItemId, isPanorama) => (0, _axisSelectors.selectAxisWithScale)(state, 'xAxis', (0, _graphicalItemSelectors.selectXAxisIdFromGraphicalItemId)(state, graphicalItemId), isPanorama);
var selectXAxisTicks = (state, graphicalItemId, isPanorama) => (0, _axisSelectors.selectTicksOfGraphicalItem)(state, 'xAxis', (0, _graphicalItemSelectors.selectXAxisIdFromGraphicalItemId)(state, graphicalItemId), isPanorama);
var selectYAxisWithScale = (state, graphicalItemId, isPanorama) => (0, _axisSelectors.selectAxisWithScale)(state, 'yAxis', (0, _graphicalItemSelectors.selectYAxisIdFromGraphicalItemId)(state, graphicalItemId), isPanorama);
var selectYAxisTicks = (state, graphicalItemId, isPanorama) => (0, _axisSelectors.selectTicksOfGraphicalItem)(state, 'yAxis', (0, _graphicalItemSelectors.selectYAxisIdFromGraphicalItemId)(state, graphicalItemId), isPanorama);
var selectBandSize = (0, _reselect.createSelector)([_chartLayoutContext.selectChartLayout, selectXAxisWithScale, selectYAxisWithScale, selectXAxisTicks, selectYAxisTicks], (layout, xAxis, yAxis, xAxisTicks, yAxisTicks) => {
if ((0, _ChartUtils.isCategoricalAxis)(layout, 'xAxis')) {
return (0, _ChartUtils.getBandSizeOfAxis)(xAxis, xAxisTicks, false);
}
return (0, _ChartUtils.getBandSizeOfAxis)(yAxis, yAxisTicks, false);
});
var pickAreaId = (_state, id) => id;
/*
* There is a race condition problem because we read some data from props and some from the state.
* The state is updated through a dispatch and is one render behind,
* and so we have this weird one tick render where the displayedData in one selector have the old dataKey
* but the new dataKey in another selector.
*
* A proper fix is to either move everything into the state, or read the dataKey always from props
* - but this is a smaller change.
*/
var selectSynchronisedAreaSettings = (0, _reselect.createSelector)([_axisSelectors.selectUnfilteredCartesianItems, pickAreaId], (graphicalItems, id) => graphicalItems.filter(item => item.type === 'area').find(item => item.id === id));
var selectNumericalAxisType = state => {
var layout = (0, _chartLayoutContext.selectChartLayout)(state);
var isXAxisCategorical = (0, _ChartUtils.isCategoricalAxis)(layout, 'xAxis');
return isXAxisCategorical ? 'yAxis' : 'xAxis';
};
var selectNumericalAxisIdFromGraphicalItemId = (state, graphicalItemId) => {
var axisType = selectNumericalAxisType(state);
if (axisType === 'yAxis') {
return (0, _graphicalItemSelectors.selectYAxisIdFromGraphicalItemId)(state, graphicalItemId);
}
return (0, _graphicalItemSelectors.selectXAxisIdFromGraphicalItemId)(state, graphicalItemId);
};
var selectNumericalAxisStackGroups = (state, graphicalItemId, isPanorama) => (0, _axisSelectors.selectStackGroups)(state, selectNumericalAxisType(state), selectNumericalAxisIdFromGraphicalItemId(state, graphicalItemId), isPanorama);
var selectGraphicalItemStackedData = exports.selectGraphicalItemStackedData = (0, _reselect.createSelector)([selectSynchronisedAreaSettings, selectNumericalAxisStackGroups], (areaSettings, stackGroups) => {
var _stackGroups$stackId;
if (areaSettings == null || stackGroups == null) {
return undefined;
}
var stackId = areaSettings.stackId;
var stackSeriesIdentifier = (0, _getStackSeriesIdentifier.getStackSeriesIdentifier)(areaSettings);
if (stackId == null || stackSeriesIdentifier == null) {
return undefined;
}
var groups = (_stackGroups$stackId = stackGroups[stackId]) === null || _stackGroups$stackId === void 0 ? void 0 : _stackGroups$stackId.stackedData;
var found = groups === null || groups === void 0 ? void 0 : groups.find(v => v.key === stackSeriesIdentifier);
if (found == null) {
return undefined;
}
return found.map(item => [item[0], item[1]]);
});
var selectArea = exports.selectArea = (0, _reselect.createSelector)([_chartLayoutContext.selectChartLayout, selectXAxisWithScale, selectYAxisWithScale, selectXAxisTicks, selectYAxisTicks, selectGraphicalItemStackedData, _dataSelectors.selectChartDataWithIndexesIfNotInPanoramaPosition3, selectBandSize, selectSynchronisedAreaSettings, _rootPropsSelectors.selectChartBaseValue], (layout, xAxis, yAxis, xAxisTicks, yAxisTicks, stackedData, _ref, bandSize, areaSettings, chartBaseValue) => {
var chartData = _ref.chartData,
dataStartIndex = _ref.dataStartIndex,
dataEndIndex = _ref.dataEndIndex;
if (areaSettings == null || layout !== 'horizontal' && layout !== 'vertical' || xAxis == null || yAxis == null || xAxisTicks == null || yAxisTicks == null || xAxisTicks.length === 0 || yAxisTicks.length === 0 || bandSize == null) {
return undefined;
}
var data = areaSettings.data;
var displayedData;
if (data && data.length > 0) {
displayedData = data;
} else {
displayedData = chartData === null || chartData === void 0 ? void 0 : chartData.slice(dataStartIndex, dataEndIndex + 1);
}
if (displayedData == null) {
return undefined;
}
return (0, _Area.computeArea)({
layout,
xAxis,
yAxis,
xAxisTicks,
yAxisTicks,
dataStartIndex,
areaSettings,
stackedData,
displayedData,
chartBaseValue,
bandSize
});
});

View file

@ -0,0 +1,37 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.arrayContentsAreEqualCheck = arrayContentsAreEqualCheck;
exports.emptyArraysAreEqualCheck = emptyArraysAreEqualCheck;
/**
* Checks if two arrays are equal, treating empty arrays as equal regardless of reference.
* If both arrays are non-empty, it checks for reference equality.
* @param a
* @param b
*/
function emptyArraysAreEqualCheck(a, b) {
if (Array.isArray(a) && Array.isArray(b) && a.length === 0 && b.length === 0) {
// empty arrays are always equal, regardless of reference
return true;
}
return a === b;
}
/**
* Checks if two arrays have the same contents in the same order.
* @param a
* @param b
*/
function arrayContentsAreEqualCheck(a, b) {
if (a.length === b.length) {
for (var i = 0; i < a.length; i++) {
if (a[i] !== b[i]) {
return false;
}
}
return true;
}
return false;
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,166 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.selectStackedDataOfItem = exports.selectMaxBarSize = exports.selectBarSizeList = exports.selectBarRectangles = exports.selectBarPosition = exports.selectBarCartesianAxisSize = exports.selectBarBandSize = exports.selectAxisBandSize = exports.selectAllVisibleBars = exports.selectAllBarPositions = void 0;
var _reselect = require("reselect");
var _axisSelectors = require("./axisSelectors");
var _DataUtils = require("../../util/DataUtils");
var _ChartUtils = require("../../util/ChartUtils");
var _Bar = require("../../cartesian/Bar");
var _chartLayoutContext = require("../../context/chartLayoutContext");
var _dataSelectors = require("./dataSelectors");
var _selectChartOffsetInternal = require("./selectChartOffsetInternal");
var _rootPropsSelectors = require("./rootPropsSelectors");
var _combineBarSizeList = require("./combiners/combineBarSizeList");
var _combineAllBarPositions = require("./combiners/combineAllBarPositions");
var _combineStackedData = require("./combiners/combineStackedData");
var _graphicalItemSelectors = require("./graphicalItemSelectors");
var _combineBarPosition = require("./combiners/combineBarPosition");
var pickIsPanorama = (_state, _id, isPanorama) => isPanorama;
var pickBarId = (_state, id) => id;
var selectSynchronisedBarSettings = (0, _reselect.createSelector)([_axisSelectors.selectUnfilteredCartesianItems, pickBarId], (graphicalItems, id) => graphicalItems.filter(item => item.type === 'bar').find(item => item.id === id));
var selectMaxBarSize = exports.selectMaxBarSize = (0, _reselect.createSelector)([selectSynchronisedBarSettings], barSettings => barSettings === null || barSettings === void 0 ? void 0 : barSettings.maxBarSize);
var pickCells = (_state, _id, _isPanorama, cells) => cells;
var selectAllVisibleBars = exports.selectAllVisibleBars = (0, _reselect.createSelector)([_chartLayoutContext.selectChartLayout, _axisSelectors.selectUnfilteredCartesianItems, _graphicalItemSelectors.selectXAxisIdFromGraphicalItemId, _graphicalItemSelectors.selectYAxisIdFromGraphicalItemId, pickIsPanorama], (layout, allItems, xAxisId, yAxisId, isPanorama) => allItems.filter(i => {
if (layout === 'horizontal') {
return i.xAxisId === xAxisId;
}
return i.yAxisId === yAxisId;
}).filter(i => i.isPanorama === isPanorama).filter(i => i.hide === false).filter(i => i.type === 'bar'));
var selectBarStackGroups = (state, id, isPanorama) => {
var layout = (0, _chartLayoutContext.selectChartLayout)(state);
var xAxisId = (0, _graphicalItemSelectors.selectXAxisIdFromGraphicalItemId)(state, id);
var yAxisId = (0, _graphicalItemSelectors.selectYAxisIdFromGraphicalItemId)(state, id);
if (xAxisId == null || yAxisId == null) {
return undefined;
}
if (layout === 'horizontal') {
return (0, _axisSelectors.selectStackGroups)(state, 'yAxis', yAxisId, isPanorama);
}
return (0, _axisSelectors.selectStackGroups)(state, 'xAxis', xAxisId, isPanorama);
};
var selectBarCartesianAxisSize = (state, id) => {
var layout = (0, _chartLayoutContext.selectChartLayout)(state);
var xAxisId = (0, _graphicalItemSelectors.selectXAxisIdFromGraphicalItemId)(state, id);
var yAxisId = (0, _graphicalItemSelectors.selectYAxisIdFromGraphicalItemId)(state, id);
if (xAxisId == null || yAxisId == null) {
return undefined;
}
if (layout === 'horizontal') {
return (0, _axisSelectors.selectCartesianAxisSize)(state, 'xAxis', xAxisId);
}
return (0, _axisSelectors.selectCartesianAxisSize)(state, 'yAxis', yAxisId);
};
exports.selectBarCartesianAxisSize = selectBarCartesianAxisSize;
var selectBarSizeList = exports.selectBarSizeList = (0, _reselect.createSelector)([selectAllVisibleBars, _rootPropsSelectors.selectRootBarSize, selectBarCartesianAxisSize], _combineBarSizeList.combineBarSizeList);
var selectBarBandSize = (state, id, isPanorama) => {
var _ref, _getBandSizeOfAxis;
var barSettings = selectSynchronisedBarSettings(state, id);
if (barSettings == null) {
return 0;
}
var xAxisId = (0, _graphicalItemSelectors.selectXAxisIdFromGraphicalItemId)(state, id);
var yAxisId = (0, _graphicalItemSelectors.selectYAxisIdFromGraphicalItemId)(state, id);
if (xAxisId == null || yAxisId == null) {
return 0;
}
var layout = (0, _chartLayoutContext.selectChartLayout)(state);
var globalMaxBarSize = (0, _rootPropsSelectors.selectRootMaxBarSize)(state);
var childMaxBarSize = barSettings.maxBarSize;
var maxBarSize = (0, _DataUtils.isNullish)(childMaxBarSize) ? globalMaxBarSize : childMaxBarSize;
var axis, ticks;
if (layout === 'horizontal') {
axis = (0, _axisSelectors.selectAxisWithScale)(state, 'xAxis', xAxisId, isPanorama);
ticks = (0, _axisSelectors.selectTicksOfGraphicalItem)(state, 'xAxis', xAxisId, isPanorama);
} else {
axis = (0, _axisSelectors.selectAxisWithScale)(state, 'yAxis', yAxisId, isPanorama);
ticks = (0, _axisSelectors.selectTicksOfGraphicalItem)(state, 'yAxis', yAxisId, isPanorama);
}
return (_ref = (_getBandSizeOfAxis = (0, _ChartUtils.getBandSizeOfAxis)(axis, ticks, true)) !== null && _getBandSizeOfAxis !== void 0 ? _getBandSizeOfAxis : maxBarSize) !== null && _ref !== void 0 ? _ref : 0;
};
exports.selectBarBandSize = selectBarBandSize;
var selectAxisBandSize = (state, id, isPanorama) => {
var layout = (0, _chartLayoutContext.selectChartLayout)(state);
var xAxisId = (0, _graphicalItemSelectors.selectXAxisIdFromGraphicalItemId)(state, id);
var yAxisId = (0, _graphicalItemSelectors.selectYAxisIdFromGraphicalItemId)(state, id);
if (xAxisId == null || yAxisId == null) {
return undefined;
}
var axis, ticks;
if (layout === 'horizontal') {
axis = (0, _axisSelectors.selectAxisWithScale)(state, 'xAxis', xAxisId, isPanorama);
ticks = (0, _axisSelectors.selectTicksOfGraphicalItem)(state, 'xAxis', xAxisId, isPanorama);
} else {
axis = (0, _axisSelectors.selectAxisWithScale)(state, 'yAxis', yAxisId, isPanorama);
ticks = (0, _axisSelectors.selectTicksOfGraphicalItem)(state, 'yAxis', yAxisId, isPanorama);
}
return (0, _ChartUtils.getBandSizeOfAxis)(axis, ticks);
};
exports.selectAxisBandSize = selectAxisBandSize;
var selectAllBarPositions = exports.selectAllBarPositions = (0, _reselect.createSelector)([selectBarSizeList, _rootPropsSelectors.selectRootMaxBarSize, _rootPropsSelectors.selectBarGap, _rootPropsSelectors.selectBarCategoryGap, selectBarBandSize, selectAxisBandSize, selectMaxBarSize], _combineAllBarPositions.combineAllBarPositions);
var selectXAxisWithScale = (state, id, isPanorama) => {
var xAxisId = (0, _graphicalItemSelectors.selectXAxisIdFromGraphicalItemId)(state, id);
if (xAxisId == null) {
return undefined;
}
return (0, _axisSelectors.selectAxisWithScale)(state, 'xAxis', xAxisId, isPanorama);
};
var selectYAxisWithScale = (state, id, isPanorama) => {
var yAxisId = (0, _graphicalItemSelectors.selectYAxisIdFromGraphicalItemId)(state, id);
if (yAxisId == null) {
return undefined;
}
return (0, _axisSelectors.selectAxisWithScale)(state, 'yAxis', yAxisId, isPanorama);
};
var selectXAxisTicks = (state, id, isPanorama) => {
var xAxisId = (0, _graphicalItemSelectors.selectXAxisIdFromGraphicalItemId)(state, id);
if (xAxisId == null) {
return undefined;
}
return (0, _axisSelectors.selectTicksOfGraphicalItem)(state, 'xAxis', xAxisId, isPanorama);
};
var selectYAxisTicks = (state, id, isPanorama) => {
var yAxisId = (0, _graphicalItemSelectors.selectYAxisIdFromGraphicalItemId)(state, id);
if (yAxisId == null) {
return undefined;
}
return (0, _axisSelectors.selectTicksOfGraphicalItem)(state, 'yAxis', yAxisId, isPanorama);
};
var selectBarPosition = exports.selectBarPosition = (0, _reselect.createSelector)([selectAllBarPositions, selectSynchronisedBarSettings], _combineBarPosition.combineBarPosition);
var selectStackedDataOfItem = exports.selectStackedDataOfItem = (0, _reselect.createSelector)([selectBarStackGroups, selectSynchronisedBarSettings], _combineStackedData.combineStackedData);
var selectBarRectangles = exports.selectBarRectangles = (0, _reselect.createSelector)([_selectChartOffsetInternal.selectChartOffsetInternal, _selectChartOffsetInternal.selectAxisViewBox, selectXAxisWithScale, selectYAxisWithScale, selectXAxisTicks, selectYAxisTicks, selectBarPosition, _chartLayoutContext.selectChartLayout, _dataSelectors.selectChartDataWithIndexesIfNotInPanoramaPosition3, selectAxisBandSize, selectStackedDataOfItem, selectSynchronisedBarSettings, pickCells], (offset, axisViewBox, xAxis, yAxis, xAxisTicks, yAxisTicks, pos, layout, _ref2, bandSize, stackedData, barSettings, cells) => {
var chartData = _ref2.chartData,
dataStartIndex = _ref2.dataStartIndex,
dataEndIndex = _ref2.dataEndIndex;
if (barSettings == null || pos == null || axisViewBox == null || layout !== 'horizontal' && layout !== 'vertical' || xAxis == null || yAxis == null || xAxisTicks == null || yAxisTicks == null || bandSize == null) {
return undefined;
}
var data = barSettings.data;
var displayedData;
if (data != null && data.length > 0) {
displayedData = data;
} else {
displayedData = chartData === null || chartData === void 0 ? void 0 : chartData.slice(dataStartIndex, dataEndIndex + 1);
}
if (displayedData == null) {
return undefined;
}
return (0, _Bar.computeBarRectangles)({
layout,
barSettings,
pos,
parentViewBox: axisViewBox,
bandSize,
xAxis,
yAxis,
xAxisTicks,
yAxisTicks,
stackedData,
displayedData,
offset,
cells,
dataStartIndex
});
});

View file

@ -0,0 +1,58 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.selectStackRects = exports.selectAllBarsInStack = exports.expandRectangle = void 0;
var _reselect = require("reselect");
var _axisSelectors = require("./axisSelectors");
var _barSelectors = require("./barSelectors");
var pickStackId = (state, stackId) => stackId;
var pickIsPanorama = (state, stackId, isPanorama) => isPanorama;
var selectAllBarsInStack = exports.selectAllBarsInStack = (0, _reselect.createSelector)([pickStackId, _axisSelectors.selectUnfilteredCartesianItems, pickIsPanorama], (stackId, allItems, isPanorama) => {
return allItems.filter(i => i.type === 'bar').filter(i => i.stackId === stackId).filter(i => i.isPanorama === isPanorama).filter(i => !i.hide);
});
var selectAllBarIdsInStack = (0, _reselect.createSelector)([selectAllBarsInStack], allBars => {
return allBars.map(bar => bar.id);
});
/**
* Takes two rectangles and returns a new rectangle that encompasses both.
* It takes the minimum x and y, and the maximum width and height.
* It handles overlapping rectangles, and rectangles with a gap between them.
* @param rect1
* @param rect2
*/
var expandRectangle = (rect1, rect2) => {
if (!rect1) {
return rect2;
}
if (!rect2) {
return rect1;
}
var x = Math.min(rect1.x, rect1.x + rect1.width, rect2.x, rect2.x + rect2.width);
var y = Math.min(rect1.y, rect1.y + rect1.height, rect2.y, rect2.y + rect2.height);
var maxX = Math.max(rect1.x, rect1.x + rect1.width, rect2.x, rect2.x + rect2.width);
var maxY = Math.max(rect1.y, rect1.y + rect1.height, rect2.y, rect2.y + rect2.height);
var width = maxX - x;
var height = maxY - y;
return {
x,
y,
width,
height
};
};
exports.expandRectangle = expandRectangle;
var combineStackRects = (state, stackId, isPanorama) => {
var allBarIds = selectAllBarIdsInStack(state, stackId, isPanorama);
var stackRects = [];
allBarIds.forEach(barId => {
var rectangles = (0, _barSelectors.selectBarRectangles)(state, barId, isPanorama, undefined);
rectangles === null || rectangles === void 0 || rectangles.forEach(rect => {
var rectIndex = rect.originalDataIndex;
stackRects[rectIndex] = expandRectangle(stackRects[rectIndex], rect);
});
});
return stackRects;
};
var selectStackRects = exports.selectStackRects = (0, _reselect.createSelector)([state => state, pickStackId, pickIsPanorama], combineStackRects);

View file

@ -0,0 +1,18 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.selectBrushSettings = exports.selectBrushDimensions = void 0;
var _reselect = require("reselect");
var _selectChartOffsetInternal = require("./selectChartOffsetInternal");
var _containerSelectors = require("./containerSelectors");
var _DataUtils = require("../../util/DataUtils");
var selectBrushSettings = state => state.brush;
exports.selectBrushSettings = selectBrushSettings;
var selectBrushDimensions = exports.selectBrushDimensions = (0, _reselect.createSelector)([selectBrushSettings, _selectChartOffsetInternal.selectChartOffsetInternal, _containerSelectors.selectMargin], (brushSettings, offset, margin) => ({
height: brushSettings.height,
x: (0, _DataUtils.isNumber)(brushSettings.x) ? brushSettings.x : offset.left,
y: (0, _DataUtils.isNumber)(brushSettings.y) ? brushSettings.y : offset.top + offset.height + offset.brushBottom - ((margin === null || margin === void 0 ? void 0 : margin.bottom) || 0),
width: (0, _DataUtils.isNumber)(brushSettings.width) ? brushSettings.width : offset.width
}));

View file

@ -0,0 +1,16 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.combineActiveLabel = void 0;
var _DataUtils = require("../../../util/DataUtils");
var combineActiveLabel = (tooltipTicks, activeIndex) => {
var _tooltipTicks$n;
var n = Number(activeIndex);
if ((0, _DataUtils.isNan)(n) || activeIndex == null) {
return undefined;
}
return n >= 0 ? tooltipTicks === null || tooltipTicks === void 0 || (_tooltipTicks$n = tooltipTicks[n]) === null || _tooltipTicks$n === void 0 ? void 0 : _tooltipTicks$n.value : undefined;
};
exports.combineActiveLabel = combineActiveLabel;

View file

@ -0,0 +1,77 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.combineActiveTooltipIndex = void 0;
var _isWellBehavedNumber = require("../../../util/isWellBehavedNumber");
var _ChartUtils = require("../../../util/ChartUtils");
var _isDomainSpecifiedByUser = require("../../../util/isDomainSpecifiedByUser");
function toFiniteNumber(value) {
if (typeof value === 'number') {
return Number.isFinite(value) ? value : undefined;
}
if (value instanceof Date) {
var numericValue = value.valueOf();
return Number.isFinite(numericValue) ? numericValue : undefined;
}
var parsed = Number(value);
return Number.isFinite(parsed) ? parsed : undefined;
}
function isValueWithinNumberDomain(value, domain) {
var numericValue = toFiniteNumber(value);
var lowerBound = domain[0];
var upperBound = domain[1];
if (numericValue === undefined) {
return false;
}
var min = Math.min(lowerBound, upperBound);
var max = Math.max(lowerBound, upperBound);
return numericValue >= min && numericValue <= max;
}
function isValueWithinDomain(entry, axisDataKey, domain) {
if (domain == null || axisDataKey == null) {
return true;
}
var value = (0, _ChartUtils.getValueByDataKey)(entry, axisDataKey);
if (value == null) {
return true;
}
if (!(0, _isDomainSpecifiedByUser.isWellFormedNumberDomain)(domain)) {
return true;
}
return isValueWithinNumberDomain(value, domain);
}
var combineActiveTooltipIndex = (tooltipInteraction, chartData, axisDataKey, domain) => {
var desiredIndex = tooltipInteraction === null || tooltipInteraction === void 0 ? void 0 : tooltipInteraction.index;
if (desiredIndex == null) {
return null;
}
var indexAsNumber = Number(desiredIndex);
if (!(0, _isWellBehavedNumber.isWellBehavedNumber)(indexAsNumber)) {
// this is for charts like Sankey and Treemap that do not support numerical indexes. We need a proper solution for this before we can start supporting keyboard events on these charts.
return desiredIndex;
}
/*
* Zero is a trivial limit for single-dimensional charts like Line and Area,
* but this also needs a support for multidimensional charts like Sankey and Treemap! TODO
*/
var lowerLimit = 0;
var upperLimit = +Infinity;
if (chartData.length > 0) {
upperLimit = chartData.length - 1;
}
// now let's clamp the desiredIndex between the limits
var clampedIndex = Math.max(lowerLimit, Math.min(indexAsNumber, upperLimit));
var entry = chartData[clampedIndex];
if (entry == null) {
return String(clampedIndex);
}
if (!isValueWithinDomain(entry, axisDataKey, domain)) {
return null;
}
return String(clampedIndex);
};
exports.combineActiveTooltipIndex = combineActiveTooltipIndex;

View file

@ -0,0 +1,92 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.combineAllBarPositions = void 0;
var _DataUtils = require("../../../util/DataUtils");
var _isWellBehavedNumber = require("../../../util/isWellBehavedNumber");
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
function getBarPositions(barGap, barCategoryGap, bandSize, sizeList, maxBarSize) {
var _sizeList$;
var len = sizeList.length;
if (len < 1) {
return undefined;
}
var realBarGap = (0, _DataUtils.getPercentValue)(barGap, bandSize, 0, true);
var result;
var initialValue = [];
// whether is barSize set by user
// Okay but why does it check only for the first element? What if the first element is set but others are not?
if ((0, _isWellBehavedNumber.isWellBehavedNumber)((_sizeList$ = sizeList[0]) === null || _sizeList$ === void 0 ? void 0 : _sizeList$.barSize)) {
var useFull = false;
var fullBarSize = bandSize / len;
var sum = sizeList.reduce((res, entry) => res + (entry.barSize || 0), 0);
sum += (len - 1) * realBarGap;
if (sum >= bandSize) {
sum -= (len - 1) * realBarGap;
realBarGap = 0;
}
if (sum >= bandSize && fullBarSize > 0) {
useFull = true;
fullBarSize *= 0.9;
sum = len * fullBarSize;
}
var offset = Math.round((bandSize - sum) / 2);
var prev = {
offset: offset - realBarGap,
size: 0
};
result = sizeList.reduce((res, entry) => {
var _entry$barSize;
var newPosition = {
stackId: entry.stackId,
dataKeys: entry.dataKeys,
position: {
offset: prev.offset + prev.size + realBarGap,
size: useFull ? fullBarSize : (_entry$barSize = entry.barSize) !== null && _entry$barSize !== void 0 ? _entry$barSize : 0
}
};
var newRes = [...res, newPosition];
prev = newPosition.position;
return newRes;
}, initialValue);
} else {
var _offset = (0, _DataUtils.getPercentValue)(barCategoryGap, bandSize, 0, true);
if (bandSize - 2 * _offset - (len - 1) * realBarGap <= 0) {
realBarGap = 0;
}
var originalSize = (bandSize - 2 * _offset - (len - 1) * realBarGap) / len;
if (originalSize > 1) {
originalSize = Math.round(originalSize);
}
var size = (0, _isWellBehavedNumber.isWellBehavedNumber)(maxBarSize) ? Math.min(originalSize, maxBarSize) : originalSize;
result = sizeList.reduce((res, entry, i) => [...res, {
stackId: entry.stackId,
dataKeys: entry.dataKeys,
position: {
offset: _offset + (originalSize + realBarGap) * i + (originalSize - size) / 2,
size
}
}], initialValue);
}
return result;
}
var combineAllBarPositions = (sizeList, globalMaxBarSize, barGap, barCategoryGap, barBandSize, bandSize, childMaxBarSize) => {
var maxBarSize = (0, _DataUtils.isNullish)(childMaxBarSize) ? globalMaxBarSize : childMaxBarSize;
var allBarPositions = getBarPositions(barGap, barCategoryGap, barBandSize !== bandSize ? barBandSize : bandSize, sizeList, maxBarSize);
if (barBandSize !== bandSize && allBarPositions != null) {
allBarPositions = allBarPositions.map(pos => _objectSpread(_objectSpread({}, pos), {}, {
position: _objectSpread(_objectSpread({}, pos.position), {}, {
offset: pos.position.offset - barBandSize / 2
})
}));
}
return allBarPositions;
};
exports.combineAllBarPositions = combineAllBarPositions;

View file

@ -0,0 +1,16 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.combineAxisRangeWithReverse = void 0;
var combineAxisRangeWithReverse = (axisSettings, axisRange) => {
if (!axisSettings || !axisRange) {
return undefined;
}
if (axisSettings !== null && axisSettings !== void 0 && axisSettings.reversed) {
return [axisRange[1], axisRange[0]];
}
return axisRange;
};
exports.combineAxisRangeWithReverse = combineAxisRangeWithReverse;

View file

@ -0,0 +1,17 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.combineBarPosition = void 0;
var combineBarPosition = (allBarPositions, barSettings) => {
if (allBarPositions == null || barSettings == null) {
return undefined;
}
var position = allBarPositions.find(p => p.stackId === barSettings.stackId && barSettings.dataKey != null && p.dataKeys.includes(barSettings.dataKey));
if (position == null) {
return undefined;
}
return position.position;
};
exports.combineBarPosition = combineBarPosition;

View file

@ -0,0 +1,59 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.combineBarSizeList = void 0;
var _StackedGraphicalItem = require("../../types/StackedGraphicalItem");
var _DataUtils = require("../../../util/DataUtils");
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
var getBarSize = (globalSize, totalSize, selfSize) => {
var barSize = selfSize !== null && selfSize !== void 0 ? selfSize : globalSize;
if ((0, _DataUtils.isNullish)(barSize)) {
return undefined;
}
return (0, _DataUtils.getPercentValue)(barSize, totalSize, 0);
};
var combineBarSizeList = (allBars, globalSize, totalSize) => {
var initialValue = {};
var stackedBars = allBars.filter(_StackedGraphicalItem.isStacked);
var unstackedBars = allBars.filter(b => b.stackId == null);
var groupByStack = stackedBars.reduce((acc, bar) => {
var s = acc[bar.stackId];
if (s == null) {
s = [];
}
s.push(bar);
acc[bar.stackId] = s;
return acc;
}, initialValue);
var stackedSizeList = Object.entries(groupByStack).map(_ref => {
var _bars$;
var _ref2 = _slicedToArray(_ref, 2),
stackId = _ref2[0],
bars = _ref2[1];
var dataKeys = bars.map(b => b.dataKey);
var barSize = getBarSize(globalSize, totalSize, (_bars$ = bars[0]) === null || _bars$ === void 0 ? void 0 : _bars$.barSize);
return {
stackId,
dataKeys,
barSize
};
});
var unstackedSizeList = unstackedBars.map(b => {
var dataKeys = [b.dataKey].filter(dk => dk != null);
var barSize = getBarSize(globalSize, totalSize, b.barSize);
return {
stackId: undefined,
dataKeys,
barSize
};
});
return [...stackedSizeList, ...unstackedSizeList];
};
exports.combineBarSizeList = combineBarSizeList;

View file

@ -0,0 +1,49 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.combineCheckedDomain = void 0;
var _isDomainSpecifiedByUser = require("../../../util/isDomainSpecifiedByUser");
var _isWellBehavedNumber = require("../../../util/isWellBehavedNumber");
/**
* This function validates and transforms the axis domain so that it is safe to use in the provided scale.
*/
var combineCheckedDomain = (realScaleType, axisDomain) => {
if (axisDomain == null) {
return undefined;
}
switch (realScaleType) {
case 'linear':
{
/*
* linear scale only reads the first two numbers in the domain, and ignores everything else.
* So if it happens that someone somehow gave us a bigger domain,
* let's pick the min and max from it.
*/
if (!(0, _isDomainSpecifiedByUser.isWellFormedNumberDomain)(axisDomain)) {
var min, max;
for (var i = 0; i < axisDomain.length; i++) {
var value = axisDomain[i];
if (!(0, _isWellBehavedNumber.isWellBehavedNumber)(value)) {
continue;
}
if (min === undefined || value < min) {
min = value;
}
if (max === undefined || value > max) {
max = value;
}
}
if (min !== undefined && max !== undefined) {
return [min, max];
}
return undefined;
}
return axisDomain;
}
default:
return axisDomain;
}
};
exports.combineCheckedDomain = combineCheckedDomain;

View file

@ -0,0 +1,52 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.combineConfiguredScale = combineConfiguredScale;
exports.combineConfiguredScaleInternal = combineConfiguredScaleInternal;
var d3Scales = _interopRequireWildcard(require("victory-vendor/d3-scale"));
var _DataUtils = require("../../../util/DataUtils");
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
function getD3ScaleFromType(realScaleType) {
var scales = d3Scales;
if (realScaleType in scales && typeof scales[realScaleType] === 'function') {
return scales[realScaleType]();
}
var name = "scale".concat((0, _DataUtils.upperFirst)(realScaleType));
if (name in scales && typeof scales[name] === 'function') {
return scales[name]();
}
return undefined;
}
/**
* Converts external scale definition into internal RechartsScale definition.
* @param scale custom function scale - if you have the `string` from outside, use `combineRealScaleType` first which will validate it and return RechartsScaleType or undefined
* @param axisDomain
* @param axisRange
*/
function combineConfiguredScaleInternal(scale, axisDomain, axisRange) {
if (typeof scale === 'function') {
return scale.copy().domain(axisDomain).range(axisRange);
}
if (scale == null) {
return undefined;
}
var d3ScaleFunction = getD3ScaleFromType(scale);
if (d3ScaleFunction == null) {
return undefined;
}
d3ScaleFunction.domain(axisDomain).range(axisRange);
return d3ScaleFunction;
}
function combineConfiguredScale(axis, realScaleType, axisDomain, axisRange) {
if (axisDomain == null || axisRange == null) {
return undefined;
}
if (typeof axis.scale === 'function') {
return combineConfiguredScaleInternal(axis.scale, axisDomain, axisRange);
}
return combineConfiguredScaleInternal(realScaleType, axisDomain, axisRange);
}

View file

@ -0,0 +1,43 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.combineCoordinateForDefaultIndex = void 0;
var combineCoordinateForDefaultIndex = (width, height, layout, offset, tooltipTicks, defaultIndex, tooltipConfigurations) => {
if (defaultIndex == null) {
return undefined;
}
/*
* With defaultIndex alone, we don't have enough information to decide _which_ of the multiple tooltips to display.
* Maybe one day we could add new prop `activeGraphicalItemId` to the chart to help with that.
* Until then, we choose the first one.
*/
var firstConfiguration = tooltipConfigurations[0];
var maybePosition = firstConfiguration === null || firstConfiguration === void 0 ? void 0 : firstConfiguration.getPosition(defaultIndex);
if (maybePosition != null) {
return maybePosition;
}
var tick = tooltipTicks === null || tooltipTicks === void 0 ? void 0 : tooltipTicks[Number(defaultIndex)];
if (!tick) {
return undefined;
}
switch (layout) {
case 'horizontal':
{
return {
x: tick.coordinate,
y: (offset.top + height) / 2
};
}
default:
{
// This logic is not super sound - it conflates vertical, radial, centric layouts into just one. TODO improve!
return {
x: (offset.left + width) / 2,
y: tick.coordinate
};
}
}
};
exports.combineCoordinateForDefaultIndex = combineCoordinateForDefaultIndex;

View file

@ -0,0 +1,53 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.combineDisplayedStackedData = combineDisplayedStackedData;
var _getStackSeriesIdentifier = require("../../../util/stacks/getStackSeriesIdentifier");
var _ChartUtils = require("../../../util/ChartUtils");
/**
* In a stacked chart, each graphical item has its own data. That data could be either:
* - defined on the chart root, in which case the item gets a unique dataKey
* - or defined on the item itself, in which case multiple items can share the same dataKey
*
* That means we cannot use the dataKey as a unique identifier for the item.
*
* This type represents a single data point in a stacked chart, where each key is a series identifier
* and the value is the numeric value for that series using the numerical axis dataKey.
*/
function combineDisplayedStackedData(stackedGraphicalItems, _ref, tooltipAxisSettings) {
var _ref$chartData = _ref.chartData,
chartData = _ref$chartData === void 0 ? [] : _ref$chartData;
var allowDuplicatedCategory = tooltipAxisSettings.allowDuplicatedCategory,
tooltipDataKey = tooltipAxisSettings.dataKey;
// A map of tooltip data keys to the stacked data points
var knownItemsByDataKey = new Map();
stackedGraphicalItems.forEach(item => {
var _item$data;
// If there is no data on the individual item then we use the root chart data
var resolvedData = (_item$data = item.data) !== null && _item$data !== void 0 ? _item$data : chartData;
if (resolvedData == null || resolvedData.length === 0) {
// if that doesn't work then we skip this item
return;
}
var stackIdentifier = (0, _getStackSeriesIdentifier.getStackSeriesIdentifier)(item);
resolvedData.forEach((entry, index) => {
var tooltipValue = tooltipDataKey == null || allowDuplicatedCategory ? index : String((0, _ChartUtils.getValueByDataKey)(entry, tooltipDataKey, null));
var numericValue = (0, _ChartUtils.getValueByDataKey)(entry, item.dataKey, 0);
var curr;
if (knownItemsByDataKey.has(tooltipValue)) {
curr = knownItemsByDataKey.get(tooltipValue);
} else {
curr = {};
}
Object.assign(curr, {
[stackIdentifier]: numericValue
});
knownItemsByDataKey.set(tooltipValue, curr);
});
});
return Array.from(knownItemsByDataKey.values());
}

View file

@ -0,0 +1,16 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.combineInverseScaleFunction = combineInverseScaleFunction;
var _createCategoricalInverse = require("../../../util/scale/createCategoricalInverse");
function combineInverseScaleFunction(configuredScale) {
if (configuredScale == null) {
return undefined;
}
if ('invert' in configuredScale && typeof configuredScale.invert === 'function') {
return configuredScale.invert.bind(configuredScale);
}
return (0, _createCategoricalInverse.createCategoricalInverse)(configuredScale, undefined);
}

View file

@ -0,0 +1,36 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.combineRealScaleType = void 0;
var d3Scales = _interopRequireWildcard(require("victory-vendor/d3-scale"));
var _DataUtils = require("../../../util/DataUtils");
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
function getD3ScaleName(name) {
return "scale".concat((0, _DataUtils.upperFirst)(name));
}
function isSupportedScaleName(name) {
return getD3ScaleName(name) in d3Scales;
}
var combineRealScaleType = (axisConfig, hasBar, chartType) => {
if (axisConfig == null) {
return undefined;
}
var scale = axisConfig.scale,
type = axisConfig.type;
if (scale === 'auto') {
if (type === 'category' && chartType && (chartType.indexOf('LineChart') >= 0 || chartType.indexOf('AreaChart') >= 0 || chartType.indexOf('ComposedChart') >= 0 && !hasBar)) {
return 'point';
}
if (type === 'category') {
return 'band';
}
return 'linear';
}
if (typeof scale === 'string') {
return isSupportedScaleName(scale) ? scale : 'point';
}
return undefined;
};
exports.combineRealScaleType = combineRealScaleType;

View file

@ -0,0 +1,27 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.combineStackedData = void 0;
var _getStackSeriesIdentifier = require("../../../util/stacks/getStackSeriesIdentifier");
var combineStackedData = (stackGroups, barSettings) => {
var stackSeriesIdentifier = (0, _getStackSeriesIdentifier.getStackSeriesIdentifier)(barSettings);
if (!stackGroups || stackSeriesIdentifier == null || barSettings == null) {
return undefined;
}
var stackId = barSettings.stackId;
if (stackId == null) {
return undefined;
}
var stackGroup = stackGroups[stackId];
if (!stackGroup) {
return undefined;
}
var stackedData = stackGroup.stackedData;
if (!stackedData) {
return undefined;
}
return stackedData.find(sd => sd.key === stackSeriesIdentifier);
};
exports.combineStackedData = combineStackedData;

View file

@ -0,0 +1,65 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.combineTooltipInteractionState = void 0;
var _tooltipSlice = require("../../tooltipSlice");
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
function chooseAppropriateMouseInteraction(tooltipState, tooltipEventType, trigger) {
if (tooltipEventType === 'axis') {
if (trigger === 'click') {
return tooltipState.axisInteraction.click;
}
return tooltipState.axisInteraction.hover;
}
if (trigger === 'click') {
return tooltipState.itemInteraction.click;
}
return tooltipState.itemInteraction.hover;
}
function hasBeenActivePreviously(tooltipInteractionState) {
return tooltipInteractionState.index != null;
}
var combineTooltipInteractionState = (tooltipState, tooltipEventType, trigger, defaultIndex) => {
if (tooltipEventType == null) {
return _tooltipSlice.noInteraction;
}
var appropriateMouseInteraction = chooseAppropriateMouseInteraction(tooltipState, tooltipEventType, trigger);
if (appropriateMouseInteraction == null) {
return _tooltipSlice.noInteraction;
}
if (appropriateMouseInteraction.active) {
return appropriateMouseInteraction;
}
if (tooltipState.keyboardInteraction.active) {
return tooltipState.keyboardInteraction;
}
if (tooltipState.syncInteraction.active && tooltipState.syncInteraction.index != null) {
return tooltipState.syncInteraction;
}
var activeFromProps = tooltipState.settings.active === true;
if (hasBeenActivePreviously(appropriateMouseInteraction)) {
if (activeFromProps) {
return _objectSpread(_objectSpread({}, appropriateMouseInteraction), {}, {
active: true
});
}
} else if (defaultIndex != null) {
return {
active: true,
coordinate: undefined,
dataKey: undefined,
index: defaultIndex,
graphicalItemId: undefined
};
}
return _objectSpread(_objectSpread({}, _tooltipSlice.noInteraction), {}, {
coordinate: appropriateMouseInteraction.coordinate
});
};
exports.combineTooltipInteractionState = combineTooltipInteractionState;

View file

@ -0,0 +1,162 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.combineTooltipPayload = void 0;
var _DataUtils = require("../../../util/DataUtils");
var _ChartUtils = require("../../../util/ChartUtils");
var _getSliced = require("../../../util/getSliced");
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
function parseName(value) {
if (typeof value === 'string' || typeof value === 'number') {
return value;
}
return undefined;
}
function parseUnit(value) {
if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
return value;
}
return undefined;
}
function parseDataKey(value) {
if (typeof value === 'string' || typeof value === 'number') {
return value;
}
if (typeof value === 'function') {
return obj => value(obj);
}
return undefined;
}
function parseColor(value) {
if (typeof value === 'string') {
return value;
}
return undefined;
}
function parseTooltipPayloadItem(item) {
if (item == null || typeof item !== 'object') {
return undefined;
}
var name = 'name' in item ? parseName(item.name) : undefined;
var unit = 'unit' in item ? parseUnit(item.unit) : undefined;
var dataKey = 'dataKey' in item ? parseDataKey(item.dataKey) : undefined;
var payload = 'payload' in item ? item.payload : undefined;
var color = 'color' in item ? parseColor(item.color) : undefined;
var fill = 'fill' in item ? parseColor(item.fill) : undefined;
return {
name,
unit,
dataKey,
payload,
color,
fill
};
}
function selectFinalData(dataDefinedOnItem, dataDefinedOnChart) {
/*
* If a payload has data specified directly from the graphical item, prefer that.
* Otherwise, fill in data from the chart level, using the same index.
*/
if (dataDefinedOnItem != null) {
return dataDefinedOnItem;
}
return dataDefinedOnChart;
}
var combineTooltipPayload = (tooltipPayloadConfigurations, activeIndex, chartDataState, tooltipAxisDataKey, activeLabel, tooltipPayloadSearcher, tooltipEventType) => {
if (activeIndex == null || tooltipPayloadSearcher == null) {
return undefined;
}
var chartData = chartDataState.chartData,
computedData = chartDataState.computedData,
dataStartIndex = chartDataState.dataStartIndex,
dataEndIndex = chartDataState.dataEndIndex;
var init = [];
return tooltipPayloadConfigurations.reduce((agg, _ref) => {
var _settings$dataKey;
var dataDefinedOnItem = _ref.dataDefinedOnItem,
settings = _ref.settings;
var finalData = selectFinalData(dataDefinedOnItem, chartData);
var sliced = Array.isArray(finalData) ? (0, _getSliced.getSliced)(finalData, dataStartIndex, dataEndIndex) : finalData;
var finalDataKey = (_settings$dataKey = settings === null || settings === void 0 ? void 0 : settings.dataKey) !== null && _settings$dataKey !== void 0 ? _settings$dataKey : tooltipAxisDataKey;
// BaseAxisProps does not support nameKey but it could!
var finalNameKey = settings === null || settings === void 0 ? void 0 : settings.nameKey; // ?? tooltipAxis?.nameKey;
var tooltipPayload;
if (tooltipAxisDataKey && Array.isArray(sliced) &&
/*
* findEntryInArray won't work for Scatter because Scatter provides an array of arrays
* as tooltip payloads and findEntryInArray is not prepared to handle that.
* Sad but also ScatterChart only allows 'item' tooltipEventType
* and also this is only a problem if there are multiple Scatters and each has its own data array
* so let's fix that some other time.
*/
!Array.isArray(sliced[0]) &&
/*
* If the tooltipEventType is 'axis', we should search for the dataKey in the sliced data
* because thanks to allowDuplicatedCategory=false, the order of elements in the array
* no longer matches the order of elements in the original data
* and so we need to search by the active dataKey + label rather than by index.
*
* The same happens if multiple graphical items are present in the chart
* and each of them has its own data array. Those arrays get concatenated
* and again the tooltip index no longer matches the original data.
*
* On the other hand the tooltipEventType 'item' should always search by index
* because we get the index from interacting over the individual elements
* which is always accurate, irrespective of the allowDuplicatedCategory setting.
*/
tooltipEventType === 'axis') {
tooltipPayload = (0, _DataUtils.findEntryInArray)(sliced, tooltipAxisDataKey, activeLabel);
} else {
/*
* This is a problem because it assumes that the index is pointing to the displayed data
* which it isn't because the index is pointing to the tooltip ticks array.
* The above approach (with findEntryInArray) is the correct one, but it only works
* if the axis dataKey is defined explicitly, and if the data is an array of objects.
*/
tooltipPayload = tooltipPayloadSearcher(sliced, activeIndex, computedData, finalNameKey);
}
if (Array.isArray(tooltipPayload)) {
tooltipPayload.forEach(item => {
var _parsedItem$color, _parsedItem$fill;
var parsedItem = parseTooltipPayloadItem(item);
var itemName = parsedItem === null || parsedItem === void 0 ? void 0 : parsedItem.name;
var itemDataKey = parsedItem === null || parsedItem === void 0 ? void 0 : parsedItem.dataKey;
var itemPayload = parsedItem === null || parsedItem === void 0 ? void 0 : parsedItem.payload;
var newSettings = _objectSpread(_objectSpread({}, settings), {}, {
name: itemName,
unit: parsedItem === null || parsedItem === void 0 ? void 0 : parsedItem.unit,
// Preserve item-level color/fill from graphical items.
color: (_parsedItem$color = parsedItem === null || parsedItem === void 0 ? void 0 : parsedItem.color) !== null && _parsedItem$color !== void 0 ? _parsedItem$color : settings === null || settings === void 0 ? void 0 : settings.color,
fill: (_parsedItem$fill = parsedItem === null || parsedItem === void 0 ? void 0 : parsedItem.fill) !== null && _parsedItem$fill !== void 0 ? _parsedItem$fill : settings === null || settings === void 0 ? void 0 : settings.fill
});
agg.push((0, _ChartUtils.getTooltipEntry)({
tooltipEntrySettings: newSettings,
dataKey: itemDataKey,
payload: itemPayload,
value: (0, _ChartUtils.getValueByDataKey)(itemPayload, itemDataKey),
name: itemName == null ? undefined : String(itemName)
}));
});
} else {
var _getValueByDataKey;
// I am not quite sure why these two branches (Array vs Array of Arrays) have to behave differently - I imagine we should unify these. 3.x breaking change?
agg.push((0, _ChartUtils.getTooltipEntry)({
tooltipEntrySettings: settings,
dataKey: finalDataKey,
payload: tooltipPayload,
// getValueByDataKey does not validate the output type
value: (0, _ChartUtils.getValueByDataKey)(tooltipPayload, finalDataKey),
// getValueByDataKey does not validate the output type
name: (_getValueByDataKey = (0, _ChartUtils.getValueByDataKey)(tooltipPayload, finalNameKey)) !== null && _getValueByDataKey !== void 0 ? _getValueByDataKey : settings === null || settings === void 0 ? void 0 : settings.name
}));
}
return agg;
}, init);
};
exports.combineTooltipPayload = combineTooltipPayload;

View file

@ -0,0 +1,52 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.combineTooltipPayloadConfigurations = void 0;
var combineTooltipPayloadConfigurations = (tooltipState, tooltipEventType, trigger, defaultIndex) => {
// if tooltip reacts to axis interaction, then we display all items at the same time.
if (tooltipEventType === 'axis') {
return tooltipState.tooltipItemPayloads;
}
/*
* By now we already know that tooltipEventType is 'item', so we can only search in itemInteractions.
* item means that only the hovered or clicked item will be present in the tooltip.
*/
if (tooltipState.tooltipItemPayloads.length === 0) {
// No point filtering if the payload is empty
return [];
}
var filterByGraphicalItemId;
if (trigger === 'hover') {
filterByGraphicalItemId = tooltipState.itemInteraction.hover.graphicalItemId;
} else {
filterByGraphicalItemId = tooltipState.itemInteraction.click.graphicalItemId;
}
if (tooltipState.syncInteraction.active && filterByGraphicalItemId == null) {
/*
* When a tooltip is synchronised from another chart, the local itemInteraction
* has no graphicalItemId because the user hasn't hovered over this chart.
* In that case we show all tooltip items so the receiving chart can display
* its own data at the synced index matching the behaviour of axis-type tooltips.
*/
return tooltipState.tooltipItemPayloads;
}
if (filterByGraphicalItemId == null && (defaultIndex != null || tooltipState.keyboardInteraction.active)) {
/*
* So when we use `defaultIndex` - we don't have a dataKey to filter by because user did not hover over anything yet.
* In that case let's display the first item in the tooltip; after all, this is `item` interaction case,
* so we should display only one item at a time instead of all.
*/
var firstItemPayload = tooltipState.tooltipItemPayloads[0];
if (firstItemPayload != null) {
return [firstItemPayload];
}
return [];
}
return tooltipState.tooltipItemPayloads.filter(tpc => {
var _tpc$settings;
return ((_tpc$settings = tpc.settings) === null || _tpc$settings === void 0 ? void 0 : _tpc$settings.graphicalItemId) === filterByGraphicalItemId;
});
};
exports.combineTooltipPayloadConfigurations = combineTooltipPayloadConfigurations;

View file

@ -0,0 +1,14 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.selectMargin = exports.selectContainerScale = exports.selectChartWidth = exports.selectChartHeight = void 0;
var selectChartWidth = state => state.layout.width;
exports.selectChartWidth = selectChartWidth;
var selectChartHeight = state => state.layout.height;
exports.selectChartHeight = selectChartHeight;
var selectContainerScale = state => state.layout.scale;
exports.selectContainerScale = selectContainerScale;
var selectMargin = state => state.layout.margin;
exports.selectMargin = selectMargin;

View file

@ -0,0 +1,87 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.selectChartDataWithIndexesIfNotInPanoramaPosition4 = exports.selectChartDataWithIndexesIfNotInPanoramaPosition3 = exports.selectChartDataWithIndexes = exports.selectChartDataSliceWithIndexes = exports.selectChartDataSliceIgnoringIndexes = exports.selectChartDataSliceIfNotInPanorama = exports.selectChartDataAndAlwaysIgnoreIndexes = void 0;
var _reselect = require("reselect");
/**
* This selector always returns the data with the indexes set by a Brush.
* Trouble is, that might or might not be what you want.
*
* In charts with Brush, you will sometimes want to select the full range of data, and sometimes the one decided by the Brush
* - even if the Brush is active, the panorama inside the Brush should show the full range of data.
*
* So instead of this selector, consider using either selectChartDataAndAlwaysIgnoreIndexes or selectChartDataWithIndexesIfNotInPanorama
*
* @param state RechartsRootState
* @returns data defined on the chart root element, such as BarChart or ScatterChart
*/
var selectChartDataWithIndexes = state => state.chartData;
/**
* This selector will always return the full range of data, ignoring the indexes set by a Brush.
* Useful for when you want to render the full range of data, even if a Brush is active.
* For example: in the Brush panorama, in Legend, in Tooltip.
*/
exports.selectChartDataWithIndexes = selectChartDataWithIndexes;
var selectChartDataAndAlwaysIgnoreIndexes = exports.selectChartDataAndAlwaysIgnoreIndexes = (0, _reselect.createSelector)([selectChartDataWithIndexes], dataState => {
var dataEndIndex = dataState.chartData != null ? dataState.chartData.length - 1 : 0;
return {
chartData: dataState.chartData,
computedData: dataState.computedData,
dataEndIndex,
dataStartIndex: 0
};
});
var selectChartDataWithIndexesIfNotInPanoramaPosition4 = (state, _unused1, _unused2, isPanorama) => {
if (isPanorama) {
return selectChartDataAndAlwaysIgnoreIndexes(state);
}
return selectChartDataWithIndexes(state);
};
exports.selectChartDataWithIndexesIfNotInPanoramaPosition4 = selectChartDataWithIndexesIfNotInPanoramaPosition4;
var selectChartDataWithIndexesIfNotInPanoramaPosition3 = (state, _unused1, isPanorama) => {
if (isPanorama) {
return selectChartDataAndAlwaysIgnoreIndexes(state);
}
return selectChartDataWithIndexes(state);
};
/**
* Returns the chart-level data slice (respecting Brush indexes), memoized by content so that
* spurious Immer reference changes (e.g. dispatching `setChartData(undefined)` when data is
* already `undefined`) do not propagate to downstream selectors.
*
* Used when a selector needs chart-level data but must avoid extra recomputes when the
* data content has not actually changed.
*/
exports.selectChartDataWithIndexesIfNotInPanoramaPosition3 = selectChartDataWithIndexesIfNotInPanoramaPosition3;
var selectChartDataSliceIfNotInPanorama = exports.selectChartDataSliceIfNotInPanorama = (0, _reselect.createSelector)([selectChartDataWithIndexesIfNotInPanoramaPosition4], _ref => {
var chartData = _ref.chartData,
dataStartIndex = _ref.dataStartIndex,
dataEndIndex = _ref.dataEndIndex;
return chartData != null ? chartData.slice(dataStartIndex, dataEndIndex + 1) : [];
});
/**
* Returns the chart-level data slice (ignoring Brush indexes), memoized by content.
* Used in tooltip and polar selectors that always need the full data range.
*/
var selectChartDataSliceIgnoringIndexes = exports.selectChartDataSliceIgnoringIndexes = (0, _reselect.createSelector)([selectChartDataAndAlwaysIgnoreIndexes], _ref2 => {
var chartData = _ref2.chartData,
dataStartIndex = _ref2.dataStartIndex,
dataEndIndex = _ref2.dataEndIndex;
return chartData != null ? chartData.slice(dataStartIndex, dataEndIndex + 1) : [];
});
/**
* Returns the chart-level data slice (with Brush indexes applied), memoized by content.
* Used in tooltip selectors.
*/
var selectChartDataSliceWithIndexes = exports.selectChartDataSliceWithIndexes = (0, _reselect.createSelector)([selectChartDataWithIndexes], _ref3 => {
var chartData = _ref3.chartData,
dataStartIndex = _ref3.dataStartIndex,
dataEndIndex = _ref3.dataEndIndex;
return chartData != null ? chartData.slice(dataStartIndex, dataEndIndex + 1) : [];
});

View file

@ -0,0 +1,55 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.selectFunnelTrapezoids = void 0;
var _reselect = require("reselect");
var _Funnel = require("../../cartesian/Funnel");
var _selectChartOffsetInternal = require("./selectChartOffsetInternal");
var _dataSelectors = require("./dataSelectors");
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
var pickFunnelSettings = (_state, funnelSettings) => funnelSettings;
var selectFunnelTrapezoids = exports.selectFunnelTrapezoids = (0, _reselect.createSelector)([_selectChartOffsetInternal.selectChartOffsetInternal, pickFunnelSettings, _dataSelectors.selectChartDataAndAlwaysIgnoreIndexes], (offset, _ref, _ref2) => {
var data = _ref.data,
dataKey = _ref.dataKey,
nameKey = _ref.nameKey,
tooltipType = _ref.tooltipType,
lastShapeType = _ref.lastShapeType,
reversed = _ref.reversed,
customWidth = _ref.customWidth,
cells = _ref.cells,
presentationProps = _ref.presentationProps,
graphicalItemId = _ref.id;
var chartData = _ref2.chartData;
var displayedData;
if (data != null && data.length > 0) {
displayedData = data;
} else if (chartData != null && chartData.length > 0) {
displayedData = chartData;
}
if (displayedData && displayedData.length) {
displayedData = displayedData.map((entry, index) => _objectSpread(_objectSpread(_objectSpread({
payload: entry
}, presentationProps), entry), cells && cells[index] && cells[index].props));
} else if (cells && cells.length) {
displayedData = cells.map(cell => _objectSpread(_objectSpread({}, presentationProps), cell.props));
} else {
return [];
}
return (0, _Funnel.computeFunnelTrapezoids)({
dataKey,
nameKey,
displayedData,
tooltipType,
lastShapeType,
reversed,
offset,
customWidth,
graphicalItemId
});
});

View file

@ -0,0 +1,16 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.selectXAxisIdFromGraphicalItemId = selectXAxisIdFromGraphicalItemId;
exports.selectYAxisIdFromGraphicalItemId = selectYAxisIdFromGraphicalItemId;
var _cartesianAxisSlice = require("../cartesianAxisSlice");
function selectXAxisIdFromGraphicalItemId(state, id) {
var _state$graphicalItems, _state$graphicalItems2;
return (_state$graphicalItems = (_state$graphicalItems2 = state.graphicalItems.cartesianItems.find(item => item.id === id)) === null || _state$graphicalItems2 === void 0 ? void 0 : _state$graphicalItems2.xAxisId) !== null && _state$graphicalItems !== void 0 ? _state$graphicalItems : _cartesianAxisSlice.defaultAxisId;
}
function selectYAxisIdFromGraphicalItemId(state, id) {
var _state$graphicalItems3, _state$graphicalItems4;
return (_state$graphicalItems3 = (_state$graphicalItems4 = state.graphicalItems.cartesianItems.find(item => item.id === id)) === null || _state$graphicalItems4 === void 0 ? void 0 : _state$graphicalItems4.yAxisId) !== null && _state$graphicalItems3 !== void 0 ? _state$graphicalItems3 : _cartesianAxisSlice.defaultAxisId;
}

View file

@ -0,0 +1,19 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.selectLegendSize = exports.selectLegendSettings = exports.selectLegendPayload = void 0;
var _reselect = require("reselect");
var _sortBy = _interopRequireDefault(require("es-toolkit/compat/sortBy"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
var selectLegendSettings = state => state.legend.settings;
exports.selectLegendSettings = selectLegendSettings;
var selectLegendSize = state => state.legend.size;
exports.selectLegendSize = selectLegendSize;
var selectAllLegendPayload2DArray = state => state.legend.payload;
var selectLegendPayload = exports.selectLegendPayload = (0, _reselect.createSelector)([selectAllLegendPayload2DArray, selectLegendSettings], (payloads, _ref) => {
var itemSorter = _ref.itemSorter;
var flat = payloads.flat(1);
return itemSorter ? (0, _sortBy.default)(flat, itemSorter) : flat;
});

View file

@ -0,0 +1,65 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.selectLinePoints = void 0;
var _reselect = require("reselect");
var _Line = require("../../cartesian/Line");
var _dataSelectors = require("./dataSelectors");
var _chartLayoutContext = require("../../context/chartLayoutContext");
var _axisSelectors = require("./axisSelectors");
var _ChartUtils = require("../../util/ChartUtils");
var selectXAxisWithScale = (state, xAxisId, _yAxisId, isPanorama) => (0, _axisSelectors.selectAxisWithScale)(state, 'xAxis', xAxisId, isPanorama);
var selectXAxisTicks = (state, xAxisId, _yAxisId, isPanorama) => (0, _axisSelectors.selectTicksOfGraphicalItem)(state, 'xAxis', xAxisId, isPanorama);
var selectYAxisWithScale = (state, _xAxisId, yAxisId, isPanorama) => (0, _axisSelectors.selectAxisWithScale)(state, 'yAxis', yAxisId, isPanorama);
var selectYAxisTicks = (state, _xAxisId, yAxisId, isPanorama) => (0, _axisSelectors.selectTicksOfGraphicalItem)(state, 'yAxis', yAxisId, isPanorama);
var selectBandSize = (0, _reselect.createSelector)([_chartLayoutContext.selectChartLayout, selectXAxisWithScale, selectYAxisWithScale, selectXAxisTicks, selectYAxisTicks], (layout, xAxis, yAxis, xAxisTicks, yAxisTicks) => {
if ((0, _ChartUtils.isCategoricalAxis)(layout, 'xAxis')) {
return (0, _ChartUtils.getBandSizeOfAxis)(xAxis, xAxisTicks, false);
}
return (0, _ChartUtils.getBandSizeOfAxis)(yAxis, yAxisTicks, false);
});
var pickLineId = (_state, _xAxisId, _yAxisId, _isPanorama, id) => id;
function isLineSettings(item) {
return item.type === 'line';
}
/*
* There is a race condition problem because we read some data from props and some from the state.
* The state is updated through a dispatch and is one render behind,
* and so we have this weird one tick render where the displayedData in one selector have the old dataKey
* but the new dataKey in another selector.
*
* So here instead of reading the dataKey from the props, we always read it from the state.
*/
var selectSynchronisedLineSettings = (0, _reselect.createSelector)([_axisSelectors.selectUnfilteredCartesianItems, pickLineId], (graphicalItems, id) => graphicalItems.filter(isLineSettings).find(x => x.id === id));
var selectLinePoints = exports.selectLinePoints = (0, _reselect.createSelector)([_chartLayoutContext.selectChartLayout, selectXAxisWithScale, selectYAxisWithScale, selectXAxisTicks, selectYAxisTicks, selectSynchronisedLineSettings, selectBandSize, _dataSelectors.selectChartDataWithIndexesIfNotInPanoramaPosition4], (layout, xAxis, yAxis, xAxisTicks, yAxisTicks, lineSettings, bandSize, _ref) => {
var chartData = _ref.chartData,
dataStartIndex = _ref.dataStartIndex,
dataEndIndex = _ref.dataEndIndex;
if (lineSettings == null || xAxis == null || yAxis == null || xAxisTicks == null || yAxisTicks == null || xAxisTicks.length === 0 || yAxisTicks.length === 0 || bandSize == null || layout !== 'horizontal' && layout !== 'vertical') {
return undefined;
}
var dataKey = lineSettings.dataKey,
data = lineSettings.data;
var displayedData;
if (data != null && data.length > 0) {
displayedData = data;
} else {
displayedData = chartData === null || chartData === void 0 ? void 0 : chartData.slice(dataStartIndex, dataEndIndex + 1);
}
if (displayedData == null) {
return undefined;
}
return (0, _Line.computeLinePoints)({
layout,
xAxis,
yAxis,
xAxisTicks,
yAxisTicks,
dataKey,
bandSize,
displayedData
});
});

View file

@ -0,0 +1,16 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.numberDomainEqualityCheck = void 0;
var numberDomainEqualityCheck = (a, b) => {
if (a === b) {
return true;
}
if (a == null || b == null) {
return false;
}
return a[0] === b[0] && a[1] === b[1];
};
exports.numberDomainEqualityCheck = numberDomainEqualityCheck;

View file

@ -0,0 +1,8 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.pickAxisId = void 0;
var pickAxisId = (_state, _axisType, axisId) => axisId;
exports.pickAxisId = pickAxisId;

View file

@ -0,0 +1,8 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.pickAxisType = void 0;
var pickAxisType = (_state, axisType) => axisType;
exports.pickAxisType = pickAxisType;

View file

@ -0,0 +1,83 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.selectPieSectors = exports.selectPieLegend = exports.selectDisplayedData = void 0;
var _reselect = require("reselect");
var _Pie = require("../../polar/Pie");
var _dataSelectors = require("./dataSelectors");
var _selectChartOffsetInternal = require("./selectChartOffsetInternal");
var _ChartUtils = require("../../util/ChartUtils");
var _polarSelectors = require("./polarSelectors");
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
var pickId = (_state, id) => id;
var selectSynchronisedPieSettings = (0, _reselect.createSelector)([_polarSelectors.selectUnfilteredPolarItems, pickId], (graphicalItems, id) => graphicalItems.filter(item => item.type === 'pie').find(item => item.id === id));
// Keep stable reference to an empty array to prevent re-renders
var emptyArray = [];
var pickCells = (_state, _id, cells) => {
if ((cells === null || cells === void 0 ? void 0 : cells.length) === 0) {
return emptyArray;
}
return cells;
};
var selectDisplayedData = exports.selectDisplayedData = (0, _reselect.createSelector)([_dataSelectors.selectChartDataAndAlwaysIgnoreIndexes, selectSynchronisedPieSettings, pickCells], (_ref, pieSettings, cells) => {
var chartData = _ref.chartData;
if (pieSettings == null) {
return undefined;
}
var displayedData;
if ((pieSettings === null || pieSettings === void 0 ? void 0 : pieSettings.data) != null && pieSettings.data.length > 0) {
displayedData = pieSettings.data;
} else {
displayedData = chartData;
}
if ((!displayedData || !displayedData.length) && cells != null) {
displayedData = cells.map(cell => _objectSpread(_objectSpread({}, pieSettings.presentationProps), cell.props));
}
if (displayedData == null) {
return undefined;
}
return displayedData;
});
var selectPieLegend = exports.selectPieLegend = (0, _reselect.createSelector)([selectDisplayedData, selectSynchronisedPieSettings, pickCells], (displayedData, pieSettings, cells) => {
if (displayedData == null || pieSettings == null) {
return undefined;
}
return displayedData.map((entry, i) => {
var _cells$i;
var name = (0, _ChartUtils.getValueByDataKey)(entry, pieSettings.nameKey, pieSettings.name);
var color;
if (cells !== null && cells !== void 0 && (_cells$i = cells[i]) !== null && _cells$i !== void 0 && (_cells$i = _cells$i.props) !== null && _cells$i !== void 0 && _cells$i.fill) {
color = cells[i].props.fill;
} else if (typeof entry === 'object' && entry != null && 'fill' in entry) {
color = entry.fill;
} else {
color = pieSettings.fill;
}
return {
value: (0, _ChartUtils.getTooltipNameProp)(name, pieSettings.dataKey),
dataKey: pieSettings.dataKey,
color,
// @ts-expect-error Legend payload.payload says it wants objects but our data can be unknown
payload: entry,
type: pieSettings.legendType
};
});
});
var selectPieSectors = exports.selectPieSectors = (0, _reselect.createSelector)([selectDisplayedData, selectSynchronisedPieSettings, pickCells, _selectChartOffsetInternal.selectChartOffsetInternal], (displayedData, pieSettings, cells, offset) => {
if (pieSettings == null || displayedData == null) {
return undefined;
}
return (0, _Pie.computePieSectors)({
offset,
pieSettings,
displayedData,
cells
});
});

View file

@ -0,0 +1,137 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.selectRadiusAxisRangeWithReversed = exports.selectRadiusAxisRange = exports.selectRadiusAxis = exports.selectPolarViewBox = exports.selectPolarOptions = exports.selectOuterRadius = exports.selectMaxRadius = exports.selectAngleAxisRangeWithReversed = exports.selectAngleAxisRange = exports.selectAngleAxis = exports.implicitRadiusAxis = exports.implicitAngleAxis = void 0;
var _reselect = require("reselect");
var _containerSelectors = require("./containerSelectors");
var _selectChartOffsetInternal = require("./selectChartOffsetInternal");
var _PolarUtils = require("../../util/PolarUtils");
var _DataUtils = require("../../util/DataUtils");
var _defaultPolarAngleAxisProps = require("../../polar/defaultPolarAngleAxisProps");
var _defaultPolarRadiusAxisProps = require("../../polar/defaultPolarRadiusAxisProps");
var _combineAxisRangeWithReverse = require("./combiners/combineAxisRangeWithReverse");
var _chartLayoutContext = require("../../context/chartLayoutContext");
var _getAxisTypeBasedOnLayout = require("../../util/getAxisTypeBasedOnLayout");
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
var implicitAngleAxis = exports.implicitAngleAxis = {
allowDataOverflow: _defaultPolarAngleAxisProps.defaultPolarAngleAxisProps.allowDataOverflow,
allowDecimals: _defaultPolarAngleAxisProps.defaultPolarAngleAxisProps.allowDecimals,
allowDuplicatedCategory: false,
// defaultPolarAngleAxisProps.allowDuplicatedCategory has it set to true but the actual axis rendering ignores the prop because reasons,
dataKey: undefined,
domain: undefined,
id: _defaultPolarAngleAxisProps.defaultPolarAngleAxisProps.angleAxisId,
includeHidden: false,
name: undefined,
reversed: _defaultPolarAngleAxisProps.defaultPolarAngleAxisProps.reversed,
scale: _defaultPolarAngleAxisProps.defaultPolarAngleAxisProps.scale,
tick: _defaultPolarAngleAxisProps.defaultPolarAngleAxisProps.tick,
tickCount: undefined,
ticks: undefined,
type: _defaultPolarAngleAxisProps.defaultPolarAngleAxisProps.type,
unit: undefined,
niceTicks: 'auto'
};
var implicitRadiusAxis = exports.implicitRadiusAxis = {
allowDataOverflow: _defaultPolarRadiusAxisProps.defaultPolarRadiusAxisProps.allowDataOverflow,
allowDecimals: _defaultPolarRadiusAxisProps.defaultPolarRadiusAxisProps.allowDecimals,
allowDuplicatedCategory: _defaultPolarRadiusAxisProps.defaultPolarRadiusAxisProps.allowDuplicatedCategory,
dataKey: undefined,
domain: undefined,
id: _defaultPolarRadiusAxisProps.defaultPolarRadiusAxisProps.radiusAxisId,
includeHidden: _defaultPolarRadiusAxisProps.defaultPolarRadiusAxisProps.includeHidden,
name: undefined,
reversed: _defaultPolarRadiusAxisProps.defaultPolarRadiusAxisProps.reversed,
scale: _defaultPolarRadiusAxisProps.defaultPolarRadiusAxisProps.scale,
tick: _defaultPolarRadiusAxisProps.defaultPolarRadiusAxisProps.tick,
tickCount: _defaultPolarRadiusAxisProps.defaultPolarRadiusAxisProps.tickCount,
ticks: undefined,
type: _defaultPolarRadiusAxisProps.defaultPolarRadiusAxisProps.type,
unit: undefined,
niceTicks: 'auto'
};
var selectAngleAxisNoDefaults = (state, angleAxisId) => {
if (angleAxisId == null) {
return undefined;
}
return state.polarAxis.angleAxis[angleAxisId];
};
var selectAngleAxis = exports.selectAngleAxis = (0, _reselect.createSelector)([selectAngleAxisNoDefaults, _chartLayoutContext.selectPolarChartLayout], (angleAxisSettings, layout) => {
var _getAxisTypeBasedOnLa;
if (angleAxisSettings != null) {
return angleAxisSettings;
}
var evaluatedType = (_getAxisTypeBasedOnLa = (0, _getAxisTypeBasedOnLayout.getAxisTypeBasedOnLayout)(layout, 'angleAxis', implicitAngleAxis.type)) !== null && _getAxisTypeBasedOnLa !== void 0 ? _getAxisTypeBasedOnLa : 'category';
return _objectSpread(_objectSpread({}, implicitAngleAxis), {}, {
type: evaluatedType
});
});
var selectRadiusAxisNoDefaults = (state, radiusAxisId) => {
return state.polarAxis.radiusAxis[radiusAxisId];
};
var selectRadiusAxis = exports.selectRadiusAxis = (0, _reselect.createSelector)([selectRadiusAxisNoDefaults, _chartLayoutContext.selectPolarChartLayout], (radiusAxisSettings, layout) => {
var _getAxisTypeBasedOnLa2;
if (radiusAxisSettings != null) {
return radiusAxisSettings;
}
var evaluatedType = (_getAxisTypeBasedOnLa2 = (0, _getAxisTypeBasedOnLayout.getAxisTypeBasedOnLayout)(layout, 'radiusAxis', implicitRadiusAxis.type)) !== null && _getAxisTypeBasedOnLa2 !== void 0 ? _getAxisTypeBasedOnLa2 : 'category';
return _objectSpread(_objectSpread({}, implicitRadiusAxis), {}, {
type: evaluatedType
});
});
var selectPolarOptions = state => state.polarOptions;
exports.selectPolarOptions = selectPolarOptions;
var selectMaxRadius = exports.selectMaxRadius = (0, _reselect.createSelector)([_containerSelectors.selectChartWidth, _containerSelectors.selectChartHeight, _selectChartOffsetInternal.selectChartOffsetInternal], _PolarUtils.getMaxRadius);
var selectInnerRadius = (0, _reselect.createSelector)([selectPolarOptions, selectMaxRadius], (polarChartOptions, maxRadius) => {
if (polarChartOptions == null) {
return undefined;
}
return (0, _DataUtils.getPercentValue)(polarChartOptions.innerRadius, maxRadius, 0);
});
var selectOuterRadius = exports.selectOuterRadius = (0, _reselect.createSelector)([selectPolarOptions, selectMaxRadius], (polarChartOptions, maxRadius) => {
if (polarChartOptions == null) {
return undefined;
}
return (0, _DataUtils.getPercentValue)(polarChartOptions.outerRadius, maxRadius, maxRadius * 0.8);
});
var combineAngleAxisRange = polarOptions => {
if (polarOptions == null) {
return [0, 0];
}
var startAngle = polarOptions.startAngle,
endAngle = polarOptions.endAngle;
return [startAngle, endAngle];
};
var selectAngleAxisRange = exports.selectAngleAxisRange = (0, _reselect.createSelector)([selectPolarOptions], combineAngleAxisRange);
var selectAngleAxisRangeWithReversed = exports.selectAngleAxisRangeWithReversed = (0, _reselect.createSelector)([selectAngleAxis, selectAngleAxisRange], _combineAxisRangeWithReverse.combineAxisRangeWithReverse);
var selectRadiusAxisRange = exports.selectRadiusAxisRange = (0, _reselect.createSelector)([selectMaxRadius, selectInnerRadius, selectOuterRadius], (maxRadius, innerRadius, outerRadius) => {
if (maxRadius == null || innerRadius == null || outerRadius == null) {
return undefined;
}
return [innerRadius, outerRadius];
});
var selectRadiusAxisRangeWithReversed = exports.selectRadiusAxisRangeWithReversed = (0, _reselect.createSelector)([selectRadiusAxis, selectRadiusAxisRange], _combineAxisRangeWithReverse.combineAxisRangeWithReverse);
var selectPolarViewBox = exports.selectPolarViewBox = (0, _reselect.createSelector)([_chartLayoutContext.selectChartLayout, selectPolarOptions, selectInnerRadius, selectOuterRadius, _containerSelectors.selectChartWidth, _containerSelectors.selectChartHeight], (layout, polarOptions, innerRadius, outerRadius, width, height) => {
if (layout !== 'centric' && layout !== 'radial' || polarOptions == null || innerRadius == null || outerRadius == null) {
return undefined;
}
var cx = polarOptions.cx,
cy = polarOptions.cy,
startAngle = polarOptions.startAngle,
endAngle = polarOptions.endAngle;
return {
cx: (0, _DataUtils.getPercentValue)(cx, width, width / 2),
cy: (0, _DataUtils.getPercentValue)(cy, height, height / 2),
innerRadius,
outerRadius,
startAngle,
endAngle,
clockWise: false // this property look useful, why not use it?
};
});

View file

@ -0,0 +1,22 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.selectPolarGridRadii = exports.selectPolarGridAngles = void 0;
var _reselect = require("reselect");
var _polarScaleSelectors = require("./polarScaleSelectors");
var selectAngleAxisTicks = (state, anglexisId) => (0, _polarScaleSelectors.selectPolarAxisTicks)(state, 'angleAxis', anglexisId, false);
var selectPolarGridAngles = exports.selectPolarGridAngles = (0, _reselect.createSelector)([selectAngleAxisTicks], ticks => {
if (!ticks) {
return undefined;
}
return ticks.map(tick => tick.coordinate);
});
var selectRadiusAxisTicks = (state, radiusAxisId) => (0, _polarScaleSelectors.selectPolarAxisTicks)(state, 'radiusAxis', radiusAxisId, false);
var selectPolarGridRadii = exports.selectPolarGridRadii = (0, _reselect.createSelector)([selectRadiusAxisTicks], ticks => {
if (!ticks) {
return undefined;
}
return ticks.map(tick => tick.coordinate);
});

View file

@ -0,0 +1,69 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.selectPolarGraphicalItemAxisTicks = exports.selectPolarCategoricalDomain = exports.selectPolarAxisTicks = exports.selectPolarAxisScale = exports.selectPolarAxis = exports.selectPolarAngleAxisTicks = void 0;
var _reselect = require("reselect");
var _axisSelectors = require("./axisSelectors");
var _polarAxisSelectors = require("./polarAxisSelectors");
var _chartLayoutContext = require("../../context/chartLayoutContext");
var _polarSelectors = require("./polarSelectors");
var _pickAxisType = require("./pickAxisType");
var _RechartsScale = require("../../util/scale/RechartsScale");
var _combineConfiguredScale = require("./combiners/combineConfiguredScale");
var selectPolarAxis = (state, axisType, axisId) => {
switch (axisType) {
case 'angleAxis':
{
return (0, _polarAxisSelectors.selectAngleAxis)(state, axisId);
}
case 'radiusAxis':
{
return (0, _polarAxisSelectors.selectRadiusAxis)(state, axisId);
}
default:
{
throw new Error("Unexpected axis type: ".concat(axisType));
}
}
};
exports.selectPolarAxis = selectPolarAxis;
var selectPolarAxisRangeWithReversed = (state, axisType, axisId) => {
switch (axisType) {
case 'angleAxis':
{
return (0, _polarAxisSelectors.selectAngleAxisRangeWithReversed)(state, axisId);
}
case 'radiusAxis':
{
return (0, _polarAxisSelectors.selectRadiusAxisRangeWithReversed)(state, axisId);
}
default:
{
throw new Error("Unexpected axis type: ".concat(axisType));
}
}
};
var selectPolarConfiguredScale = (0, _reselect.createSelector)([selectPolarAxis, _axisSelectors.selectRealScaleType, _polarSelectors.selectPolarAxisCheckedDomain, selectPolarAxisRangeWithReversed], _combineConfiguredScale.combineConfiguredScale);
var selectPolarAxisScale = exports.selectPolarAxisScale = (0, _reselect.createSelector)([selectPolarConfiguredScale], _RechartsScale.rechartsScaleFactory);
var selectPolarCategoricalDomain = exports.selectPolarCategoricalDomain = (0, _reselect.createSelector)([_chartLayoutContext.selectChartLayout, _polarSelectors.selectPolarAppliedValues, _axisSelectors.selectRenderableAxisSettings, _pickAxisType.pickAxisType], _axisSelectors.combineCategoricalDomain);
var selectPolarAxisTicks = exports.selectPolarAxisTicks = (0, _reselect.createSelector)([_chartLayoutContext.selectChartLayout, selectPolarAxis, _axisSelectors.selectRealScaleType, selectPolarAxisScale, _polarSelectors.selectPolarNiceTicks, selectPolarAxisRangeWithReversed, _axisSelectors.selectDuplicateDomain, selectPolarCategoricalDomain, _pickAxisType.pickAxisType], _axisSelectors.combineAxisTicks);
var selectPolarAngleAxisTicks = exports.selectPolarAngleAxisTicks = (0, _reselect.createSelector)([selectPolarAxisTicks], ticks => {
/*
* Angle axis is circular; so here we need to look for ticks that overlap (i.e., 0 and 360 degrees)
* and remove the duplicate tick to avoid rendering issues.
*/
if (!ticks) {
return undefined;
}
var uniqueTicksMap = new Map();
ticks.forEach(tick => {
var normalizedCoordinate = (tick.coordinate + 360) % 360;
if (!uniqueTicksMap.has(normalizedCoordinate)) {
uniqueTicksMap.set(normalizedCoordinate, tick);
}
});
return Array.from(uniqueTicksMap.values());
});
var selectPolarGraphicalItemAxisTicks = exports.selectPolarGraphicalItemAxisTicks = (0, _reselect.createSelector)([_chartLayoutContext.selectChartLayout, selectPolarAxis, selectPolarAxisScale, selectPolarAxisRangeWithReversed, _axisSelectors.selectDuplicateDomain, selectPolarCategoricalDomain, _pickAxisType.pickAxisType], _axisSelectors.combineGraphicalItemTicks);

View file

@ -0,0 +1,53 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.selectUnfilteredPolarItems = exports.selectPolarNiceTicks = exports.selectPolarItemsSettings = exports.selectPolarDisplayedData = exports.selectPolarAxisDomainIncludingNiceTicks = exports.selectPolarAxisDomain = exports.selectPolarAxisCheckedDomain = exports.selectPolarAppliedValues = exports.selectAllPolarAppliedNumericalValues = void 0;
var _reselect = require("reselect");
var _dataSelectors = require("./dataSelectors");
var _axisSelectors = require("./axisSelectors");
var _chartLayoutContext = require("../../context/chartLayoutContext");
var _ChartUtils = require("../../util/ChartUtils");
var _pickAxisType = require("./pickAxisType");
var _pickAxisId = require("./pickAxisId");
var _rootPropsSelectors = require("./rootPropsSelectors");
var _combineCheckedDomain = require("./combiners/combineCheckedDomain");
var selectUnfilteredPolarItems = state => state.graphicalItems.polarItems;
exports.selectUnfilteredPolarItems = selectUnfilteredPolarItems;
var selectAxisPredicate = (0, _reselect.createSelector)([_pickAxisType.pickAxisType, _pickAxisId.pickAxisId], _axisSelectors.itemAxisPredicate);
var selectPolarItemsSettings = exports.selectPolarItemsSettings = (0, _reselect.createSelector)([selectUnfilteredPolarItems, _axisSelectors.selectBaseAxis, selectAxisPredicate], _axisSelectors.combineGraphicalItemsSettings);
var selectPolarGraphicalItemsData = (0, _reselect.createSelector)([selectPolarItemsSettings], _axisSelectors.combineGraphicalItemsData);
var selectPolarDisplayedData = exports.selectPolarDisplayedData = (0, _reselect.createSelector)([selectPolarGraphicalItemsData, _dataSelectors.selectChartDataAndAlwaysIgnoreIndexes], _axisSelectors.combineDisplayedData);
var selectPolarAppliedValues = exports.selectPolarAppliedValues = (0, _reselect.createSelector)([selectPolarDisplayedData, _axisSelectors.selectBaseAxis, selectPolarItemsSettings], _axisSelectors.combineAppliedValues);
var selectAllPolarAppliedNumericalValues = exports.selectAllPolarAppliedNumericalValues = (0, _reselect.createSelector)([selectPolarDisplayedData, _axisSelectors.selectBaseAxis, selectPolarItemsSettings], (data, axisSettings, items) => {
if (items.length > 0) {
return data.flatMap(entry => {
return items.flatMap(item => {
var _axisSettings$dataKey;
var valueByDataKey = (0, _ChartUtils.getValueByDataKey)(entry, (_axisSettings$dataKey = axisSettings.dataKey) !== null && _axisSettings$dataKey !== void 0 ? _axisSettings$dataKey : item.dataKey);
return {
value: valueByDataKey,
errorDomain: [] // polar charts do not have error bars
};
});
}).filter(Boolean);
}
if ((axisSettings === null || axisSettings === void 0 ? void 0 : axisSettings.dataKey) != null) {
return data.map(item => ({
value: (0, _ChartUtils.getValueByDataKey)(item, axisSettings.dataKey),
errorDomain: []
}));
}
return data.map(entry => ({
value: entry,
errorDomain: []
}));
});
var unsupportedInPolarChart = () => undefined;
var selectDomainOfAllPolarAppliedNumericalValues = (0, _reselect.createSelector)([selectPolarDisplayedData, _axisSelectors.selectBaseAxis, selectPolarItemsSettings, _axisSelectors.selectAllErrorBarSettings, _pickAxisType.pickAxisType, _dataSelectors.selectChartDataSliceIgnoringIndexes], _axisSelectors.combineDomainOfAllAppliedNumericalValuesIncludingErrorValues);
var selectPolarNumericalDomain = (0, _reselect.createSelector)([_axisSelectors.selectBaseAxis, _axisSelectors.selectDomainDefinition, _axisSelectors.selectDomainFromUserPreference, unsupportedInPolarChart, selectDomainOfAllPolarAppliedNumericalValues, unsupportedInPolarChart, _chartLayoutContext.selectChartLayout, _pickAxisType.pickAxisType], _axisSelectors.combineNumericalDomain);
var selectPolarAxisDomain = exports.selectPolarAxisDomain = (0, _reselect.createSelector)([_axisSelectors.selectBaseAxis, _chartLayoutContext.selectChartLayout, selectPolarDisplayedData, selectPolarAppliedValues, _rootPropsSelectors.selectStackOffsetType, _pickAxisType.pickAxisType, selectPolarNumericalDomain], _axisSelectors.combineAxisDomain);
var selectPolarNiceTicks = exports.selectPolarNiceTicks = (0, _reselect.createSelector)([selectPolarAxisDomain, _axisSelectors.selectRenderableAxisSettings, _axisSelectors.selectRealScaleType], _axisSelectors.combineNiceTicks);
var selectPolarAxisDomainIncludingNiceTicks = exports.selectPolarAxisDomainIncludingNiceTicks = (0, _reselect.createSelector)([_axisSelectors.selectBaseAxis, selectPolarAxisDomain, selectPolarNiceTicks, _pickAxisType.pickAxisType], _axisSelectors.combineAxisDomainWithNiceTicks);
var selectPolarAxisCheckedDomain = exports.selectPolarAxisCheckedDomain = (0, _reselect.createSelector)([_axisSelectors.selectRealScaleType, selectPolarAxisDomainIncludingNiceTicks], _combineCheckedDomain.combineCheckedDomain);

View file

@ -0,0 +1,96 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.selectRadiusAxisForBandSize = exports.selectRadarPoints = exports.selectAngleAxisWithScaleAndViewport = exports.selectAngleAxisForBandSize = void 0;
var _reselect = require("reselect");
var _Radar = require("../../polar/Radar");
var _polarScaleSelectors = require("./polarScaleSelectors");
var _polarAxisSelectors = require("./polarAxisSelectors");
var _dataSelectors = require("./dataSelectors");
var _chartLayoutContext = require("../../context/chartLayoutContext");
var _ChartUtils = require("../../util/ChartUtils");
var _polarSelectors = require("./polarSelectors");
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
var selectRadiusAxisScale = (state, radiusAxisId) => (0, _polarScaleSelectors.selectPolarAxisScale)(state, 'radiusAxis', radiusAxisId);
var selectRadiusAxisForRadar = (0, _reselect.createSelector)([selectRadiusAxisScale], scale => {
if (scale == null) {
return undefined;
}
return {
scale
};
});
var selectRadiusAxisForBandSize = exports.selectRadiusAxisForBandSize = (0, _reselect.createSelector)([_polarAxisSelectors.selectRadiusAxis, selectRadiusAxisScale], (axisSettings, scale) => {
if (axisSettings == null || scale == null) {
return undefined;
}
return _objectSpread(_objectSpread({}, axisSettings), {}, {
scale
});
});
var selectRadiusAxisTicks = (state, radiusAxisId, _angleAxisId, isPanorama) => {
return (0, _polarScaleSelectors.selectPolarAxisTicks)(state, 'radiusAxis', radiusAxisId, isPanorama);
};
var selectAngleAxisForRadar = (state, _radiusAxisId, angleAxisId) => (0, _polarAxisSelectors.selectAngleAxis)(state, angleAxisId);
var selectPolarAxisScaleForRadar = (state, _radiusAxisId, angleAxisId) => (0, _polarScaleSelectors.selectPolarAxisScale)(state, 'angleAxis', angleAxisId);
var selectAngleAxisForBandSize = exports.selectAngleAxisForBandSize = (0, _reselect.createSelector)([selectAngleAxisForRadar, selectPolarAxisScaleForRadar], (axisSettings, scale) => {
if (axisSettings == null || scale == null) {
return undefined;
}
return _objectSpread(_objectSpread({}, axisSettings), {}, {
scale
});
});
var selectAngleAxisTicks = (state, _radiusAxisId, angleAxisId, isPanorama) => {
return (0, _polarScaleSelectors.selectPolarAxisTicks)(state, 'angleAxis', angleAxisId, isPanorama);
};
var selectAngleAxisWithScaleAndViewport = exports.selectAngleAxisWithScaleAndViewport = (0, _reselect.createSelector)([selectAngleAxisForRadar, selectPolarAxisScaleForRadar, _polarAxisSelectors.selectPolarViewBox], (axisOptions, scale, polarViewBox) => {
if (polarViewBox == null || scale == null) {
return undefined;
}
return {
scale,
type: axisOptions.type,
dataKey: axisOptions.dataKey,
cx: polarViewBox.cx,
cy: polarViewBox.cy
};
});
var pickId = (_state, _radiusAxisId, _angleAxisId, _isPanorama, radarId) => radarId;
var selectBandSizeOfAxis = (0, _reselect.createSelector)([_chartLayoutContext.selectChartLayout, selectRadiusAxisForBandSize, selectRadiusAxisTicks, selectAngleAxisForBandSize, selectAngleAxisTicks], (layout, radiusAxis, radiusAxisTicks, angleAxis, angleAxisTicks) => {
if ((0, _ChartUtils.isCategoricalAxis)(layout, 'radiusAxis')) {
return (0, _ChartUtils.getBandSizeOfAxis)(radiusAxis, radiusAxisTicks, false);
}
return (0, _ChartUtils.getBandSizeOfAxis)(angleAxis, angleAxisTicks, false);
});
var selectSynchronisedRadarDataKey = (0, _reselect.createSelector)([_polarSelectors.selectUnfilteredPolarItems, pickId], (graphicalItems, radarId) => {
if (graphicalItems == null) {
return undefined;
}
// Find the radar item with the given radarId
var pgis = graphicalItems.find(item => item.type === 'radar' && radarId === item.id);
// If found, return its dataKey
return pgis === null || pgis === void 0 ? void 0 : pgis.dataKey;
});
var selectRadarPoints = exports.selectRadarPoints = (0, _reselect.createSelector)([selectRadiusAxisForRadar, selectAngleAxisWithScaleAndViewport, _dataSelectors.selectChartDataAndAlwaysIgnoreIndexes, selectSynchronisedRadarDataKey, selectBandSizeOfAxis], (radiusAxis, angleAxis, _ref, dataKey, bandSize) => {
var chartData = _ref.chartData,
dataStartIndex = _ref.dataStartIndex,
dataEndIndex = _ref.dataEndIndex;
if (radiusAxis == null || angleAxis == null || chartData == null || bandSize == null || dataKey == null) {
return undefined;
}
var displayedData = chartData.slice(dataStartIndex, dataEndIndex + 1);
return (0, _Radar.computeRadarPoints)({
radiusAxis,
angleAxis,
displayedData,
dataKey,
bandSize
});
});

View file

@ -0,0 +1,183 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.selectRadiusAxisWithScale = exports.selectRadiusAxisTicks = exports.selectRadialBarSectors = exports.selectRadialBarLegendPayload = exports.selectPolarBarSizeList = exports.selectPolarBarPosition = exports.selectPolarBarBandSize = exports.selectBaseValue = exports.selectBandSizeOfPolarAxis = exports.selectAngleAxisWithScale = exports.selectAllPolarBarPositions = exports.pickMaxBarSize = void 0;
var _reselect = require("reselect");
var _RadialBar = require("../../polar/RadialBar");
var _dataSelectors = require("./dataSelectors");
var _polarScaleSelectors = require("./polarScaleSelectors");
var _axisSelectors = require("./axisSelectors");
var _polarAxisSelectors = require("./polarAxisSelectors");
var _chartLayoutContext = require("../../context/chartLayoutContext");
var _ChartUtils = require("../../util/ChartUtils");
var _rootPropsSelectors = require("./rootPropsSelectors");
var _polarSelectors = require("./polarSelectors");
var _DataUtils = require("../../util/DataUtils");
var _combineDisplayedStackedData = require("./combiners/combineDisplayedStackedData");
var _StackedGraphicalItem = require("../types/StackedGraphicalItem");
var _combineBarSizeList = require("./combiners/combineBarSizeList");
var _combineAllBarPositions = require("./combiners/combineAllBarPositions");
var _combineStackedData = require("./combiners/combineStackedData");
var _combineBarPosition = require("./combiners/combineBarPosition");
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
var selectRadiusAxisForRadialBar = (state, radiusAxisId) => (0, _polarAxisSelectors.selectRadiusAxis)(state, radiusAxisId);
var selectRadiusAxisScaleForRadar = (state, radiusAxisId) => (0, _polarScaleSelectors.selectPolarAxisScale)(state, 'radiusAxis', radiusAxisId);
var selectRadiusAxisWithScale = exports.selectRadiusAxisWithScale = (0, _reselect.createSelector)([selectRadiusAxisForRadialBar, selectRadiusAxisScaleForRadar], (axis, scale) => {
if (axis == null || scale == null) {
return undefined;
}
return _objectSpread(_objectSpread({}, axis), {}, {
scale
});
});
var selectRadiusAxisTicks = (state, radiusAxisId) => {
return (0, _polarScaleSelectors.selectPolarGraphicalItemAxisTicks)(state, 'radiusAxis', radiusAxisId, false);
};
exports.selectRadiusAxisTicks = selectRadiusAxisTicks;
var selectAngleAxisForRadialBar = (state, _radiusAxisId, angleAxisId) => (0, _polarAxisSelectors.selectAngleAxis)(state, angleAxisId);
var selectAngleAxisScaleForRadialBar = (state, _radiusAxisId, angleAxisId) => (0, _polarScaleSelectors.selectPolarAxisScale)(state, 'angleAxis', angleAxisId);
var selectAngleAxisWithScale = exports.selectAngleAxisWithScale = (0, _reselect.createSelector)([selectAngleAxisForRadialBar, selectAngleAxisScaleForRadialBar], (axis, scale) => {
if (axis == null || scale == null) {
return undefined;
}
return _objectSpread(_objectSpread({}, axis), {}, {
scale
});
});
var selectAngleAxisTicks = (state, _radiusAxisId, angleAxisId) => {
// here we can hardcode isPanorama to false because radialBar does not support panorama mode
return (0, _polarScaleSelectors.selectPolarAxisTicks)(state, 'angleAxis', angleAxisId, false);
};
var pickRadialBarSettings = (_state, _radiusAxisId, _angleAxisId, radialBarSettings) => radialBarSettings;
var selectSynchronisedRadialBarSettings = (0, _reselect.createSelector)([_polarSelectors.selectUnfilteredPolarItems, pickRadialBarSettings], (graphicalItems, radialBarSettingsFromProps) => {
if (graphicalItems.some(pgis => pgis.type === 'radialBar' && radialBarSettingsFromProps.dataKey === pgis.dataKey && radialBarSettingsFromProps.stackId === pgis.stackId)) {
return radialBarSettingsFromProps;
}
return undefined;
});
var selectBandSizeOfPolarAxis = exports.selectBandSizeOfPolarAxis = (0, _reselect.createSelector)([_chartLayoutContext.selectChartLayout, selectRadiusAxisWithScale, selectRadiusAxisTicks, selectAngleAxisWithScale, selectAngleAxisTicks], (layout, radiusAxis, radiusAxisTicks, angleAxis, angleAxisTicks) => {
if ((0, _ChartUtils.isCategoricalAxis)(layout, 'radiusAxis')) {
return (0, _ChartUtils.getBandSizeOfAxis)(radiusAxis, radiusAxisTicks, false);
}
return (0, _ChartUtils.getBandSizeOfAxis)(angleAxis, angleAxisTicks, false);
});
var selectBaseValue = exports.selectBaseValue = (0, _reselect.createSelector)([selectAngleAxisWithScale, selectRadiusAxisWithScale, _chartLayoutContext.selectChartLayout], (angleAxis, radiusAxis, layout) => {
var numericAxis = layout === 'radial' ? angleAxis : radiusAxis;
if (numericAxis == null || numericAxis.scale == null) {
return undefined;
}
return (0, _ChartUtils.getBaseValueOfBar)({
numericAxis
});
});
var pickCells = (_state, _radiusAxisId, _angleAxisId, _radialBarSettings, cells) => cells;
var pickAngleAxisId = (_state, _radiusAxisId, angleAxisId, _radialBarSettings, _cells) => angleAxisId;
var pickRadiusAxisId = (_state, radiusAxisId, _angleAxisId, _radialBarSettings, _cells) => radiusAxisId;
var pickMaxBarSize = (_state, _radiusAxisId, _angleAxisId, radialBarSettings, _cells) => radialBarSettings.maxBarSize;
exports.pickMaxBarSize = pickMaxBarSize;
var isRadialBar = item => item.type === 'radialBar';
var selectAllVisibleRadialBars = (0, _reselect.createSelector)([_chartLayoutContext.selectChartLayout, _polarSelectors.selectUnfilteredPolarItems, pickAngleAxisId, pickRadiusAxisId], (layout, allItems, angleAxisId, radiusAxisId) => {
return allItems.filter(i => {
if (layout === 'centric') {
return i.angleAxisId === angleAxisId;
}
return i.radiusAxisId === radiusAxisId;
}).filter(i => i.hide === false).filter(isRadialBar);
});
/**
* The generator never returned the totalSize which means that barSize in polar chart can not support percent values.
* We can add that if we want to I suppose.
* @returns undefined - but it should be a total size of numerical axis in polar chart
*/
var selectPolarBarAxisSize = () => undefined;
var selectPolarBarSizeList = exports.selectPolarBarSizeList = (0, _reselect.createSelector)([selectAllVisibleRadialBars, _rootPropsSelectors.selectRootBarSize, selectPolarBarAxisSize], _combineBarSizeList.combineBarSizeList);
var selectPolarBarBandSize = exports.selectPolarBarBandSize = (0, _reselect.createSelector)([_chartLayoutContext.selectChartLayout, _rootPropsSelectors.selectRootMaxBarSize, selectAngleAxisWithScale, selectAngleAxisTicks, selectRadiusAxisWithScale, selectRadiusAxisTicks, pickMaxBarSize], (layout, globalMaxBarSize, angleAxis, angleAxisTicks, radiusAxis, radiusAxisTicks, childMaxBarSize) => {
var _ref2, _getBandSizeOfAxis2;
var maxBarSize = (0, _DataUtils.isNullish)(childMaxBarSize) ? globalMaxBarSize : childMaxBarSize;
if (layout === 'centric') {
var _ref, _getBandSizeOfAxis;
return (_ref = (_getBandSizeOfAxis = (0, _ChartUtils.getBandSizeOfAxis)(angleAxis, angleAxisTicks, true)) !== null && _getBandSizeOfAxis !== void 0 ? _getBandSizeOfAxis : maxBarSize) !== null && _ref !== void 0 ? _ref : 0;
}
return (_ref2 = (_getBandSizeOfAxis2 = (0, _ChartUtils.getBandSizeOfAxis)(radiusAxis, radiusAxisTicks, true)) !== null && _getBandSizeOfAxis2 !== void 0 ? _getBandSizeOfAxis2 : maxBarSize) !== null && _ref2 !== void 0 ? _ref2 : 0;
});
var selectAllPolarBarPositions = exports.selectAllPolarBarPositions = (0, _reselect.createSelector)([selectPolarBarSizeList, _rootPropsSelectors.selectRootMaxBarSize, _rootPropsSelectors.selectBarGap, _rootPropsSelectors.selectBarCategoryGap, selectPolarBarBandSize, selectBandSizeOfPolarAxis, pickMaxBarSize], _combineAllBarPositions.combineAllBarPositions);
var selectPolarBarPosition = exports.selectPolarBarPosition = (0, _reselect.createSelector)([selectAllPolarBarPositions, selectSynchronisedRadialBarSettings], _combineBarPosition.combineBarPosition);
var selectStackedRadialBars = (0, _reselect.createSelector)([_polarSelectors.selectPolarItemsSettings], allPolarItems => allPolarItems.filter(isRadialBar).filter(_StackedGraphicalItem.isStacked));
var selectPolarCombinedStackedData = (0, _reselect.createSelector)([selectStackedRadialBars, _dataSelectors.selectChartDataAndAlwaysIgnoreIndexes, _axisSelectors.selectTooltipAxis], _combineDisplayedStackedData.combineDisplayedStackedData);
var selectStackGroups = (0, _reselect.createSelector)([selectPolarCombinedStackedData, selectStackedRadialBars, _rootPropsSelectors.selectStackOffsetType, _rootPropsSelectors.selectReverseStackOrder], _axisSelectors.combineStackGroups);
var selectRadialBarStackGroups = (state, radiusAxisId, angleAxisId) => {
var layout = (0, _chartLayoutContext.selectChartLayout)(state);
if (layout === 'centric') {
return selectStackGroups(state, 'radiusAxis', radiusAxisId);
}
return selectStackGroups(state, 'angleAxis', angleAxisId);
};
var selectPolarStackedData = (0, _reselect.createSelector)([selectRadialBarStackGroups, selectSynchronisedRadialBarSettings], _combineStackedData.combineStackedData);
var selectRadialBarSectors = exports.selectRadialBarSectors = (0, _reselect.createSelector)([selectAngleAxisWithScale, selectAngleAxisTicks, selectRadiusAxisWithScale, selectRadiusAxisTicks, _dataSelectors.selectChartDataWithIndexes, selectSynchronisedRadialBarSettings, selectBandSizeOfPolarAxis, _chartLayoutContext.selectChartLayout, selectBaseValue, _polarAxisSelectors.selectPolarViewBox, pickCells, selectPolarBarPosition, selectPolarStackedData], (angleAxis, angleAxisTicks, radiusAxis, radiusAxisTicks, _ref3, radialBarSettings, bandSize, layout, baseValue, polarViewBox, cells, pos, stackedData) => {
var chartData = _ref3.chartData,
dataStartIndex = _ref3.dataStartIndex,
dataEndIndex = _ref3.dataEndIndex;
if (radialBarSettings == null || radiusAxis == null || angleAxis == null || chartData == null || bandSize == null || pos == null || layout !== 'centric' && layout !== 'radial' || radiusAxisTicks == null || polarViewBox == null) {
return [];
}
var dataKey = radialBarSettings.dataKey,
minPointSize = radialBarSettings.minPointSize;
var cx = polarViewBox.cx,
cy = polarViewBox.cy,
startAngle = polarViewBox.startAngle,
endAngle = polarViewBox.endAngle;
var displayedData = chartData.slice(dataStartIndex, dataEndIndex + 1);
var numericAxis = layout === 'centric' ? radiusAxis : angleAxis;
var stackedDomain = stackedData ? numericAxis.scale.domain() : null;
return (0, _RadialBar.computeRadialBarDataItems)({
angleAxis,
angleAxisTicks,
bandSize,
baseValue,
cells,
cx,
cy,
dataKey,
dataStartIndex,
displayedData,
endAngle,
layout,
minPointSize,
pos,
radiusAxis,
radiusAxisTicks,
stackedData,
stackedDomain,
startAngle
});
});
var selectRadialBarLegendPayload = exports.selectRadialBarLegendPayload = (0, _reselect.createSelector)([_dataSelectors.selectChartDataAndAlwaysIgnoreIndexes, (_s, l) => l], (_ref4, legendType) => {
var chartData = _ref4.chartData,
dataStartIndex = _ref4.dataStartIndex,
dataEndIndex = _ref4.dataEndIndex;
if (chartData == null) {
return [];
}
var displayedData = chartData.slice(dataStartIndex, dataEndIndex + 1);
if (displayedData.length === 0) {
return [];
}
return displayedData.map(entry => {
return {
type: legendType,
// @ts-expect-error we need a better typing for our data inputs
value: entry.name,
// @ts-expect-error we need a better typing for our data inputs
color: entry.fill,
// @ts-expect-error Legend payload.payload says it wants objects but our data can be unknown
payload: entry
};
});
});

View file

@ -0,0 +1,28 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.selectSyncMethod = exports.selectSyncId = exports.selectStackOffsetType = exports.selectRootMaxBarSize = exports.selectRootBarSize = exports.selectReverseStackOrder = exports.selectEventEmitter = exports.selectChartName = exports.selectChartBaseValue = exports.selectBarGap = exports.selectBarCategoryGap = void 0;
var selectRootMaxBarSize = state => state.rootProps.maxBarSize;
exports.selectRootMaxBarSize = selectRootMaxBarSize;
var selectBarGap = state => state.rootProps.barGap;
exports.selectBarGap = selectBarGap;
var selectBarCategoryGap = state => state.rootProps.barCategoryGap;
exports.selectBarCategoryGap = selectBarCategoryGap;
var selectRootBarSize = state => state.rootProps.barSize;
exports.selectRootBarSize = selectRootBarSize;
var selectStackOffsetType = state => state.rootProps.stackOffset;
exports.selectStackOffsetType = selectStackOffsetType;
var selectReverseStackOrder = state => state.rootProps.reverseStackOrder;
exports.selectReverseStackOrder = selectReverseStackOrder;
var selectChartName = state => state.options.chartName;
exports.selectChartName = selectChartName;
var selectSyncId = state => state.rootProps.syncId;
exports.selectSyncId = selectSyncId;
var selectSyncMethod = state => state.rootProps.syncMethod;
exports.selectSyncMethod = selectSyncMethod;
var selectEventEmitter = state => state.options.eventEmitter;
exports.selectEventEmitter = selectEventEmitter;
var selectChartBaseValue = state => state.rootProps.baseValue;
exports.selectChartBaseValue = selectChartBaseValue;

View file

@ -0,0 +1,48 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.selectScatterPoints = void 0;
var _reselect = require("reselect");
var _Scatter = require("../../cartesian/Scatter");
var _dataSelectors = require("./dataSelectors");
var _axisSelectors = require("./axisSelectors");
var selectXAxisWithScale = (state, xAxisId, _yAxisId, _zAxisId, _id, _cells, isPanorama) => (0, _axisSelectors.selectAxisWithScale)(state, 'xAxis', xAxisId, isPanorama);
var selectXAxisTicks = (state, xAxisId, _yAxisId, _zAxisId, _id, _cells, isPanorama) => (0, _axisSelectors.selectTicksOfGraphicalItem)(state, 'xAxis', xAxisId, isPanorama);
var selectYAxisWithScale = (state, _xAxisId, yAxisId, _zAxisId, _id, _cells, isPanorama) => (0, _axisSelectors.selectAxisWithScale)(state, 'yAxis', yAxisId, isPanorama);
var selectYAxisTicks = (state, _xAxisId, yAxisId, _zAxisId, _id, _cells, isPanorama) => (0, _axisSelectors.selectTicksOfGraphicalItem)(state, 'yAxis', yAxisId, isPanorama);
var selectZAxis = (state, _xAxisId, _yAxisId, zAxisId) => (0, _axisSelectors.selectZAxisWithScale)(state, 'zAxis', zAxisId, false);
var pickScatterId = (_state, _xAxisId, _yAxisId, _zAxisId, id) => id;
var pickCells = (_state, _xAxisId, _yAxisId, _zAxisId, _id, cells) => cells;
var scatterChartDataSelector = (state, _xAxisId, _yAxisId, _zAxisId, _id, _cells, isPanorama) => (0, _dataSelectors.selectChartDataWithIndexesIfNotInPanoramaPosition4)(state, undefined, undefined, isPanorama);
var selectSynchronisedScatterSettings = (0, _reselect.createSelector)([_axisSelectors.selectUnfilteredCartesianItems, pickScatterId], (graphicalItems, id) => {
return graphicalItems.filter(item => item.type === 'scatter').find(item => item.id === id);
});
var selectScatterPoints = exports.selectScatterPoints = (0, _reselect.createSelector)([scatterChartDataSelector, selectXAxisWithScale, selectXAxisTicks, selectYAxisWithScale, selectYAxisTicks, selectZAxis, selectSynchronisedScatterSettings, pickCells], (_ref, xAxis, xAxisTicks, yAxis, yAxisTicks, zAxis, scatterSettings, cells) => {
var chartData = _ref.chartData,
dataStartIndex = _ref.dataStartIndex,
dataEndIndex = _ref.dataEndIndex;
if (scatterSettings == null) {
return undefined;
}
var displayedData;
if ((scatterSettings === null || scatterSettings === void 0 ? void 0 : scatterSettings.data) != null && scatterSettings.data.length > 0) {
displayedData = scatterSettings.data;
} else {
displayedData = chartData === null || chartData === void 0 ? void 0 : chartData.slice(dataStartIndex, dataEndIndex + 1);
}
if (displayedData == null || xAxis == null || yAxis == null || xAxisTicks == null || yAxisTicks == null || (xAxisTicks === null || xAxisTicks === void 0 ? void 0 : xAxisTicks.length) === 0 || (yAxisTicks === null || yAxisTicks === void 0 ? void 0 : yAxisTicks.length) === 0) {
return undefined;
}
return (0, _Scatter.computeScatterPoints)({
displayedData,
xAxis,
yAxis,
zAxis,
scatterSettings,
xAxisTicks,
yAxisTicks,
cells
});
});

View file

@ -0,0 +1,15 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.selectActivePropsFromChartPointer = void 0;
var _reselect = require("reselect");
var _chartLayoutContext = require("../../context/chartLayoutContext");
var _tooltipSelectors = require("./tooltipSelectors");
var _selectChartOffsetInternal = require("./selectChartOffsetInternal");
var _selectors = require("./selectors");
var _polarAxisSelectors = require("./polarAxisSelectors");
var _selectTooltipAxisType = require("./selectTooltipAxisType");
var pickChartPointer = (_state, chartPointer) => chartPointer;
var selectActivePropsFromChartPointer = exports.selectActivePropsFromChartPointer = (0, _reselect.createSelector)([pickChartPointer, _chartLayoutContext.selectChartLayout, _polarAxisSelectors.selectPolarViewBox, _selectTooltipAxisType.selectTooltipAxisType, _tooltipSelectors.selectTooltipAxisRangeWithReverse, _tooltipSelectors.selectTooltipAxisTicks, _selectors.selectOrderedTooltipTicks, _selectChartOffsetInternal.selectChartOffsetInternal], _selectors.combineActiveProps);

View file

@ -0,0 +1,13 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.selectAllYAxes = exports.selectAllXAxes = void 0;
var _reselect = require("reselect");
var selectAllXAxes = exports.selectAllXAxes = (0, _reselect.createSelector)(state => state.cartesianAxis.xAxis, xAxisMap => {
return Object.values(xAxisMap);
});
var selectAllYAxes = exports.selectAllYAxes = (0, _reselect.createSelector)(state => state.cartesianAxis.yAxis, yAxisMap => {
return Object.values(yAxisMap);
});

View file

@ -0,0 +1,16 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.selectChartOffset = void 0;
var _reselect = require("reselect");
var _selectChartOffsetInternal = require("./selectChartOffsetInternal");
var selectChartOffset = exports.selectChartOffset = (0, _reselect.createSelector)([_selectChartOffsetInternal.selectChartOffsetInternal], offsetInternal => {
return {
top: offsetInternal.top,
bottom: offsetInternal.bottom,
left: offsetInternal.left,
right: offsetInternal.right
};
});

View file

@ -0,0 +1,99 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.selectChartViewBox = exports.selectChartOffsetInternal = exports.selectBrushHeight = exports.selectAxisViewBox = void 0;
var _reselect = require("reselect");
var _legendSelectors = require("./legendSelectors");
var _ChartUtils = require("../../util/ChartUtils");
var _containerSelectors = require("./containerSelectors");
var _selectAllAxes = require("./selectAllAxes");
var _Constants = require("../../util/Constants");
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
var selectBrushHeight = state => state.brush.height;
exports.selectBrushHeight = selectBrushHeight;
function selectLeftAxesOffset(state) {
var yAxes = (0, _selectAllAxes.selectAllYAxes)(state);
return yAxes.reduce((result, entry) => {
if (entry.orientation === 'left' && !entry.mirror && !entry.hide) {
var width = typeof entry.width === 'number' ? entry.width : _Constants.DEFAULT_Y_AXIS_WIDTH;
return result + width;
}
return result;
}, 0);
}
function selectRightAxesOffset(state) {
var yAxes = (0, _selectAllAxes.selectAllYAxes)(state);
return yAxes.reduce((result, entry) => {
if (entry.orientation === 'right' && !entry.mirror && !entry.hide) {
var width = typeof entry.width === 'number' ? entry.width : _Constants.DEFAULT_Y_AXIS_WIDTH;
return result + width;
}
return result;
}, 0);
}
function selectTopAxesOffset(state) {
var xAxes = (0, _selectAllAxes.selectAllXAxes)(state);
return xAxes.reduce((result, entry) => {
if (entry.orientation === 'top' && !entry.mirror && !entry.hide) {
return result + entry.height;
}
return result;
}, 0);
}
function selectBottomAxesOffset(state) {
var xAxes = (0, _selectAllAxes.selectAllXAxes)(state);
return xAxes.reduce((result, entry) => {
if (entry.orientation === 'bottom' && !entry.mirror && !entry.hide) {
return result + entry.height;
}
return result;
}, 0);
}
/**
* For internal use only.
*
* @param root state
* @return ChartOffsetInternal
*/
var selectChartOffsetInternal = exports.selectChartOffsetInternal = (0, _reselect.createSelector)([_containerSelectors.selectChartWidth, _containerSelectors.selectChartHeight, _containerSelectors.selectMargin, selectBrushHeight, selectLeftAxesOffset, selectRightAxesOffset, selectTopAxesOffset, selectBottomAxesOffset, _legendSelectors.selectLegendSettings, _legendSelectors.selectLegendSize], (chartWidth, chartHeight, margin, brushHeight, leftAxesOffset, rightAxesOffset, topAxesOffset, bottomAxesOffset, legendSettings, legendSize) => {
var offsetH = {
left: (margin.left || 0) + leftAxesOffset,
right: (margin.right || 0) + rightAxesOffset
};
var offsetV = {
top: (margin.top || 0) + topAxesOffset,
bottom: (margin.bottom || 0) + bottomAxesOffset
};
var offset = _objectSpread(_objectSpread({}, offsetV), offsetH);
var brushBottom = offset.bottom;
offset.bottom += brushHeight;
offset = (0, _ChartUtils.appendOffsetOfLegend)(offset, legendSettings, legendSize);
var offsetWidth = chartWidth - offset.left - offset.right;
var offsetHeight = chartHeight - offset.top - offset.bottom;
return _objectSpread(_objectSpread({
brushBottom
}, offset), {}, {
// never return negative values for height and width
width: Math.max(offsetWidth, 0),
height: Math.max(offsetHeight, 0)
});
});
var selectChartViewBox = exports.selectChartViewBox = (0, _reselect.createSelector)(selectChartOffsetInternal, offset => ({
x: offset.left,
y: offset.top,
width: offset.width,
height: offset.height
}));
var selectAxisViewBox = exports.selectAxisViewBox = (0, _reselect.createSelector)(_containerSelectors.selectChartWidth, _containerSelectors.selectChartHeight, (width, height) => ({
x: 0,
y: 0,
width,
height
}));

View file

@ -0,0 +1,20 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.selectPlotArea = void 0;
var _reselect = require("reselect");
var _selectChartOffset = require("./selectChartOffset");
var _containerSelectors = require("./containerSelectors");
var selectPlotArea = exports.selectPlotArea = (0, _reselect.createSelector)([_selectChartOffset.selectChartOffset, _containerSelectors.selectChartWidth, _containerSelectors.selectChartHeight], (offset, chartWidth, chartHeight) => {
if (!offset || chartWidth == null || chartHeight == null) {
return undefined;
}
return {
x: offset.left,
y: offset.top,
width: Math.max(0, chartWidth - offset.left - offset.right),
height: Math.max(0, chartHeight - offset.top - offset.bottom)
};
});

View file

@ -0,0 +1,8 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.selectTooltipAxisId = void 0;
var selectTooltipAxisId = state => state.tooltip.settings.axisId;
exports.selectTooltipAxisId = selectTooltipAxisId;

View file

@ -0,0 +1,29 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.selectTooltipAxisType = void 0;
var _chartLayoutContext = require("../../context/chartLayoutContext");
/**
* angle, radius, X, Y, and Z axes all have domain and range and scale and associated settings
*/
/**
* Z axis is never displayed and so it lacks ticks and tick settings.
*/
var selectTooltipAxisType = state => {
var layout = (0, _chartLayoutContext.selectChartLayout)(state);
if (layout === 'horizontal') {
return 'xAxis';
}
if (layout === 'vertical') {
return 'yAxis';
}
if (layout === 'centric') {
return 'angleAxis';
}
return 'radiusAxis';
};
exports.selectTooltipAxisType = selectTooltipAxisType;

View file

@ -0,0 +1,33 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.combineTooltipEventType = combineTooltipEventType;
exports.selectDefaultTooltipEventType = void 0;
exports.selectTooltipEventType = selectTooltipEventType;
exports.selectValidateTooltipEventTypes = void 0;
exports.useTooltipEventType = useTooltipEventType;
var _hooks = require("../hooks");
var selectDefaultTooltipEventType = state => state.options.defaultTooltipEventType;
exports.selectDefaultTooltipEventType = selectDefaultTooltipEventType;
var selectValidateTooltipEventTypes = state => state.options.validateTooltipEventTypes;
exports.selectValidateTooltipEventTypes = selectValidateTooltipEventTypes;
function combineTooltipEventType(shared, defaultTooltipEventType, validateTooltipEventTypes) {
if (shared == null) {
return defaultTooltipEventType;
}
var eventType = shared ? 'axis' : 'item';
if (validateTooltipEventTypes == null) {
return defaultTooltipEventType;
}
return validateTooltipEventTypes.includes(eventType) ? eventType : defaultTooltipEventType;
}
function selectTooltipEventType(state, shared) {
var defaultTooltipEventType = selectDefaultTooltipEventType(state);
var validateTooltipEventTypes = selectValidateTooltipEventTypes(state);
return combineTooltipEventType(shared, defaultTooltipEventType, validateTooltipEventTypes);
}
function useTooltipEventType(shared) {
return (0, _hooks.useAppSelector)(state => selectTooltipEventType(state, shared));
}

View file

@ -0,0 +1,8 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.selectTooltipPayloadSearcher = void 0;
var selectTooltipPayloadSearcher = state => state.options.tooltipPayloadSearcher;
exports.selectTooltipPayloadSearcher = selectTooltipPayloadSearcher;

View file

@ -0,0 +1,8 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.selectTooltipSettings = void 0;
var selectTooltipSettings = state => state.tooltip.settings;
exports.selectTooltipSettings = selectTooltipSettings;

View file

@ -0,0 +1,8 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.selectTooltipState = void 0;
var selectTooltipState = state => state.tooltip;
exports.selectTooltipState = selectTooltipState;

View file

@ -0,0 +1,110 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.useChartName = exports.selectTooltipPayloadConfigurations = exports.selectTooltipPayload = exports.selectTooltipInteractionState = exports.selectTooltipDataKey = exports.selectOrderedTooltipTicks = exports.selectIsTooltipActive = exports.selectCoordinateForDefaultIndex = exports.selectActiveLabel = exports.selectActiveIndex = exports.selectActiveCoordinate = exports.combineActiveProps = void 0;
var _reselect = require("reselect");
var _sortBy = _interopRequireDefault(require("es-toolkit/compat/sortBy"));
var _hooks = require("../hooks");
var _ChartUtils = require("../../util/ChartUtils");
var _dataSelectors = require("./dataSelectors");
var _tooltipSelectors = require("./tooltipSelectors");
var _axisSelectors = require("./axisSelectors");
var _rootPropsSelectors = require("./rootPropsSelectors");
var _chartLayoutContext = require("../../context/chartLayoutContext");
var _selectChartOffsetInternal = require("./selectChartOffsetInternal");
var _containerSelectors = require("./containerSelectors");
var _combineActiveLabel = require("./combiners/combineActiveLabel");
var _combineTooltipInteractionState = require("./combiners/combineTooltipInteractionState");
var _combineActiveTooltipIndex = require("./combiners/combineActiveTooltipIndex");
var _combineCoordinateForDefaultIndex = require("./combiners/combineCoordinateForDefaultIndex");
var _combineTooltipPayloadConfigurations = require("./combiners/combineTooltipPayloadConfigurations");
var _selectTooltipPayloadSearcher = require("./selectTooltipPayloadSearcher");
var _selectTooltipState = require("./selectTooltipState");
var _combineTooltipPayload = require("./combiners/combineTooltipPayload");
var _getActiveCoordinate = require("../../util/getActiveCoordinate");
var _PolarUtils = require("../../util/PolarUtils");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
var useChartName = () => {
return (0, _hooks.useAppSelector)(_rootPropsSelectors.selectChartName);
};
exports.useChartName = useChartName;
var pickTooltipEventType = (_state, tooltipEventType) => tooltipEventType;
var pickTrigger = (_state, _tooltipEventType, trigger) => trigger;
var pickDefaultIndex = (_state, _tooltipEventType, _trigger, defaultIndex) => defaultIndex;
var selectOrderedTooltipTicks = exports.selectOrderedTooltipTicks = (0, _reselect.createSelector)(_tooltipSelectors.selectTooltipAxisTicks, ticks => (0, _sortBy.default)(ticks, o => o.coordinate));
var selectTooltipInteractionState = exports.selectTooltipInteractionState = (0, _reselect.createSelector)([_selectTooltipState.selectTooltipState, pickTooltipEventType, pickTrigger, pickDefaultIndex], _combineTooltipInteractionState.combineTooltipInteractionState);
var selectActiveIndex = exports.selectActiveIndex = (0, _reselect.createSelector)([selectTooltipInteractionState, _tooltipSelectors.selectTooltipDisplayedData, _axisSelectors.selectTooltipAxisDataKey, _tooltipSelectors.selectTooltipAxisDomain], _combineActiveTooltipIndex.combineActiveTooltipIndex);
var selectTooltipDataKey = (state, tooltipEventType, trigger) => {
if (tooltipEventType == null) {
return undefined;
}
var tooltipState = (0, _selectTooltipState.selectTooltipState)(state);
if (tooltipEventType === 'axis') {
if (trigger === 'hover') {
return tooltipState.axisInteraction.hover.dataKey;
}
return tooltipState.axisInteraction.click.dataKey;
}
if (trigger === 'hover') {
return tooltipState.itemInteraction.hover.dataKey;
}
return tooltipState.itemInteraction.click.dataKey;
};
exports.selectTooltipDataKey = selectTooltipDataKey;
var selectTooltipPayloadConfigurations = exports.selectTooltipPayloadConfigurations = (0, _reselect.createSelector)([_selectTooltipState.selectTooltipState, pickTooltipEventType, pickTrigger, pickDefaultIndex], _combineTooltipPayloadConfigurations.combineTooltipPayloadConfigurations);
var selectCoordinateForDefaultIndex = exports.selectCoordinateForDefaultIndex = (0, _reselect.createSelector)([_containerSelectors.selectChartWidth, _containerSelectors.selectChartHeight, _chartLayoutContext.selectChartLayout, _selectChartOffsetInternal.selectChartOffsetInternal, _tooltipSelectors.selectTooltipAxisTicks, pickDefaultIndex, selectTooltipPayloadConfigurations], _combineCoordinateForDefaultIndex.combineCoordinateForDefaultIndex);
var selectActiveCoordinate = exports.selectActiveCoordinate = (0, _reselect.createSelector)([selectTooltipInteractionState, selectCoordinateForDefaultIndex], (tooltipInteractionState, defaultIndexCoordinate) => {
var _tooltipInteractionSt;
return (_tooltipInteractionSt = tooltipInteractionState.coordinate) !== null && _tooltipInteractionSt !== void 0 ? _tooltipInteractionSt : defaultIndexCoordinate;
});
var selectActiveLabel = exports.selectActiveLabel = (0, _reselect.createSelector)([_tooltipSelectors.selectTooltipAxisTicks, selectActiveIndex], _combineActiveLabel.combineActiveLabel);
var selectTooltipPayload = exports.selectTooltipPayload = (0, _reselect.createSelector)([selectTooltipPayloadConfigurations, selectActiveIndex, _dataSelectors.selectChartDataWithIndexes, _axisSelectors.selectTooltipAxisDataKey, selectActiveLabel, _selectTooltipPayloadSearcher.selectTooltipPayloadSearcher, pickTooltipEventType], _combineTooltipPayload.combineTooltipPayload);
var selectIsTooltipActive = exports.selectIsTooltipActive = (0, _reselect.createSelector)([selectTooltipInteractionState, selectActiveIndex], (tooltipInteractionState, activeIndex) => {
return {
isActive: tooltipInteractionState.active && activeIndex != null,
activeIndex
};
});
var combineActiveCartesianProps = (chartEvent, layout, tooltipAxisType, tooltipAxisRange, tooltipTicks, orderedTooltipTicks, offset) => {
if (!chartEvent || !tooltipAxisType || !tooltipAxisRange || !tooltipTicks) {
return undefined;
}
if (!(0, _getActiveCoordinate.isInCartesianRange)(chartEvent, offset)) {
return undefined;
}
var pos = (0, _ChartUtils.calculateCartesianTooltipPos)(chartEvent, layout);
var activeIndex = (0, _getActiveCoordinate.calculateActiveTickIndex)(pos, orderedTooltipTicks, tooltipTicks, tooltipAxisType, tooltipAxisRange);
var activeCoordinate = (0, _getActiveCoordinate.getActiveCartesianCoordinate)(layout, tooltipTicks, activeIndex, chartEvent);
return {
activeIndex: String(activeIndex),
activeCoordinate
};
};
var combineActivePolarProps = (chartEvent, layout, polarViewBox, tooltipAxisType, tooltipAxisRange, tooltipTicks, orderedTooltipTicks) => {
if (!chartEvent || !tooltipAxisType || !tooltipAxisRange || !tooltipTicks || !polarViewBox) {
return undefined;
}
var rangeObj = (0, _PolarUtils.inRangeOfSector)(chartEvent, polarViewBox);
if (!rangeObj) {
return undefined;
}
var pos = (0, _ChartUtils.calculatePolarTooltipPos)(rangeObj, layout);
var activeIndex = (0, _getActiveCoordinate.calculateActiveTickIndex)(pos, orderedTooltipTicks, tooltipTicks, tooltipAxisType, tooltipAxisRange);
var activeCoordinate = (0, _getActiveCoordinate.getActivePolarCoordinate)(layout, tooltipTicks, activeIndex, rangeObj);
return {
activeIndex: String(activeIndex),
activeCoordinate
};
};
var combineActiveProps = (chartEvent, layout, polarViewBox, tooltipAxisType, tooltipAxisRange, tooltipTicks, orderedTooltipTicks, offset) => {
if (!chartEvent || !layout || !tooltipAxisType || !tooltipAxisRange || !tooltipTicks) {
return undefined;
}
if (layout === 'horizontal' || layout === 'vertical') {
return combineActiveCartesianProps(chartEvent, layout, tooltipAxisType, tooltipAxisRange, tooltipTicks, orderedTooltipTicks, offset);
}
return combineActivePolarProps(chartEvent, layout, polarViewBox, tooltipAxisType, tooltipAxisRange, tooltipTicks, orderedTooltipTicks);
};
exports.combineActiveProps = combineActiveProps;

View file

@ -0,0 +1,188 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.selectTooltipGraphicalItemsData = exports.selectTooltipDisplayedData = exports.selectTooltipCategoricalDomain = exports.selectTooltipAxisTicks = exports.selectTooltipAxisScale = exports.selectTooltipAxisRealScaleType = exports.selectTooltipAxisRangeWithReverse = exports.selectTooltipAxisDomainIncludingNiceTicks = exports.selectTooltipAxisDomain = exports.selectIsTooltipActive = exports.selectAllUnfilteredGraphicalItems = exports.selectAllGraphicalItemsSettings = exports.selectActiveTooltipPayload = exports.selectActiveTooltipIndex = exports.selectActiveTooltipGraphicalItemId = exports.selectActiveTooltipDataPoints = exports.selectActiveTooltipDataKey = exports.selectActiveTooltipCoordinate = exports.selectActiveLabel = void 0;
var _reselect = require("reselect");
var _axisSelectors = require("./axisSelectors");
var _chartLayoutContext = require("../../context/chartLayoutContext");
var _ChartUtils = require("../../util/ChartUtils");
var _dataSelectors = require("./dataSelectors");
var _rootPropsSelectors = require("./rootPropsSelectors");
var _DataUtils = require("../../util/DataUtils");
var _combineAxisRangeWithReverse = require("./combiners/combineAxisRangeWithReverse");
var _selectTooltipEventType = require("./selectTooltipEventType");
var _combineActiveLabel = require("./combiners/combineActiveLabel");
var _selectTooltipSettings = require("./selectTooltipSettings");
var _combineTooltipInteractionState = require("./combiners/combineTooltipInteractionState");
var _combineActiveTooltipIndex = require("./combiners/combineActiveTooltipIndex");
var _combineCoordinateForDefaultIndex = require("./combiners/combineCoordinateForDefaultIndex");
var _containerSelectors = require("./containerSelectors");
var _selectChartOffsetInternal = require("./selectChartOffsetInternal");
var _combineTooltipPayloadConfigurations = require("./combiners/combineTooltipPayloadConfigurations");
var _selectTooltipPayloadSearcher = require("./selectTooltipPayloadSearcher");
var _selectTooltipState = require("./selectTooltipState");
var _combineTooltipPayload = require("./combiners/combineTooltipPayload");
var _selectTooltipAxisId = require("./selectTooltipAxisId");
var _selectTooltipAxisType = require("./selectTooltipAxisType");
var _combineDisplayedStackedData = require("./combiners/combineDisplayedStackedData");
var _StackedGraphicalItem = require("../types/StackedGraphicalItem");
var _isDomainSpecifiedByUser = require("../../util/isDomainSpecifiedByUser");
var _numberDomainEqualityCheck = require("./numberDomainEqualityCheck");
var _arrayEqualityCheck = require("./arrayEqualityCheck");
var _RechartsScale = require("../../util/scale/RechartsScale");
var _isWellBehavedNumber = require("../../util/isWellBehavedNumber");
var _combineRealScaleType = require("./combiners/combineRealScaleType");
var _combineConfiguredScale = require("./combiners/combineConfiguredScale");
var selectTooltipAxisRealScaleType = exports.selectTooltipAxisRealScaleType = (0, _reselect.createSelector)([_axisSelectors.selectTooltipAxis, _axisSelectors.selectHasBar, _rootPropsSelectors.selectChartName], _combineRealScaleType.combineRealScaleType);
var selectAllUnfilteredGraphicalItems = exports.selectAllUnfilteredGraphicalItems = (0, _reselect.createSelector)([state => state.graphicalItems.cartesianItems, state => state.graphicalItems.polarItems], (cartesianItems, polarItems) => [...cartesianItems, ...polarItems]);
var selectTooltipAxisPredicate = (0, _reselect.createSelector)([_selectTooltipAxisType.selectTooltipAxisType, _selectTooltipAxisId.selectTooltipAxisId], _axisSelectors.itemAxisPredicate);
var selectAllGraphicalItemsSettings = exports.selectAllGraphicalItemsSettings = (0, _reselect.createSelector)([selectAllUnfilteredGraphicalItems, _axisSelectors.selectTooltipAxis, selectTooltipAxisPredicate], _axisSelectors.combineGraphicalItemsSettings, {
memoizeOptions: {
resultEqualityCheck: _arrayEqualityCheck.emptyArraysAreEqualCheck
}
});
var selectAllStackedGraphicalItemsSettings = (0, _reselect.createSelector)([selectAllGraphicalItemsSettings], graphicalItems => graphicalItems.filter(_StackedGraphicalItem.isStacked));
var selectTooltipGraphicalItemsData = exports.selectTooltipGraphicalItemsData = (0, _reselect.createSelector)([selectAllGraphicalItemsSettings], _axisSelectors.combineGraphicalItemsData, {
memoizeOptions: {
resultEqualityCheck: _arrayEqualityCheck.emptyArraysAreEqualCheck
}
});
var selectAnyTooltipItemUsesChartData = (0, _reselect.createSelector)([selectAllGraphicalItemsSettings], items => items.some(item => !item.data));
/**
* Data for tooltip always use the data with indexes set by a Brush,
* and never accept the isPanorama flag:
* because Tooltip never displays inside the panorama anyway
* so we don't need to worry what would happen there.
*/
var selectTooltipDisplayedData = exports.selectTooltipDisplayedData = (0, _reselect.createSelector)([selectTooltipGraphicalItemsData, _dataSelectors.selectChartDataWithIndexes], _axisSelectors.combineDisplayedData);
var selectTooltipStackedData = (0, _reselect.createSelector)([selectAllStackedGraphicalItemsSettings, _dataSelectors.selectChartDataWithIndexes, _axisSelectors.selectTooltipAxis], _combineDisplayedStackedData.combineDisplayedStackedData);
var selectAllTooltipAppliedValues = (0, _reselect.createSelector)([selectTooltipDisplayedData, _axisSelectors.selectTooltipAxis, selectAllGraphicalItemsSettings, _dataSelectors.selectChartDataWithIndexes, selectAnyTooltipItemUsesChartData, selectTooltipGraphicalItemsData], _axisSelectors.combineAllAppliedValues);
var selectTooltipAxisDomainDefinition = (0, _reselect.createSelector)([_axisSelectors.selectTooltipAxis], _axisSelectors.getDomainDefinition);
var selectTooltipDataOverflow = (0, _reselect.createSelector)([_axisSelectors.selectTooltipAxis], axisSettings => axisSettings.allowDataOverflow);
var selectTooltipDomainFromUserPreferences = (0, _reselect.createSelector)([selectTooltipAxisDomainDefinition, selectTooltipDataOverflow], _isDomainSpecifiedByUser.numericalDomainSpecifiedWithoutRequiringData);
var selectAllStackedGraphicalItems = (0, _reselect.createSelector)([selectAllGraphicalItemsSettings], graphicalItems => graphicalItems.filter(_StackedGraphicalItem.isStacked));
var selectTooltipStackGroups = (0, _reselect.createSelector)([selectTooltipStackedData, selectAllStackedGraphicalItems, _rootPropsSelectors.selectStackOffsetType, _rootPropsSelectors.selectReverseStackOrder], _axisSelectors.combineStackGroups);
var selectTooltipDomainOfStackGroups = (0, _reselect.createSelector)([selectTooltipStackGroups, _dataSelectors.selectChartDataWithIndexes, _selectTooltipAxisType.selectTooltipAxisType, selectTooltipDomainFromUserPreferences], _axisSelectors.combineDomainOfStackGroups);
var selectTooltipItemsSettingsExceptStacked = (0, _reselect.createSelector)([selectAllGraphicalItemsSettings], _axisSelectors.filterGraphicalNotStackedItems);
var selectDomainOfAllAppliedNumericalValuesIncludingErrorValues = (0, _reselect.createSelector)([selectTooltipDisplayedData, _axisSelectors.selectTooltipAxis, selectTooltipItemsSettingsExceptStacked, _axisSelectors.selectAllErrorBarSettings, _selectTooltipAxisType.selectTooltipAxisType, _dataSelectors.selectChartDataSliceWithIndexes], _axisSelectors.combineDomainOfAllAppliedNumericalValuesIncludingErrorValues, {
memoizeOptions: {
resultEqualityCheck: _numberDomainEqualityCheck.numberDomainEqualityCheck
}
});
var selectReferenceDotsByTooltipAxis = (0, _reselect.createSelector)([_axisSelectors.selectReferenceDots, _selectTooltipAxisType.selectTooltipAxisType, _selectTooltipAxisId.selectTooltipAxisId], _axisSelectors.filterReferenceElements);
var selectTooltipReferenceDotsDomain = (0, _reselect.createSelector)([selectReferenceDotsByTooltipAxis, _selectTooltipAxisType.selectTooltipAxisType], _axisSelectors.combineDotsDomain);
var selectReferenceAreasByTooltipAxis = (0, _reselect.createSelector)([_axisSelectors.selectReferenceAreas, _selectTooltipAxisType.selectTooltipAxisType, _selectTooltipAxisId.selectTooltipAxisId], _axisSelectors.filterReferenceElements);
var selectTooltipReferenceAreasDomain = (0, _reselect.createSelector)([selectReferenceAreasByTooltipAxis, _selectTooltipAxisType.selectTooltipAxisType], _axisSelectors.combineAreasDomain);
var selectReferenceLinesByTooltipAxis = (0, _reselect.createSelector)([_axisSelectors.selectReferenceLines, _selectTooltipAxisType.selectTooltipAxisType, _selectTooltipAxisId.selectTooltipAxisId], _axisSelectors.filterReferenceElements);
var selectTooltipReferenceLinesDomain = (0, _reselect.createSelector)([selectReferenceLinesByTooltipAxis, _selectTooltipAxisType.selectTooltipAxisType], _axisSelectors.combineLinesDomain);
var selectTooltipReferenceElementsDomain = (0, _reselect.createSelector)([selectTooltipReferenceDotsDomain, selectTooltipReferenceLinesDomain, selectTooltipReferenceAreasDomain], _axisSelectors.mergeDomains);
var selectTooltipNumericalDomain = (0, _reselect.createSelector)([_axisSelectors.selectTooltipAxis, selectTooltipAxisDomainDefinition, selectTooltipDomainFromUserPreferences, selectTooltipDomainOfStackGroups, selectDomainOfAllAppliedNumericalValuesIncludingErrorValues, selectTooltipReferenceElementsDomain, _chartLayoutContext.selectChartLayout, _selectTooltipAxisType.selectTooltipAxisType], _axisSelectors.combineNumericalDomain);
var selectTooltipAxisDomain = exports.selectTooltipAxisDomain = (0, _reselect.createSelector)([_axisSelectors.selectTooltipAxis, _chartLayoutContext.selectChartLayout, selectTooltipDisplayedData, selectAllTooltipAppliedValues, _rootPropsSelectors.selectStackOffsetType, _selectTooltipAxisType.selectTooltipAxisType, selectTooltipNumericalDomain], _axisSelectors.combineAxisDomain);
var selectTooltipNiceTicks = (0, _reselect.createSelector)([selectTooltipAxisDomain, _axisSelectors.selectTooltipAxis, selectTooltipAxisRealScaleType], _axisSelectors.combineNiceTicks);
var selectTooltipAxisDomainIncludingNiceTicks = exports.selectTooltipAxisDomainIncludingNiceTicks = (0, _reselect.createSelector)([_axisSelectors.selectTooltipAxis, selectTooltipAxisDomain, selectTooltipNiceTicks, _selectTooltipAxisType.selectTooltipAxisType], _axisSelectors.combineAxisDomainWithNiceTicks);
var selectTooltipAxisRange = state => {
var axisType = (0, _selectTooltipAxisType.selectTooltipAxisType)(state);
var axisId = (0, _selectTooltipAxisId.selectTooltipAxisId)(state);
var isPanorama = false; // Tooltip never displays in panorama so this is safe to assume
return (0, _axisSelectors.selectAxisRange)(state, axisType, axisId, isPanorama);
};
var selectTooltipAxisRangeWithReverse = exports.selectTooltipAxisRangeWithReverse = (0, _reselect.createSelector)([_axisSelectors.selectTooltipAxis, selectTooltipAxisRange], _combineAxisRangeWithReverse.combineAxisRangeWithReverse);
var selectTooltipConfiguredScale = (0, _reselect.createSelector)([_axisSelectors.selectTooltipAxis, selectTooltipAxisRealScaleType, selectTooltipAxisDomainIncludingNiceTicks, selectTooltipAxisRangeWithReverse], _combineConfiguredScale.combineConfiguredScale);
var selectTooltipAxisScale = exports.selectTooltipAxisScale = (0, _reselect.createSelector)([selectTooltipConfiguredScale], _RechartsScale.rechartsScaleFactory);
var selectTooltipDuplicateDomain = (0, _reselect.createSelector)([_chartLayoutContext.selectChartLayout, selectAllTooltipAppliedValues, _axisSelectors.selectTooltipAxis, _selectTooltipAxisType.selectTooltipAxisType], _axisSelectors.combineDuplicateDomain);
var selectTooltipCategoricalDomain = exports.selectTooltipCategoricalDomain = (0, _reselect.createSelector)([_chartLayoutContext.selectChartLayout, selectAllTooltipAppliedValues, _axisSelectors.selectTooltipAxis, _selectTooltipAxisType.selectTooltipAxisType], _axisSelectors.combineCategoricalDomain);
var combineTicksOfTooltipAxis = (layout, axis, realScaleType, scale, range, duplicateDomain, categoricalDomain, axisType) => {
if (!axis) {
return undefined;
}
var type = axis.type;
var isCategorical = (0, _ChartUtils.isCategoricalAxis)(layout, axisType);
if (!scale) {
return undefined;
}
var offsetForBand = realScaleType === 'scaleBand' && scale.bandwidth ? scale.bandwidth() / 2 : 2;
var offset = type === 'category' && scale.bandwidth ? scale.bandwidth() / offsetForBand : 0;
offset = axisType === 'angleAxis' && range != null && (range === null || range === void 0 ? void 0 : range.length) >= 2 ? (0, _DataUtils.mathSign)(range[0] - range[1]) * 2 * offset : offset;
// When axis is a categorical axis, but the type of axis is number or the scale of axis is not "auto"
if (isCategorical && categoricalDomain) {
return categoricalDomain.map((entry, index) => {
var scaled = scale.map(entry);
if (!(0, _isWellBehavedNumber.isWellBehavedNumber)(scaled)) {
return null;
}
return {
coordinate: scaled + offset,
value: entry,
index,
offset
};
}).filter(_DataUtils.isNotNil);
}
// When axis has duplicated text, serial numbers are used to generate scale
return scale.domain().map((entry, index) => {
var scaled = scale.map(entry);
if (!(0, _isWellBehavedNumber.isWellBehavedNumber)(scaled)) {
return null;
}
return {
coordinate: scaled + offset,
// @ts-expect-error can't use Date as an index
value: duplicateDomain ? duplicateDomain[entry] : entry,
index,
offset
};
}).filter(_DataUtils.isNotNil);
};
/**
* Of on four almost identical implementations of tick generation.
* The four horsemen of tick generation are:
* - {@link selectTooltipAxisTicks}
* - {@link combineAxisTicks}
* - {@link getTicksOfAxis}.
* - {@link combineGraphicalItemTicks}
*/
var selectTooltipAxisTicks = exports.selectTooltipAxisTicks = (0, _reselect.createSelector)([_chartLayoutContext.selectChartLayout, _axisSelectors.selectTooltipAxis, selectTooltipAxisRealScaleType, selectTooltipAxisScale, selectTooltipAxisRange, selectTooltipDuplicateDomain, selectTooltipCategoricalDomain, _selectTooltipAxisType.selectTooltipAxisType], combineTicksOfTooltipAxis);
var selectTooltipEventType = (0, _reselect.createSelector)([_selectTooltipEventType.selectDefaultTooltipEventType, _selectTooltipEventType.selectValidateTooltipEventTypes, _selectTooltipSettings.selectTooltipSettings], (defaultTooltipEventType, validateTooltipEventType, settings) => (0, _selectTooltipEventType.combineTooltipEventType)(settings.shared, defaultTooltipEventType, validateTooltipEventType));
var selectTooltipTrigger = state => state.tooltip.settings.trigger;
var selectDefaultIndex = state => state.tooltip.settings.defaultIndex;
var selectTooltipInteractionState = (0, _reselect.createSelector)([_selectTooltipState.selectTooltipState, selectTooltipEventType, selectTooltipTrigger, selectDefaultIndex], _combineTooltipInteractionState.combineTooltipInteractionState);
var selectActiveTooltipIndex = exports.selectActiveTooltipIndex = (0, _reselect.createSelector)([selectTooltipInteractionState, selectTooltipDisplayedData, _axisSelectors.selectTooltipAxisDataKey, selectTooltipAxisDomain], _combineActiveTooltipIndex.combineActiveTooltipIndex);
var selectActiveLabel = exports.selectActiveLabel = (0, _reselect.createSelector)([selectTooltipAxisTicks, selectActiveTooltipIndex], _combineActiveLabel.combineActiveLabel);
var selectActiveTooltipDataKey = exports.selectActiveTooltipDataKey = (0, _reselect.createSelector)([selectTooltipInteractionState], tooltipInteraction => {
if (!tooltipInteraction) {
return undefined;
}
return tooltipInteraction.dataKey;
});
var selectActiveTooltipGraphicalItemId = exports.selectActiveTooltipGraphicalItemId = (0, _reselect.createSelector)([selectTooltipInteractionState], tooltipInteraction => {
if (!tooltipInteraction) {
return undefined;
}
return tooltipInteraction.graphicalItemId;
});
var selectTooltipPayloadConfigurations = (0, _reselect.createSelector)([_selectTooltipState.selectTooltipState, selectTooltipEventType, selectTooltipTrigger, selectDefaultIndex], _combineTooltipPayloadConfigurations.combineTooltipPayloadConfigurations);
var selectTooltipCoordinateForDefaultIndex = (0, _reselect.createSelector)([_containerSelectors.selectChartWidth, _containerSelectors.selectChartHeight, _chartLayoutContext.selectChartLayout, _selectChartOffsetInternal.selectChartOffsetInternal, selectTooltipAxisTicks, selectDefaultIndex, selectTooltipPayloadConfigurations], _combineCoordinateForDefaultIndex.combineCoordinateForDefaultIndex);
var selectActiveTooltipCoordinate = exports.selectActiveTooltipCoordinate = (0, _reselect.createSelector)([selectTooltipInteractionState, selectTooltipCoordinateForDefaultIndex], (tooltipInteractionState, defaultIndexCoordinate) => {
if (tooltipInteractionState !== null && tooltipInteractionState !== void 0 && tooltipInteractionState.coordinate) {
return tooltipInteractionState.coordinate;
}
return defaultIndexCoordinate;
});
var selectIsTooltipActive = exports.selectIsTooltipActive = (0, _reselect.createSelector)([selectTooltipInteractionState], tooltipInteractionState => {
var _tooltipInteractionSt;
return (_tooltipInteractionSt = tooltipInteractionState === null || tooltipInteractionState === void 0 ? void 0 : tooltipInteractionState.active) !== null && _tooltipInteractionSt !== void 0 ? _tooltipInteractionSt : false;
});
var selectActiveTooltipPayload = exports.selectActiveTooltipPayload = (0, _reselect.createSelector)([selectTooltipPayloadConfigurations, selectActiveTooltipIndex, _dataSelectors.selectChartDataWithIndexes, _axisSelectors.selectTooltipAxisDataKey, selectActiveLabel, _selectTooltipPayloadSearcher.selectTooltipPayloadSearcher, selectTooltipEventType], _combineTooltipPayload.combineTooltipPayload);
var selectActiveTooltipDataPoints = exports.selectActiveTooltipDataPoints = (0, _reselect.createSelector)([selectActiveTooltipPayload], payload => {
if (payload == null) {
return undefined;
}
var dataPoints = payload.map(p => p.payload).filter(p => p != null);
return Array.from(new Set(dataPoints));
});

View file

@ -0,0 +1,25 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.selectTooltipCoordinate = void 0;
var _reselect = require("reselect");
var _selectTooltipState = require("./selectTooltipState");
var selectAllTooltipPayloadConfiguration = (0, _reselect.createSelector)([_selectTooltipState.selectTooltipState], tooltipState => tooltipState.tooltipItemPayloads);
var selectTooltipCoordinate = exports.selectTooltipCoordinate = (0, _reselect.createSelector)([selectAllTooltipPayloadConfiguration, (_state, tooltipIndex) => tooltipIndex, (_state, _tooltipIndex, graphicalItemId) => graphicalItemId], (allTooltipConfigurations, tooltipIndex, graphicalItemId) => {
if (tooltipIndex == null) {
return undefined;
}
var mostRelevantTooltipConfiguration = allTooltipConfigurations.find(tooltipConfiguration => {
return tooltipConfiguration.settings.graphicalItemId === graphicalItemId;
});
if (mostRelevantTooltipConfiguration == null) {
return undefined;
}
var getPosition = mostRelevantTooltipConfiguration.getPosition;
if (getPosition == null) {
return undefined;
}
return getPosition(tooltipIndex);
});

93
frontend/node_modules/recharts/lib/state/store.js generated vendored Normal file
View file

@ -0,0 +1,93 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.createRechartsStore = void 0;
var _toolkit = require("@reduxjs/toolkit");
var _optionsSlice = require("./optionsSlice");
var _tooltipSlice = require("./tooltipSlice");
var _chartDataSlice = require("./chartDataSlice");
var _layoutSlice = require("./layoutSlice");
var _mouseEventsMiddleware = require("./mouseEventsMiddleware");
var _reduxDevtoolsJsonStringifyReplacer = require("./reduxDevtoolsJsonStringifyReplacer");
var _cartesianAxisSlice = require("./cartesianAxisSlice");
var _graphicalItemsSlice = require("./graphicalItemsSlice");
var _referenceElementsSlice = require("./referenceElementsSlice");
var _brushSlice = require("./brushSlice");
var _legendSlice = require("./legendSlice");
var _rootPropsSlice = require("./rootPropsSlice");
var _polarAxisSlice = require("./polarAxisSlice");
var _polarOptionsSlice = require("./polarOptionsSlice");
var _keyboardEventsMiddleware = require("./keyboardEventsMiddleware");
var _externalEventsMiddleware = require("./externalEventsMiddleware");
var _touchEventsMiddleware = require("./touchEventsMiddleware");
var _errorBarSlice = require("./errorBarSlice");
var _Global = require("../util/Global");
var _zIndexSlice = require("./zIndexSlice");
var _eventSettingsSlice = require("./eventSettingsSlice");
var _renderedTicksSlice = require("./renderedTicksSlice");
var rootReducer = (0, _toolkit.combineReducers)({
brush: _brushSlice.brushReducer,
cartesianAxis: _cartesianAxisSlice.cartesianAxisReducer,
chartData: _chartDataSlice.chartDataReducer,
errorBars: _errorBarSlice.errorBarReducer,
eventSettings: _eventSettingsSlice.eventSettingsReducer,
graphicalItems: _graphicalItemsSlice.graphicalItemsReducer,
layout: _layoutSlice.chartLayoutReducer,
legend: _legendSlice.legendReducer,
options: _optionsSlice.optionsReducer,
polarAxis: _polarAxisSlice.polarAxisReducer,
polarOptions: _polarOptionsSlice.polarOptionsReducer,
referenceElements: _referenceElementsSlice.referenceElementsReducer,
renderedTicks: _renderedTicksSlice.renderedTicksReducer,
rootProps: _rootPropsSlice.rootPropsReducer,
tooltip: _tooltipSlice.tooltipReducer,
zIndex: _zIndexSlice.zIndexReducer
});
var createRechartsStore = exports.createRechartsStore = function createRechartsStore(preloadedState) {
var chartName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'Chart';
return (0, _toolkit.configureStore)({
reducer: rootReducer,
// redux-toolkit v1 types are unhappy with the preloadedState type. Remove the `as any` when bumping to v2
preloadedState: preloadedState,
// @ts-expect-error redux-toolkit v1 types are unhappy with the middleware array. Remove this comment when bumping to v2
middleware: getDefaultMiddleware => {
var _process$env$NODE_ENV;
return getDefaultMiddleware({
serializableCheck: false,
immutableCheck: !['commonjs', 'es6', 'production'].includes((_process$env$NODE_ENV = "commonjs") !== null && _process$env$NODE_ENV !== void 0 ? _process$env$NODE_ENV : '')
}).concat([_mouseEventsMiddleware.mouseClickMiddleware.middleware, _mouseEventsMiddleware.mouseMoveMiddleware.middleware, _keyboardEventsMiddleware.keyboardEventsMiddleware.middleware, _externalEventsMiddleware.externalEventsMiddleware.middleware, _touchEventsMiddleware.touchEventMiddleware.middleware]);
},
/*
* I can't find out how to satisfy typescript here.
* We return `EnhancerArray<[StoreEnhancer<{}, {}>, StoreEnhancer]>` from this function,
* but the types say we should return `EnhancerArray<StoreEnhancer<{}, {}>`.
* Looks like it's badly inferred generics, but it won't allow me to provide the correct type manually either.
* So let's just ignore the error for now.
*/
// @ts-expect-error mismatched generics
enhancers: getDefaultEnhancers => {
var enhancers = getDefaultEnhancers;
if (typeof getDefaultEnhancers === 'function') {
/*
* In RTK v2 this is always a function, but in v1 it is an array.
* Because we have @types/redux-toolkit v1 as a dependency, typescript is going to flag this as an error.
* We support both RTK v1 and v2, so we need to do this check.
* https://redux-toolkit.js.org/usage/migrating-rtk-2#configurestoreenhancers-must-be-a-callback
*/
// @ts-expect-error RTK v2 behaviour on RTK v1 types
enhancers = getDefaultEnhancers();
}
return enhancers.concat((0, _toolkit.autoBatchEnhancer)({
type: 'raf'
}));
},
devTools: _Global.Global.devToolsEnabled && {
serialize: {
replacer: _reduxDevtoolsJsonStringifyReplacer.reduxDevtoolsJsonStringifyReplacer
},
name: "recharts-".concat(chartName)
}
});
};

View file

@ -0,0 +1,226 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.tooltipReducer = exports.setTooltipSettingsState = exports.setSyncInteraction = exports.setMouseOverAxisIndex = exports.setMouseClickAxisIndex = exports.setKeyboardInteraction = exports.setActiveMouseOverItemIndex = exports.setActiveClickItemIndex = exports.replaceTooltipEntrySettings = exports.removeTooltipEntrySettings = exports.noInteraction = exports.mouseLeaveItem = exports.mouseLeaveChart = exports.initialState = exports.addTooltipEntrySettings = void 0;
var _toolkit = require("@reduxjs/toolkit");
var _immer = require("immer");
/**
* One Tooltip can display multiple TooltipPayloadEntries at a time.
*/
/**
* So what happens is that the tooltip payload is decided based on the available data, and the dataKey.
* The dataKey can either be defined on the graphical element (like Line, or Bar)
* or on the tooltip itself.
*
* The data can be defined in the chart element, or in the graphical item.
*
* So this type is all the settings, other than the data + dataKey complications.
*/
/**
* This is what Tooltip renders.
*/
/**
* null means no active index
* string means: whichever index from the chart data it is.
* Different charts have different requirements on data shapes,
* and are also responsible for providing a function that will accept this index
* and return data.
*/
/**
* Different items have different data shapes so the state has no opinion on what the data shape should be;
* the only requirement is that the chart also provides a searcher function
* that accepts the data, and a key, and returns whatever the payload in Tooltip should be.
*/
/**
* So this informs the "tooltip event type". Tooltip event type can be either "axis" or "item"
* and it is used for two things:
* 1. Sets the active area
* 2. Sets the background and cursor highlights
*
* Some charts only allow to have one type of tooltip event type, some allow both.
* Those charts that allow both will have one default, and the "shared" prop will be used to switch between them.
* Undefined means "use the chart default".
*
* Charts that only allow one tooltip event type, will ignore the shared prop.
*/
/**
* A generic state for user interaction with the chart.
* User interaction can come through multiple channels: mouse events, keyboard events, or hardcoded in props, or synchronised from other charts.
*
* Each of the interaction states is represented as TooltipInteractionState,
* and then the selectors and Tooltip will decide which of the interaction states to use.
*/
var noInteraction = exports.noInteraction = {
active: false,
index: null,
dataKey: undefined,
graphicalItemId: undefined,
coordinate: undefined
};
/**
* The tooltip interaction state stores:
*
* - Which graphical item is user interacting with at the moment,
* - which axis (or, which part of chart background) is user interacting with at the moment
* - The data that individual graphical items wish to be displayed in case the tooltip gets activated
*/
var initialState = exports.initialState = {
itemInteraction: {
click: noInteraction,
hover: noInteraction
},
axisInteraction: {
click: noInteraction,
hover: noInteraction
},
keyboardInteraction: noInteraction,
syncInteraction: {
active: false,
index: null,
dataKey: undefined,
label: undefined,
coordinate: undefined,
sourceViewBox: undefined,
graphicalItemId: undefined
},
tooltipItemPayloads: [],
settings: {
shared: undefined,
trigger: 'hover',
axisId: 0,
active: false,
defaultIndex: undefined
}
};
/**
* This is the event we get when user is interacting with a specific graphical item.
*/
/**
* Keyboard interaction payload has no graphical item ID,
* and no dataKey, because keyboard interaction is always
* with the whole chart, not with a specific graphical item.
*/
var tooltipSlice = (0, _toolkit.createSlice)({
name: 'tooltip',
initialState,
reducers: {
addTooltipEntrySettings: {
reducer(state, action) {
state.tooltipItemPayloads.push((0, _immer.castDraft)(action.payload));
},
prepare: (0, _toolkit.prepareAutoBatched)()
},
replaceTooltipEntrySettings: {
reducer(state, action) {
var _action$payload = action.payload,
prev = _action$payload.prev,
next = _action$payload.next;
var index = (0, _toolkit.current)(state).tooltipItemPayloads.indexOf((0, _immer.castDraft)(prev));
if (index > -1) {
state.tooltipItemPayloads[index] = (0, _immer.castDraft)(next);
}
},
prepare: (0, _toolkit.prepareAutoBatched)()
},
removeTooltipEntrySettings: {
reducer(state, action) {
var index = (0, _toolkit.current)(state).tooltipItemPayloads.indexOf((0, _immer.castDraft)(action.payload));
if (index > -1) {
state.tooltipItemPayloads.splice(index, 1);
}
},
prepare: (0, _toolkit.prepareAutoBatched)()
},
setTooltipSettingsState(state, action) {
state.settings = action.payload;
},
setActiveMouseOverItemIndex(state, action) {
state.syncInteraction.active = false;
state.syncInteraction.sourceViewBox = undefined;
state.keyboardInteraction.active = false;
state.itemInteraction.hover.active = true;
state.itemInteraction.hover.index = action.payload.activeIndex;
state.itemInteraction.hover.dataKey = action.payload.activeDataKey;
state.itemInteraction.hover.graphicalItemId = action.payload.activeGraphicalItemId;
state.itemInteraction.hover.coordinate = action.payload.activeCoordinate;
},
mouseLeaveChart(state) {
/*
* Clear only the active flags. Why?
* 1. Keep Coordinate to preserve animation - next time the Tooltip appears, we want to render it from
* the last place where it was when it disappeared.
* 2. We want to keep all the properties anyway just in case the tooltip has `active=true` prop
* and continues being visible even after the mouse has left the chart.
*/
state.itemInteraction.hover.active = false;
state.axisInteraction.hover.active = false;
},
mouseLeaveItem(state) {
state.itemInteraction.hover.active = false;
},
setActiveClickItemIndex(state, action) {
state.syncInteraction.active = false;
state.syncInteraction.sourceViewBox = undefined;
state.itemInteraction.click.active = true;
state.keyboardInteraction.active = false;
state.itemInteraction.click.index = action.payload.activeIndex;
state.itemInteraction.click.dataKey = action.payload.activeDataKey;
state.itemInteraction.click.graphicalItemId = action.payload.activeGraphicalItemId;
state.itemInteraction.click.coordinate = action.payload.activeCoordinate;
},
setMouseOverAxisIndex(state, action) {
state.syncInteraction.active = false;
state.syncInteraction.sourceViewBox = undefined;
state.axisInteraction.hover.active = true;
state.keyboardInteraction.active = false;
state.axisInteraction.hover.index = action.payload.activeIndex;
state.axisInteraction.hover.dataKey = action.payload.activeDataKey;
state.axisInteraction.hover.coordinate = action.payload.activeCoordinate;
},
setMouseClickAxisIndex(state, action) {
state.syncInteraction.active = false;
state.syncInteraction.sourceViewBox = undefined;
state.keyboardInteraction.active = false;
state.axisInteraction.click.active = true;
state.axisInteraction.click.index = action.payload.activeIndex;
state.axisInteraction.click.dataKey = action.payload.activeDataKey;
state.axisInteraction.click.coordinate = action.payload.activeCoordinate;
},
setSyncInteraction(state, action) {
state.syncInteraction = action.payload;
},
setKeyboardInteraction(state, action) {
state.keyboardInteraction.active = action.payload.active;
state.keyboardInteraction.index = action.payload.activeIndex;
state.keyboardInteraction.coordinate = action.payload.activeCoordinate;
}
}
});
var _tooltipSlice$actions = tooltipSlice.actions,
addTooltipEntrySettings = exports.addTooltipEntrySettings = _tooltipSlice$actions.addTooltipEntrySettings,
replaceTooltipEntrySettings = exports.replaceTooltipEntrySettings = _tooltipSlice$actions.replaceTooltipEntrySettings,
removeTooltipEntrySettings = exports.removeTooltipEntrySettings = _tooltipSlice$actions.removeTooltipEntrySettings,
setTooltipSettingsState = exports.setTooltipSettingsState = _tooltipSlice$actions.setTooltipSettingsState,
setActiveMouseOverItemIndex = exports.setActiveMouseOverItemIndex = _tooltipSlice$actions.setActiveMouseOverItemIndex,
mouseLeaveItem = exports.mouseLeaveItem = _tooltipSlice$actions.mouseLeaveItem,
mouseLeaveChart = exports.mouseLeaveChart = _tooltipSlice$actions.mouseLeaveChart,
setActiveClickItemIndex = exports.setActiveClickItemIndex = _tooltipSlice$actions.setActiveClickItemIndex,
setMouseOverAxisIndex = exports.setMouseOverAxisIndex = _tooltipSlice$actions.setMouseOverAxisIndex,
setMouseClickAxisIndex = exports.setMouseClickAxisIndex = _tooltipSlice$actions.setMouseClickAxisIndex,
setSyncInteraction = exports.setSyncInteraction = _tooltipSlice$actions.setSyncInteraction,
setKeyboardInteraction = exports.setKeyboardInteraction = _tooltipSlice$actions.setKeyboardInteraction;
var tooltipReducer = exports.tooltipReducer = tooltipSlice.reducer;

View file

@ -0,0 +1,119 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.touchEventMiddleware = exports.touchEventAction = void 0;
var _toolkit = require("@reduxjs/toolkit");
var _tooltipSlice = require("./tooltipSlice");
var _selectActivePropsFromChartPointer = require("./selectors/selectActivePropsFromChartPointer");
var _getRelativeCoordinate = require("../util/getRelativeCoordinate");
var _selectTooltipEventType = require("./selectors/selectTooltipEventType");
var _Constants = require("../util/Constants");
var _touchSelectors = require("./selectors/touchSelectors");
var _tooltipSelectors = require("./selectors/tooltipSelectors");
var _createEventProxy = require("../util/createEventProxy");
var touchEventAction = exports.touchEventAction = (0, _toolkit.createAction)('touchMove');
var touchEventMiddleware = exports.touchEventMiddleware = (0, _toolkit.createListenerMiddleware)();
var rafId = null;
var timeoutId = null;
var latestChartPointers = null;
var latestTouchEvent = null;
touchEventMiddleware.startListening({
actionCreator: touchEventAction,
effect: (action, listenerApi) => {
var touchEvent = action.payload;
if (touchEvent.touches == null || touchEvent.touches.length === 0) {
return;
}
latestTouchEvent = (0, _createEventProxy.createEventProxy)(touchEvent);
var state = listenerApi.getState();
var _state$eventSettings = state.eventSettings,
throttleDelay = _state$eventSettings.throttleDelay,
throttledEvents = _state$eventSettings.throttledEvents;
var isThrottled = throttledEvents === 'all' || throttledEvents.includes('touchmove');
if (rafId !== null) {
cancelAnimationFrame(rafId);
rafId = null;
}
if (timeoutId !== null && (typeof throttleDelay !== 'number' || !isThrottled)) {
clearTimeout(timeoutId);
timeoutId = null;
}
latestChartPointers = Array.from(touchEvent.touches).map(touch => (0, _getRelativeCoordinate.getRelativeCoordinate)({
clientX: touch.clientX,
clientY: touch.clientY,
currentTarget: touchEvent.currentTarget
}));
var callback = () => {
if (latestTouchEvent == null) {
return;
}
var currentState = listenerApi.getState();
var tooltipEventType = (0, _selectTooltipEventType.selectTooltipEventType)(currentState, currentState.tooltip.settings.shared);
if (tooltipEventType === 'axis') {
var _latestChartPointers;
var latestTouchPointer = (_latestChartPointers = latestChartPointers) === null || _latestChartPointers === void 0 ? void 0 : _latestChartPointers[0];
if (latestTouchPointer == null) {
rafId = null;
timeoutId = null;
return;
}
var activeProps = (0, _selectActivePropsFromChartPointer.selectActivePropsFromChartPointer)(currentState, latestTouchPointer);
if ((activeProps === null || activeProps === void 0 ? void 0 : activeProps.activeIndex) != null) {
listenerApi.dispatch((0, _tooltipSlice.setMouseOverAxisIndex)({
activeIndex: activeProps.activeIndex,
activeDataKey: undefined,
activeCoordinate: activeProps.activeCoordinate
}));
}
} else if (tooltipEventType === 'item') {
var _target$getAttribute;
var touch = latestTouchEvent.touches[0];
if (document.elementFromPoint == null || touch == null) {
return;
}
var target = document.elementFromPoint(touch.clientX, touch.clientY);
if (!target || !target.getAttribute) {
return;
}
var itemIndex = target.getAttribute(_Constants.DATA_ITEM_INDEX_ATTRIBUTE_NAME);
var graphicalItemId = (_target$getAttribute = target.getAttribute(_Constants.DATA_ITEM_GRAPHICAL_ITEM_ID_ATTRIBUTE_NAME)) !== null && _target$getAttribute !== void 0 ? _target$getAttribute : undefined;
var settings = (0, _tooltipSelectors.selectAllGraphicalItemsSettings)(currentState).find(item => item.id === graphicalItemId);
if (itemIndex == null || settings == null || graphicalItemId == null) {
return;
}
var dataKey = settings.dataKey;
var coordinate = (0, _touchSelectors.selectTooltipCoordinate)(currentState, itemIndex, graphicalItemId);
listenerApi.dispatch((0, _tooltipSlice.setActiveMouseOverItemIndex)({
activeDataKey: dataKey,
activeIndex: itemIndex,
activeCoordinate: coordinate,
activeGraphicalItemId: graphicalItemId
}));
}
rafId = null;
timeoutId = null;
};
if (!isThrottled) {
callback();
return;
}
if (throttleDelay === 'raf') {
rafId = requestAnimationFrame(callback);
} else if (typeof throttleDelay === 'number') {
if (timeoutId === null) {
callback();
latestTouchEvent = null;
timeoutId = setTimeout(() => {
if (latestTouchEvent) {
callback();
} else {
timeoutId = null;
rafId = null;
}
}, throttleDelay);
}
}
}
});

View file

@ -0,0 +1 @@
"use strict";

View file

@ -0,0 +1 @@
"use strict";

View file

@ -0,0 +1 @@
"use strict";

View file

@ -0,0 +1 @@
"use strict";

View file

@ -0,0 +1 @@
"use strict";

View file

@ -0,0 +1 @@
"use strict";

View file

@ -0,0 +1 @@
"use strict";

View file

@ -0,0 +1,20 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.isStacked = isStacked;
/**
* Some graphical items allow data stacking. The stacks are optional,
* so all props here are optional too.
*/
/**
* Some graphical items allow data stacking.
* This interface is used to represent the items that are stacked
* because the user has provided the stackId and dataKey properties.
*/
function isStacked(graphicalItem) {
return 'stackId' in graphicalItem && graphicalItem.stackId != null && graphicalItem.dataKey != null;
}

112
frontend/node_modules/recharts/lib/state/zIndexSlice.js generated vendored Normal file
View file

@ -0,0 +1,112 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.zIndexReducer = exports.unregisterZIndexPortalElement = exports.unregisterZIndexPortal = exports.registerZIndexPortalElement = exports.registerZIndexPortal = void 0;
var _toolkit = require("@reduxjs/toolkit");
var _immer = require("immer");
var _DefaultZIndexes = require("../zIndex/DefaultZIndexes");
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /**
* This slice contains a registry of z-index values for various components.
* The state is a map from z-index numbers to element references.
*/
var seed = {};
var initialState = {
zIndexMap: Object.values(_DefaultZIndexes.DefaultZIndexes).reduce((acc, current) => _objectSpread(_objectSpread({}, acc), {}, {
[current]: {
element: undefined,
panoramaElement: undefined,
consumers: 0
}
}), seed)
};
var defaultZIndexSet = new Set(Object.values(_DefaultZIndexes.DefaultZIndexes));
function isDefaultZIndex(zIndex) {
return defaultZIndexSet.has(zIndex);
}
var zIndexSlice = (0, _toolkit.createSlice)({
name: 'zIndex',
initialState,
reducers: {
registerZIndexPortal: {
reducer: (state, action) => {
var zIndex = action.payload.zIndex;
if (state.zIndexMap[zIndex]) {
state.zIndexMap[zIndex].consumers += 1;
} else {
state.zIndexMap[zIndex] = {
consumers: 1,
element: undefined,
panoramaElement: undefined
};
}
},
prepare: (0, _toolkit.prepareAutoBatched)()
},
unregisterZIndexPortal: {
reducer: (state, action) => {
var zIndex = action.payload.zIndex;
if (state.zIndexMap[zIndex]) {
state.zIndexMap[zIndex].consumers -= 1;
/*
* Garbage collect unused z-index entries, except for default z-indexes.
* Default z-indexes are always rendered, regardless of whether there are consumers or not.
* And because of that, even if we delete this entry, the ZIndexPortal provider will still be rendered
* and React is not going to re-create it, and it won't re-register the element ID.
* So let's not delete default z-index entries.
*/
if (state.zIndexMap[zIndex].consumers <= 0 && !isDefaultZIndex(zIndex)) {
delete state.zIndexMap[zIndex];
}
}
},
prepare: (0, _toolkit.prepareAutoBatched)()
},
registerZIndexPortalElement: {
reducer: (state, action) => {
var _action$payload = action.payload,
zIndex = _action$payload.zIndex,
element = _action$payload.element,
isPanorama = _action$payload.isPanorama;
if (state.zIndexMap[zIndex]) {
if (isPanorama) {
state.zIndexMap[zIndex].panoramaElement = (0, _immer.castDraft)(element);
} else {
state.zIndexMap[zIndex].element = (0, _immer.castDraft)(element);
}
} else {
state.zIndexMap[zIndex] = {
consumers: 0,
element: isPanorama ? undefined : (0, _immer.castDraft)(element),
panoramaElement: isPanorama ? (0, _immer.castDraft)(element) : undefined
};
}
},
prepare: (0, _toolkit.prepareAutoBatched)()
},
unregisterZIndexPortalElement: {
reducer: (state, action) => {
var zIndex = action.payload.zIndex;
if (state.zIndexMap[zIndex]) {
if (action.payload.isPanorama) {
state.zIndexMap[zIndex].panoramaElement = undefined;
} else {
state.zIndexMap[zIndex].element = undefined;
}
}
},
prepare: (0, _toolkit.prepareAutoBatched)()
}
}
});
var _zIndexSlice$actions = zIndexSlice.actions,
registerZIndexPortal = exports.registerZIndexPortal = _zIndexSlice$actions.registerZIndexPortal,
unregisterZIndexPortal = exports.unregisterZIndexPortal = _zIndexSlice$actions.unregisterZIndexPortal,
registerZIndexPortalElement = exports.registerZIndexPortalElement = _zIndexSlice$actions.registerZIndexPortalElement,
unregisterZIndexPortalElement = exports.unregisterZIndexPortalElement = _zIndexSlice$actions.unregisterZIndexPortalElement;
var zIndexReducer = exports.zIndexReducer = zIndexSlice.reducer;