11'use strict' ;
22
3- var DatasetController = require ( '../core/core.datasetController' ) ;
4- var defaults = require ( '../core/core.defaults' ) ;
5- var elements = require ( '../elements/index' ) ;
6- var helpers = require ( '../helpers/index' ) ;
3+ const DatasetController = require ( '../core/core.datasetController' ) ;
4+ const defaults = require ( '../core/core.defaults' ) ;
5+ const elements = require ( '../elements/index' ) ;
6+ const helpers = require ( '../helpers/index' ) ;
77
8- var valueOrDefault = helpers . valueOrDefault ;
9- var resolve = helpers . options . resolve ;
8+ const resolve = helpers . options . resolve ;
109
1110defaults . _set ( 'bubble' , {
11+ animation : {
12+ numbers : {
13+ properties : [ 'x' , 'y' , 'borderWidth' , 'radius' ]
14+ }
15+ } ,
1216 scales : {
1317 x : {
1418 type : 'linear' ,
@@ -43,11 +47,8 @@ module.exports = DatasetController.extend({
4347 'backgroundColor' ,
4448 'borderColor' ,
4549 'borderWidth' ,
46- 'hoverBackgroundColor' ,
47- 'hoverBorderColor' ,
48- 'hoverBorderWidth' ,
49- 'hoverRadius' ,
5050 'hitRadius' ,
51+ 'radius' ,
5152 'pointStyle' ,
5253 'rotation'
5354 ] ,
@@ -77,15 +78,14 @@ module.exports = DatasetController.extend({
7778 * @private
7879 */
7980 _getMaxOverflow : function ( ) {
80- var me = this ;
81- var meta = me . _cachedMeta ;
82- var data = meta . data || [ ] ;
83- if ( ! data . length ) {
84- return false ;
81+ const me = this ;
82+ const meta = me . _cachedMeta ;
83+ let i = ( meta . data || [ ] ) . length - 1 ;
84+ let max = 0 ;
85+ for ( ; i >= 0 ; -- i ) {
86+ max = Math . max ( max , me . getStyle ( i , true ) . radius ) ;
8587 }
86- var firstPoint = data [ 0 ] . size ( ) ;
87- var lastPoint = data [ data . length - 1 ] . size ( ) ;
88- return Math . max ( firstPoint , lastPoint ) / 2 ;
88+ return max > 0 && max ;
8989 } ,
9090
9191 /**
@@ -109,72 +109,56 @@ module.exports = DatasetController.extend({
109109 /**
110110 * @protected
111111 */
112- update : function ( reset ) {
112+ update : function ( mode ) {
113113 const me = this ;
114114 const points = me . _cachedMeta . data ;
115115
116116 // Update Points
117- me . updateElements ( points , 0 , points . length , reset ) ;
117+ me . updateElements ( points , 0 , points . length , mode ) ;
118118 } ,
119119
120120 /**
121121 * @protected
122122 */
123- updateElements : function ( points , start , count , reset ) {
123+ updateElements : function ( points , start , count , mode ) {
124124 const me = this ;
125+ const reset = mode === 'reset' ;
125126 const { xScale, yScale} = me . _cachedMeta ;
127+ const firstOpts = me . _resolveDataElementOptions ( start , mode ) ;
128+ const sharedOptions = me . _getSharedOptions ( mode , points [ start ] , firstOpts ) ;
129+ const includeOptions = me . _includeOptions ( mode , sharedOptions ) ;
126130 let i ;
127131
128132 for ( i = start ; i < start + count ; i ++ ) {
129133 const point = points [ i ] ;
130- const options = me . _resolveDataElementOptions ( i ) ;
131134 const parsed = ! reset && me . _getParsed ( i ) ;
132135 const x = reset ? xScale . getPixelForDecimal ( 0.5 ) : xScale . getPixelForValue ( parsed [ xScale . id ] ) ;
133136 const y = reset ? yScale . getBasePixel ( ) : yScale . getPixelForValue ( parsed [ yScale . id ] ) ;
134-
135- point . _options = options ;
136- point . _model = {
137- backgroundColor : options . backgroundColor ,
138- borderColor : options . borderColor ,
139- borderWidth : options . borderWidth ,
140- hitRadius : options . hitRadius ,
141- pointStyle : options . pointStyle ,
142- rotation : options . rotation ,
143- radius : reset ? 0 : options . radius ,
144- skip : isNaN ( x ) || isNaN ( y ) ,
145- x : x ,
146- y : y ,
137+ const properties = {
138+ x,
139+ y,
140+ skip : isNaN ( x ) || isNaN ( y )
147141 } ;
148142
149- point . pivot ( me . chart . _animationsDisabled ) ;
150- }
151- } ,
143+ if ( includeOptions ) {
144+ properties . options = i === start ? firstOpts
145+ : me . _resolveDataElementOptions ( i , mode ) ;
152146
153- /**
154- * @protected
155- */
156- setHoverStyle : function ( point ) {
157- var model = point . _model ;
158- var options = point . _options ;
159- var getHoverColor = helpers . getHoverColor ;
160-
161- point . $previousStyle = {
162- backgroundColor : model . backgroundColor ,
163- borderColor : model . borderColor ,
164- borderWidth : model . borderWidth ,
165- radius : model . radius
166- } ;
147+ if ( reset ) {
148+ properties . options . radius = 0 ;
149+ }
150+ }
167151
168- model . backgroundColor = valueOrDefault ( options . hoverBackgroundColor , getHoverColor ( options . backgroundColor ) ) ;
169- model . borderColor = valueOrDefault ( options . hoverBorderColor , getHoverColor ( options . borderColor ) ) ;
170- model . borderWidth = valueOrDefault ( options . hoverBorderWidth , options . borderWidth ) ;
171- model . radius = options . radius + options . hoverRadius ;
152+ me . _updateElement ( point , i , properties , mode ) ;
153+ }
154+
155+ me . _updateSharedOptions ( sharedOptions , mode ) ;
172156 } ,
173157
174158 /**
175159 * @private
176160 */
177- _resolveDataElementOptions : function ( index ) {
161+ _resolveDataElementOptions : function ( index , mode ) {
178162 var me = this ;
179163 var chart = me . chart ;
180164 var dataset = me . getDataset ( ) ;
@@ -190,12 +174,16 @@ module.exports = DatasetController.extend({
190174 } ;
191175
192176 // In case values were cached (and thus frozen), we need to clone the values
193- if ( me . _cachedDataOpts === values ) {
194- values = helpers . extend ( { } , values ) ;
177+ if ( values . $shared ) {
178+ values = helpers . extend ( { } , values , { $shared : false } ) ;
195179 }
196180
181+
197182 // Custom radius resolution
198- values . radius = resolve ( [
183+ if ( mode !== 'active' ) {
184+ values . radius = 0 ;
185+ }
186+ values . radius += resolve ( [
199187 parsed && parsed . _custom ,
200188 me . _config . radius ,
201189 chart . options . elements . point . radius
0 commit comments