source: node_modules/recharts/lib/state/selectors/lineSelectors.js

Last change on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago

Added visualizations

  • Property mode set to 100644
File size: 3.4 KB
Line 
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.selectLinePoints = void 0;
7var _reselect = require("reselect");
8var _Line = require("../../cartesian/Line");
9var _dataSelectors = require("./dataSelectors");
10var _chartLayoutContext = require("../../context/chartLayoutContext");
11var _axisSelectors = require("./axisSelectors");
12var _ChartUtils = require("../../util/ChartUtils");
13var selectXAxisWithScale = (state, xAxisId, _yAxisId, isPanorama) => (0, _axisSelectors.selectAxisWithScale)(state, 'xAxis', xAxisId, isPanorama);
14var selectXAxisTicks = (state, xAxisId, _yAxisId, isPanorama) => (0, _axisSelectors.selectTicksOfGraphicalItem)(state, 'xAxis', xAxisId, isPanorama);
15var selectYAxisWithScale = (state, _xAxisId, yAxisId, isPanorama) => (0, _axisSelectors.selectAxisWithScale)(state, 'yAxis', yAxisId, isPanorama);
16var selectYAxisTicks = (state, _xAxisId, yAxisId, isPanorama) => (0, _axisSelectors.selectTicksOfGraphicalItem)(state, 'yAxis', yAxisId, isPanorama);
17var selectBandSize = (0, _reselect.createSelector)([_chartLayoutContext.selectChartLayout, selectXAxisWithScale, selectYAxisWithScale, selectXAxisTicks, selectYAxisTicks], (layout, xAxis, yAxis, xAxisTicks, yAxisTicks) => {
18 if ((0, _ChartUtils.isCategoricalAxis)(layout, 'xAxis')) {
19 return (0, _ChartUtils.getBandSizeOfAxis)(xAxis, xAxisTicks, false);
20 }
21 return (0, _ChartUtils.getBandSizeOfAxis)(yAxis, yAxisTicks, false);
22});
23var pickLineId = (_state, _xAxisId, _yAxisId, _isPanorama, id) => id;
24function isLineSettings(item) {
25 return item.type === 'line';
26}
27
28/*
29 * There is a race condition problem because we read some data from props and some from the state.
30 * The state is updated through a dispatch and is one render behind,
31 * and so we have this weird one tick render where the displayedData in one selector have the old dataKey
32 * but the new dataKey in another selector.
33 *
34 * So here instead of reading the dataKey from the props, we always read it from the state.
35 */
36var selectSynchronisedLineSettings = (0, _reselect.createSelector)([_axisSelectors.selectUnfilteredCartesianItems, pickLineId], (graphicalItems, id) => graphicalItems.filter(isLineSettings).find(x => x.id === id));
37var selectLinePoints = exports.selectLinePoints = (0, _reselect.createSelector)([_chartLayoutContext.selectChartLayout, selectXAxisWithScale, selectYAxisWithScale, selectXAxisTicks, selectYAxisTicks, selectSynchronisedLineSettings, selectBandSize, _dataSelectors.selectChartDataWithIndexesIfNotInPanoramaPosition4], (layout, xAxis, yAxis, xAxisTicks, yAxisTicks, lineSettings, bandSize, _ref) => {
38 var {
39 chartData,
40 dataStartIndex,
41 dataEndIndex
42 } = _ref;
43 if (lineSettings == null || xAxis == null || yAxis == null || xAxisTicks == null || yAxisTicks == null || xAxisTicks.length === 0 || yAxisTicks.length === 0 || bandSize == null || layout !== 'horizontal' && layout !== 'vertical') {
44 return undefined;
45 }
46 var {
47 dataKey,
48 data
49 } = lineSettings;
50 var displayedData;
51 if (data != null && data.length > 0) {
52 displayedData = data;
53 } else {
54 displayedData = chartData === null || chartData === void 0 ? void 0 : chartData.slice(dataStartIndex, dataEndIndex + 1);
55 }
56 if (displayedData == null) {
57 return undefined;
58 }
59 return (0, _Line.computeLinePoints)({
60 layout,
61 xAxis,
62 yAxis,
63 xAxisTicks,
64 yAxisTicks,
65 dataKey,
66 bandSize,
67 displayedData
68 });
69});
Note: See TracBrowser for help on using the repository browser.