File tree Expand file tree Collapse file tree 4 files changed +55
-3
lines changed
styles/components/widgets Expand file tree Collapse file tree 4 files changed +55
-3
lines changed Original file line number Diff line number Diff line change @@ -118,7 +118,13 @@ class EditorControls extends Component {
118118 if ( this . props . beforeAddTrace ) {
119119 this . props . beforeAddTrace ( payload ) ;
120120 }
121- graphDiv . data . push ( { type : 'scatter' , mode : 'markers' } ) ;
121+
122+ graphDiv . data . push (
123+ this . props . useAsDefaultTrace
124+ ? this . props . useAsDefaultTrace
125+ : { type : 'scatter' , mode : 'markers' }
126+ ) ;
127+
122128 if ( this . props . afterAddTrace ) {
123129 this . props . afterAddTrace ( payload ) ;
124130 }
@@ -298,6 +304,7 @@ EditorControls.propTypes = {
298304 plotly : PropTypes . object ,
299305 showFieldTooltips : PropTypes . bool ,
300306 traceTypesConfig : PropTypes . object ,
307+ useAsDefaultTrace : PropTypes . object ,
301308} ;
302309
303310EditorControls . defaultProps = {
Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ class PlotlyEditor extends Component {
2626 dictionaries = { this . props . dictionaries }
2727 showFieldTooltips = { this . props . showFieldTooltips }
2828 srcConverters = { this . props . srcConverters }
29+ useAsDefaultTrace = { this . props . useAsDefaultTrace }
2930 >
3031 { this . props . children }
3132 </ EditorControls >
@@ -75,6 +76,7 @@ PlotlyEditor.propTypes = {
7576 toSrc : PropTypes . func . isRequired ,
7677 fromSrc : PropTypes . func . isRequired ,
7778 } ) ,
79+ useAsDefaultTrace : PropTypes . object ,
7880} ;
7981
8082PlotlyEditor . defaultProps = {
Original file line number Diff line number Diff line change @@ -121,11 +121,53 @@ class TraceTypeSelector extends Component {
121121 } ) ;
122122 }
123123
124+ renderGrid ( ) {
125+ return < div className = "trace-grid" > { this . renderCategories ( ) } </ div > ;
126+ }
127+
128+ renderSingleBlock ( ) {
129+ const { fullValue} = this . props ;
130+ const {
131+ traceTypesConfig : { traces, complex} ,
132+ localize : _ ,
133+ } = this . context ;
134+
135+ const items = traces ( _ ) . map ( item => (
136+ < Item
137+ key = { item . value }
138+ complex = { complex }
139+ active = { fullValue === item . value }
140+ item = { item }
141+ actions = { actions }
142+ showActions = { false }
143+ handleClick = { ( ) => this . selectAndClose ( item . value ) }
144+ style = { { display : 'inline-block' } }
145+ />
146+ ) ) ;
147+
148+ return (
149+ < div
150+ style = { {
151+ maxWidth : '460px' ,
152+ display : 'flex' ,
153+ flexFlow : 'wrap' ,
154+ padding : '5px' ,
155+ } }
156+ >
157+ { items }
158+ </ div >
159+ ) ;
160+ }
161+
124162 render ( ) {
125- const { localize : _ } = this . context ;
163+ const {
164+ traceTypesConfig : { categories} ,
165+ localize : _ ,
166+ } = this . context ;
167+
126168 return (
127169 < Modal title = { _ ( 'Select Trace Type' ) } >
128- < div className = "trace-grid" > { this . renderCategories ( ) } </ div >
170+ { categories ? this . renderGrid ( ) : this . renderSingleBlock ( ) }
129171 </ Modal >
130172 ) ;
131173 }
Original file line number Diff line number Diff line change @@ -175,6 +175,7 @@ $item-size: 90px;
175175 color : var (--color-text-base );
176176 text-transform : capitalize ;
177177 font-size : var (--font-size-small );
178+ text-align : center ;
178179 }
179180}
180181
You can’t perform that action at this time.
0 commit comments