@@ -6,71 +6,10 @@ import {
6
6
traceTypeToPlotlyInitFigure ,
7
7
localize ,
8
8
plotlyTraceToCustomTrace ,
9
+ computeTraceOptionsFromSchema ,
9
10
} from 'lib' ;
10
- import { EDITOR_ACTIONS } from 'lib/constants' ;
11
11
import TraceTypeSelector from 'components/widgets/TraceTypeSelector' ;
12
12
13
- function computeTraceOptionsFromSchema ( schema , _ , context ) {
14
- // Filter out Polar "area" type as it is fairly broken and we want to present
15
- // scatter with fill as an "area" chart type for convenience.
16
- const traceTypes = Object . keys ( schema . traces ) . filter (
17
- t => ! [ 'area' , 'scattermapbox' ] . includes ( t )
18
- ) ;
19
-
20
- // explicit map of all supported trace types (as of plotlyjs 1.32)
21
- const traceOptions = [
22
- { value : 'scatter' , label : _ ( 'Scatter' ) } ,
23
- { value : 'box' , label : _ ( 'Box' ) } ,
24
- { value : 'bar' , label : _ ( 'Bar' ) } ,
25
- { value : 'heatmap' , label : _ ( 'Heatmap' ) } ,
26
- // {value: 'histogram', label: _('Histogram')},
27
- // {value: 'histogram2d', label: _('2D Histogram')},
28
- // {value: 'histogram2dcontour', label: _('2D Contour Histogram')},
29
- { value : 'pie' , label : _ ( 'Pie' ) } ,
30
- { value : 'contour' , label : _ ( 'Contour' ) } ,
31
- { value : 'scatterternary' , label : _ ( 'Ternary Scatter' ) } ,
32
- // {value: 'violin', label: _('Violin')},
33
- { value : 'scatter3d' , label : _ ( '3D Scatter' ) } ,
34
- { value : 'surface' , label : _ ( 'Surface' ) } ,
35
- { value : 'mesh3d' , label : _ ( '3D Mesh' ) } ,
36
- { value : 'scattergeo' , label : _ ( 'Atlas Map' ) } ,
37
- { value : 'choropleth' , label : _ ( 'Choropleth' ) } ,
38
- // {value: 'scattergl', label: _('Scatter GL')},
39
- // {value: 'pointcloud', label: _('Point Cloud')},
40
- // {value: 'heatmapgl', label: _('Heatmap GL')},
41
- // {value: 'parcoords', label: _('Parallel Coordinates')},
42
- // {value: 'sankey', label: _('Sankey')},
43
- // {value: 'table', label: _('Table')},
44
- // {value: 'carpet', label: _('Carpet')},
45
- // {value: 'scattercarpet', label: _('Carpet Scatter')},
46
- // {value: 'contourcarpet', label: _('Carpet Contour')},
47
- { value : 'ohlc' , label : _ ( 'OHLC' ) } ,
48
- { value : 'candlestick' , label : _ ( 'Candlestick' ) } ,
49
- // {value: 'scatterpolar', label: _('Polar Scatter')},
50
- ] . filter ( obj => traceTypes . indexOf ( obj . value ) !== - 1 ) ;
51
-
52
- const traceIndex = traceType =>
53
- traceOptions . findIndex ( opt => opt . value === traceType ) ;
54
-
55
- traceOptions . splice (
56
- traceIndex ( 'scatter' ) + 1 ,
57
- 0 ,
58
- { label : _ ( 'Line' ) , value : 'line' } ,
59
- { label : _ ( 'Area' ) , value : 'area' }
60
- ) ;
61
-
62
- traceOptions . splice ( traceIndex ( 'scatter3d' ) + 1 , 0 , {
63
- label : _ ( '3D Line' ) ,
64
- value : 'line3d' ,
65
- } ) ;
66
-
67
- if ( context . config && context . config . mapboxAccessToken ) {
68
- traceOptions . push ( { value : 'scattermapbox' , label : _ ( 'Satellite Map' ) } ) ;
69
- }
70
-
71
- return traceOptions ;
72
- }
73
-
74
13
class TraceSelector extends Component {
75
14
constructor ( props , context ) {
76
15
super ( props , context ) ;
@@ -140,7 +79,6 @@ class TraceSelector extends Component {
140
79
}
141
80
142
81
updatePlot ( value ) {
143
-
144
82
const { updateContainer} = this . props ;
145
83
if ( updateContainer ) {
146
84
updateContainer ( traceTypeToPlotlyInitFigure ( value ) ) ;
@@ -160,9 +98,7 @@ class TraceSelector extends Component {
160
98
return (
161
99
< div
162
100
className = "trace-type-select-dropdown__wrapper"
163
- onClick = { ( ) =>
164
- this . context . openModal ( TraceTypeSelector , props )
165
- }
101
+ onClick = { ( ) => this . context . openModal ( TraceTypeSelector , props ) }
166
102
>
167
103
< UnconnectedDropdown { ...props } />
168
104
</ div >
0 commit comments