@@ -30,7 +30,6 @@ var svgSdf = require('svg-path-sdf');
30
30
var createRegl = require ( 'regl' ) ;
31
31
var fillHoverText = require ( '../scatter/fill_hover_text' ) ;
32
32
var isNumeric = require ( 'fast-isnumeric' ) ;
33
- var Scatter = require ( '../scatter' ) ;
34
33
35
34
var MAXDIST = Fx . constants . MAXDIST ;
36
35
var SYMBOL_SDF_SIZE = 200 ;
@@ -41,27 +40,7 @@ var SYMBOL_SVG_CIRCLE = Drawing.symbolFuncs[0](SYMBOL_SIZE * 0.05);
41
40
var TOO_MANY_POINTS = 1e5 ;
42
41
var DOT_RE = / - d o t / ;
43
42
44
-
45
- var ScatterGl = module . exports = { } ;
46
-
47
- ScatterGl . name = 'scattergl' ;
48
- ScatterGl . categories = [ 'gl' , 'regl' , 'cartesian' , 'symbols' , 'errorBarsOK' , 'markerColorscale' , 'showLegend' , 'scatter-like' ] ;
49
- ScatterGl . attributes = require ( './attributes' ) ;
50
- ScatterGl . supplyDefaults = require ( './defaults' ) ;
51
- ScatterGl . cleanData = Scatter . cleanData ;
52
- ScatterGl . arraysToCalcdata = Scatter . arraysToCalcdata ;
53
- ScatterGl . colorbar = Scatter . colorbar ;
54
- ScatterGl . meta = Scatter . meta ;
55
- ScatterGl . animatable = true ;
56
- ScatterGl . hasLines = subTypes . hasLines ;
57
- ScatterGl . hasMarkers = subTypes . hasMarkers ;
58
- ScatterGl . hasText = subTypes . hasText ;
59
- ScatterGl . isBubble = subTypes . isBubble ;
60
- ScatterGl . moduleType = 'trace' ;
61
- ScatterGl . basePlotModule = require ( '../../plots/cartesian' ) ;
62
-
63
-
64
- ScatterGl . calc = function calc ( container , trace ) {
43
+ function calc ( container , trace ) {
65
44
var layout = container . _fullLayout ;
66
45
var positions ;
67
46
var stash = { } ;
@@ -146,7 +125,7 @@ ScatterGl.calc = function calc(container, trace) {
146
125
147
126
calcColorscales ( trace ) ;
148
127
149
- var options = ScatterGl . sceneOptions ( container , subplot , trace , positions ) ;
128
+ var options = sceneOptions ( container , subplot , trace , positions ) ;
150
129
151
130
// expanding axes is separate from options
152
131
if ( ! options . markers ) {
@@ -195,7 +174,7 @@ ScatterGl.calc = function calc(container, trace) {
195
174
}
196
175
197
176
// create scene
198
- var scene = ScatterGl . scene ( container , subplot ) ;
177
+ var scene = sceneUpdate ( container , subplot ) ;
199
178
200
179
// set flags to create scene renderers
201
180
if ( options . fill && ! scene . fill2d ) scene . fill2d = true ;
@@ -224,11 +203,10 @@ ScatterGl.calc = function calc(container, trace) {
224
203
stash . count = count ;
225
204
226
205
return [ { x : false , y : false , t : stash , trace : trace } ] ;
227
- } ;
228
-
206
+ }
229
207
230
208
// create scene options
231
- ScatterGl . sceneOptions = function sceneOptions ( container , subplot , trace , positions ) {
209
+ function sceneOptions ( container , subplot , trace , positions ) {
232
210
var layout = container . _fullLayout ;
233
211
var count = positions . length / 2 ;
234
212
var markerOpts = trace . marker ;
@@ -540,11 +518,10 @@ ScatterGl.sceneOptions = function sceneOptions(container, subplot, trace, positi
540
518
selected : selectedOptions ,
541
519
unselected : unselectedOptions
542
520
} ;
543
- } ;
544
-
521
+ }
545
522
546
523
// make sure scene exists on subplot, return it
547
- ScatterGl . scene = function getScene ( container , subplot ) {
524
+ function sceneUpdate ( container , subplot ) {
548
525
var scene = subplot . _scene ;
549
526
var layout = container . _fullLayout ;
550
527
@@ -707,8 +684,7 @@ ScatterGl.scene = function getScene(container, subplot) {
707
684
}
708
685
709
686
return scene ;
710
- } ;
711
-
687
+ }
712
688
713
689
function getSymbolSdf ( symbol ) {
714
690
if ( symbol === 'circle' ) return null ;
@@ -742,8 +718,7 @@ function getSymbolSdf(symbol) {
742
718
return symbolSdf || null ;
743
719
}
744
720
745
-
746
- ScatterGl . plot = function plot ( container , subplot , cdata ) {
721
+ function plot ( container , subplot , cdata ) {
747
722
if ( ! cdata . length ) return ;
748
723
749
724
var layout = container . _fullLayout ;
@@ -1006,10 +981,9 @@ ScatterGl.plot = function plot(container, subplot, cdata) {
1006
981
scene . draw ( ) ;
1007
982
1008
983
return ;
1009
- } ;
1010
-
984
+ }
1011
985
1012
- ScatterGl . hoverPoints = function hover ( pointData , xval , yval , hovermode ) {
986
+ function hoverPoints ( pointData , xval , yval , hovermode ) {
1013
987
var cd = pointData . cd ,
1014
988
stash = cd [ 0 ] . t ,
1015
989
trace = cd [ 0 ] . trace ,
@@ -1157,10 +1131,9 @@ ScatterGl.hoverPoints = function hover(pointData, xval, yval, hovermode) {
1157
1131
ErrorBars . hoverInfo ( di , trace , pointData ) ;
1158
1132
1159
1133
return [ pointData ] ;
1160
- } ;
1161
-
1134
+ }
1162
1135
1163
- ScatterGl . selectPoints = function select ( searchInfo , polygon ) {
1136
+ function selectPoints ( searchInfo , polygon ) {
1164
1137
var cd = searchInfo . cd ,
1165
1138
selection = [ ] ,
1166
1139
trace = cd [ 0 ] . trace ,
@@ -1213,14 +1186,43 @@ ScatterGl.selectPoints = function select(searchInfo, polygon) {
1213
1186
scene . unselectBatch [ stash . index ] = unels ;
1214
1187
1215
1188
return selection ;
1216
- } ;
1217
-
1189
+ }
1218
1190
1219
- ScatterGl . style = function style ( gd , cd ) {
1191
+ function style ( gd , cd ) {
1220
1192
if ( cd ) {
1221
1193
var stash = cd [ 0 ] . t ;
1222
1194
var scene = stash . scene ;
1223
1195
scene . clear ( ) ;
1224
1196
scene . draw ( ) ;
1225
1197
}
1198
+ }
1199
+
1200
+ module . exports = {
1201
+ moduleType : 'trace' ,
1202
+ name : 'scattergl' ,
1203
+ basePlotModule : require ( '../../plots/cartesian' ) ,
1204
+ categories : [ 'gl' , 'regl' , 'cartesian' , 'symbols' , 'errorBarsOK' , 'markerColorscale' , 'showLegend' , 'scatter-like' ] ,
1205
+
1206
+ attributes : require ( './attributes' ) ,
1207
+ supplyDefaults : require ( './defaults' ) ,
1208
+ cleanData : require ( '../scatter/clean_data' ) ,
1209
+ colorbar : require ( '../scatter/colorbar' ) ,
1210
+ calc : calc ,
1211
+ plot : plot ,
1212
+ hoverPoints : hoverPoints ,
1213
+ style : style ,
1214
+ selectPoints : selectPoints ,
1215
+
1216
+ sceneOptions : sceneOptions ,
1217
+ sceneUpdate : sceneUpdate ,
1218
+
1219
+ meta : {
1220
+ hrName : 'scatter_gl' ,
1221
+ description : [
1222
+ 'The data visualized as scatter point or lines is set in `x` and `y`' ,
1223
+ 'using the WebGL plotting engine.' ,
1224
+ 'Bubble charts are achieved by setting `marker.size` and/or `marker.color`' ,
1225
+ 'to a numerical arrays.'
1226
+ ] . join ( ' ' )
1227
+ }
1226
1228
} ;
0 commit comments