11import React , { CSSProperties , createRef } from 'react' ;
22import classNames from 'classnames' ;
33import { Provider } from 'react-redux' ;
4+ import { createStore , Store } from 'redux' ;
5+ import Konva from 'konva' ;
6+ import { Stage } from 'react-konva' ;
7+ import uuid from 'uuid' ;
8+
49import { SpecsParser } from '../specs/specs_parser' ;
510import { ChartResizer } from './chart_resizer' ;
611import { Legend } from './legend/legend' ;
@@ -10,9 +15,6 @@ import { Position } from '../chart_types/xy_chart/utils/specs';
1015import { ChartSize , getChartSize } from '../utils/chart_size' ;
1116import { ChartStatus } from './chart_status' ;
1217import { chartStoreReducer , GlobalChartState } from '../state/chart_state' ;
13- import { createStore , Store } from 'redux' ;
14- import uuid from 'uuid' ;
15- import { devToolsEnhancer } from 'redux-devtools-extension' ;
1618import { isInitialized } from '../state/selectors/is_initialized' ;
1719import { createOnElementOutCaller } from '../chart_types/xy_chart/state/selectors/on_element_out_caller' ;
1820import { createOnElementOverCaller } from '../chart_types/xy_chart/state/selectors/on_element_over_caller' ;
@@ -23,8 +25,6 @@ import { createOnBrushEndCaller } from '../chart_types/xy_chart/state/selectors/
2325import { onExternalPointerEvent } from '../state/actions/events' ;
2426import { CursorEvent } from '../specs' ;
2527import { createOnPointerMoveCaller } from '../chart_types/xy_chart/state/selectors/on_pointer_move_caller' ;
26- import Konva from 'konva' ;
27- import { Stage } from 'react-konva' ;
2828
2929interface ChartProps {
3030 /** The type of rendered
@@ -57,17 +57,19 @@ export class Chart extends React.Component<ChartProps, ChartState> {
5757 private chartStore : Store < GlobalChartState > ;
5858 private chartContainerRef : React . RefObject < HTMLDivElement > ;
5959 private chartStageRef : React . RefObject < Stage > ;
60+
6061 constructor ( props : any ) {
6162 super ( props ) ;
6263 this . chartContainerRef = createRef ( ) ;
6364 this . chartStageRef = createRef ( ) ;
6465
65- const storeReducer = chartStoreReducer ( uuid . v4 ( ) ) ;
66- if ( process . env . NODE_ENV !== 'production' ) {
67- this . chartStore = createStore ( storeReducer , devToolsEnhancer ( { trace : true } ) ) ;
68- } else {
69- this . chartStore = createStore ( storeReducer ) ;
70- }
66+ const id = uuid . v4 ( ) ;
67+ const storeReducer = chartStoreReducer ( id ) ;
68+ const enhancers = ( window as any ) . __REDUX_DEVTOOLS_EXTENSION_COMPOSE__
69+ ? ( window as any ) . __REDUX_DEVTOOLS_EXTENSION_COMPOSE__ ( { trace : true , name : `@elastic/charts (id: ${ id } )` } ) ( )
70+ : undefined ;
71+
72+ this . chartStore = createStore ( storeReducer , enhancers ) ;
7173 this . state = {
7274 legendPosition : Position . Right ,
7375 } ;
@@ -135,7 +137,7 @@ export class Chart extends React.Component<ChartProps, ChartState> {
135137 const canvasStage = stage . toCanvas ( {
136138 width,
137139 height,
138- callback : ( ) => { } ,
140+ callback : ( ) => undefined ,
139141 } ) ;
140142 // @ts -ignore
141143 if ( canvasStage . msToBlob ) {
0 commit comments