@@ -121,11 +121,7 @@ class EditorControls extends Component {
121121
122122 // can't use default prop because plotly.js mutates it:
123123 // https://github.com/plotly/react-chart-editor/issues/509
124- graphDiv . data . push (
125- this . props . useAsDefaultTrace
126- ? this . props . useAsDefaultTrace
127- : { type : 'scatter' , mode : 'markers' }
128- ) ;
124+ graphDiv . data . push ( this . props . makeDefaultTrace ( this . props . useAsDefaultTrace ) ) ;
129125
130126 if ( this . props . afterAddTrace ) {
131127 this . props . afterAddTrace ( payload ) ;
@@ -307,11 +303,18 @@ EditorControls.propTypes = {
307303 showFieldTooltips : PropTypes . bool ,
308304 traceTypesConfig : PropTypes . object ,
309305 useAsDefaultTrace : PropTypes . object ,
306+ makeDefaultTrace : PropTypes . func ,
310307} ;
311308
312309EditorControls . defaultProps = {
313310 showFieldTooltips : false ,
314311 locale : 'en' ,
312+ makeDefaultTrace : suppliedDefault => {
313+ if ( suppliedDefault ) {
314+ return suppliedDefault ;
315+ }
316+ return { type : 'scatter' , mode : 'markers' }
317+ } ,
315318 traceTypesConfig : {
316319 categories : _ => categoryLayout ( _ ) ,
317320 traces : _ => traceTypes ( _ ) ,
0 commit comments