@@ -30,7 +30,6 @@ var svgSdf = require('svg-path-sdf');
3030var createRegl = require ( 'regl' ) ;
3131var fillHoverText = require ( '../scatter/fill_hover_text' ) ;
3232var isNumeric = require ( 'fast-isnumeric' ) ;
33- var Scatter = require ( '../scatter' ) ;
3433
3534var MAXDIST = Fx . constants . MAXDIST ;
3635var SYMBOL_SDF_SIZE = 200 ;
@@ -41,27 +40,7 @@ var SYMBOL_SVG_CIRCLE = Drawing.symbolFuncs[0](SYMBOL_SIZE * 0.05);
4140var TOO_MANY_POINTS = 1e5 ;
4241var DOT_RE = / - d o t / ;
4342
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 ) {
6544 var layout = container . _fullLayout ;
6645 var positions ;
6746 var stash = { } ;
@@ -146,7 +125,7 @@ ScatterGl.calc = function calc(container, trace) {
146125
147126 calcColorscales ( trace ) ;
148127
149- var options = ScatterGl . sceneOptions ( container , subplot , trace , positions ) ;
128+ var options = sceneOptions ( container , subplot , trace , positions ) ;
150129
151130 // expanding axes is separate from options
152131 if ( ! options . markers ) {
@@ -195,7 +174,7 @@ ScatterGl.calc = function calc(container, trace) {
195174 }
196175
197176 // create scene
198- var scene = ScatterGl . scene ( container , subplot ) ;
177+ var scene = sceneUpdate ( container , subplot ) ;
199178
200179 // set flags to create scene renderers
201180 if ( options . fill && ! scene . fill2d ) scene . fill2d = true ;
@@ -224,11 +203,10 @@ ScatterGl.calc = function calc(container, trace) {
224203 stash . count = count ;
225204
226205 return [ { x : false , y : false , t : stash , trace : trace } ] ;
227- } ;
228-
206+ }
229207
230208// create scene options
231- ScatterGl . sceneOptions = function sceneOptions ( container , subplot , trace , positions ) {
209+ function sceneOptions ( container , subplot , trace , positions ) {
232210 var layout = container . _fullLayout ;
233211 var count = positions . length / 2 ;
234212 var markerOpts = trace . marker ;
@@ -540,11 +518,10 @@ ScatterGl.sceneOptions = function sceneOptions(container, subplot, trace, positi
540518 selected : selectedOptions ,
541519 unselected : unselectedOptions
542520 } ;
543- } ;
544-
521+ }
545522
546523// make sure scene exists on subplot, return it
547- ScatterGl . scene = function getScene ( container , subplot ) {
524+ function sceneUpdate ( container , subplot ) {
548525 var scene = subplot . _scene ;
549526 var layout = container . _fullLayout ;
550527
@@ -707,8 +684,7 @@ ScatterGl.scene = function getScene(container, subplot) {
707684 }
708685
709686 return scene ;
710- } ;
711-
687+ }
712688
713689function getSymbolSdf ( symbol ) {
714690 if ( symbol === 'circle' ) return null ;
@@ -742,8 +718,7 @@ function getSymbolSdf(symbol) {
742718 return symbolSdf || null ;
743719}
744720
745-
746- ScatterGl . plot = function plot ( container , subplot , cdata ) {
721+ function plot ( container , subplot , cdata ) {
747722 if ( ! cdata . length ) return ;
748723
749724 var layout = container . _fullLayout ;
@@ -1006,10 +981,9 @@ ScatterGl.plot = function plot(container, subplot, cdata) {
1006981 scene . draw ( ) ;
1007982
1008983 return ;
1009- } ;
1010-
984+ }
1011985
1012- ScatterGl . hoverPoints = function hover ( pointData , xval , yval , hovermode ) {
986+ function hoverPoints ( pointData , xval , yval , hovermode ) {
1013987 var cd = pointData . cd ,
1014988 stash = cd [ 0 ] . t ,
1015989 trace = cd [ 0 ] . trace ,
@@ -1157,10 +1131,9 @@ ScatterGl.hoverPoints = function hover(pointData, xval, yval, hovermode) {
11571131 ErrorBars . hoverInfo ( di , trace , pointData ) ;
11581132
11591133 return [ pointData ] ;
1160- } ;
1161-
1134+ }
11621135
1163- ScatterGl . selectPoints = function select ( searchInfo , polygon ) {
1136+ function selectPoints ( searchInfo , polygon ) {
11641137 var cd = searchInfo . cd ,
11651138 selection = [ ] ,
11661139 trace = cd [ 0 ] . trace ,
@@ -1213,14 +1186,43 @@ ScatterGl.selectPoints = function select(searchInfo, polygon) {
12131186 scene . unselectBatch [ stash . index ] = unels ;
12141187
12151188 return selection ;
1216- } ;
1217-
1189+ }
12181190
1219- ScatterGl . style = function style ( gd , cd ) {
1191+ function style ( gd , cd ) {
12201192 if ( cd ) {
12211193 var stash = cd [ 0 ] . t ;
12221194 var scene = stash . scene ;
12231195 scene . clear ( ) ;
12241196 scene . draw ( ) ;
12251197 }
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+ }
12261228} ;
0 commit comments