|
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.3 KB
|
| Rev | Line | |
|---|
| [a762898] | 1 | import { createSlice } from '@reduxjs/toolkit';
|
|---|
| 2 |
|
|---|
| 3 | /**
|
|---|
| 4 | * ErrorBars have lot more settings but all the others are scoped to the component itself.
|
|---|
| 5 | * Only some of them required to be reported to the global store because XAxis and YAxis need to know
|
|---|
| 6 | * if the error bar is contributing to extending the axis domain.
|
|---|
| 7 | */
|
|---|
| 8 |
|
|---|
| 9 | var initialState = {};
|
|---|
| 10 | var errorBarSlice = createSlice({
|
|---|
| 11 | name: 'errorBars',
|
|---|
| 12 | initialState,
|
|---|
| 13 | reducers: {
|
|---|
| 14 | addErrorBar: (state, action) => {
|
|---|
| 15 | var {
|
|---|
| 16 | itemId,
|
|---|
| 17 | errorBar
|
|---|
| 18 | } = action.payload;
|
|---|
| 19 | if (!state[itemId]) {
|
|---|
| 20 | state[itemId] = [];
|
|---|
| 21 | }
|
|---|
| 22 | state[itemId].push(errorBar);
|
|---|
| 23 | },
|
|---|
| 24 | replaceErrorBar: (state, action) => {
|
|---|
| 25 | var {
|
|---|
| 26 | itemId,
|
|---|
| 27 | prev,
|
|---|
| 28 | next
|
|---|
| 29 | } = action.payload;
|
|---|
| 30 | if (state[itemId]) {
|
|---|
| 31 | state[itemId] = state[itemId].map(e => e.dataKey === prev.dataKey && e.direction === prev.direction ? next : e);
|
|---|
| 32 | }
|
|---|
| 33 | },
|
|---|
| 34 | removeErrorBar: (state, action) => {
|
|---|
| 35 | var {
|
|---|
| 36 | itemId,
|
|---|
| 37 | errorBar
|
|---|
| 38 | } = action.payload;
|
|---|
| 39 | if (state[itemId]) {
|
|---|
| 40 | state[itemId] = state[itemId].filter(e => e.dataKey !== errorBar.dataKey || e.direction !== errorBar.direction);
|
|---|
| 41 | }
|
|---|
| 42 | }
|
|---|
| 43 | }
|
|---|
| 44 | });
|
|---|
| 45 | export var {
|
|---|
| 46 | addErrorBar,
|
|---|
| 47 | replaceErrorBar,
|
|---|
| 48 | removeErrorBar
|
|---|
| 49 | } = errorBarSlice.actions;
|
|---|
| 50 | export var errorBarReducer = errorBarSlice.reducer; |
|---|
Note:
See
TracBrowser
for help on using the repository browser.