|
Last change
on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago |
|
Added visualizations
|
-
Property mode
set to
100644
|
|
File size:
1.2 KB
|
| Rev | Line | |
|---|
| [a762898] | 1 | import { createSlice } from '@reduxjs/toolkit';
|
|---|
| 2 | import { isNan } from '../util/DataUtils';
|
|---|
| 3 |
|
|---|
| 4 | /**
|
|---|
| 5 | * These chart options are decided internally, by Recharts,
|
|---|
| 6 | * and will not change during the lifetime of the chart.
|
|---|
| 7 | *
|
|---|
| 8 | * Changing these options can be done by swapping the root element
|
|---|
| 9 | * which will make a brand-new Redux store.
|
|---|
| 10 | *
|
|---|
| 11 | * If you want to store options that can be changed by the user,
|
|---|
| 12 | * use UpdatableChartOptions in rootPropsSlice.ts.
|
|---|
| 13 | */
|
|---|
| 14 |
|
|---|
| 15 | export var arrayTooltipSearcher = (data, strIndex) => {
|
|---|
| 16 | if (!strIndex) return undefined;
|
|---|
| 17 | if (!Array.isArray(data)) return undefined;
|
|---|
| 18 | var numIndex = Number.parseInt(strIndex, 10);
|
|---|
| 19 | if (isNan(numIndex)) {
|
|---|
| 20 | return undefined;
|
|---|
| 21 | }
|
|---|
| 22 | return data[numIndex];
|
|---|
| 23 | };
|
|---|
| 24 | var initialState = {
|
|---|
| 25 | chartName: '',
|
|---|
| 26 | tooltipPayloadSearcher: () => undefined,
|
|---|
| 27 | eventEmitter: undefined,
|
|---|
| 28 | defaultTooltipEventType: 'axis'
|
|---|
| 29 | };
|
|---|
| 30 | var optionsSlice = createSlice({
|
|---|
| 31 | name: 'options',
|
|---|
| 32 | initialState,
|
|---|
| 33 | reducers: {
|
|---|
| 34 | createEventEmitter: state => {
|
|---|
| 35 | if (state.eventEmitter == null) {
|
|---|
| 36 | state.eventEmitter = Symbol('rechartsEventEmitter');
|
|---|
| 37 | }
|
|---|
| 38 | }
|
|---|
| 39 | }
|
|---|
| 40 | });
|
|---|
| 41 | export var optionsReducer = optionsSlice.reducer;
|
|---|
| 42 | export var {
|
|---|
| 43 | createEventEmitter
|
|---|
| 44 | } = optionsSlice.actions; |
|---|
Note:
See
TracBrowser
for help on using the repository browser.