11/*********************************************
22
33Scatterplot.js
4+ Version: 1.1.1
45Author : Paul Woidke
56URL : http://www.paulwoidke.com
67
@@ -65,7 +66,7 @@ URL : http://www.paulwoidke.com
6566 backgroundImage : 'linear-gradient(white 2px, transparent 2px), linear-gradient(90deg, white 2px, transparent 2px), linear-gradient(rgba(255,255,255,.4) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.4) 1px, transparent 1px)' ,
6667 backgroundPosition : '-2px -2px, -2px -2px, -1px -1px, -1px -1px'
6768 } ) ;
68-
69+
6970 if ( settings . responsive ) {
7071 chart . css ( {
7172 backgroundSize : colWidth + '% ' + rowHeight + '%,' + colWidth + '% ' + rowHeight + '%,' + ( colWidth / settings . subsections ) + '% ' + ( rowHeight / settings . subsections ) + '%,' + ( colWidth / settings . subsections ) + '% ' + ( rowHeight / settings . subsections ) + '%'
@@ -152,12 +153,14 @@ URL : http://www.paulwoidke.com
152153
153154 return this . each ( function ( ) {
154155
155- var point = $ ( this ) , left = - 1 , bottom = - 1 ;
156+ var point = $ ( this ) ,
157+ left = - 1 ,
158+ bottom = - 1 ;
156159 settings . responsive = point . parent ( ) . hasClass ( 'responsive' ) ;
157160
158161 left = point . css ( 'left' ) ;
159162 bottom = point . css ( 'bottom' ) ;
160-
163+
161164 if ( settings . xPos < 0 ) {
162165 settings . xPos = 0 ;
163166 }
@@ -169,62 +172,92 @@ URL : http://www.paulwoidke.com
169172 }
170173
171174 point . addClass ( 'point' ) ;
175+
176+ if ( point . width ( ) > 0 ) {
177+ settings . radius = point . width ( ) / 2 ;
178+ }
179+ if ( point . css ( 'background-color' ) === settings . color || point . css ( 'background-color' ) === 'transparent' ) {
180+ point . css ( {
181+ backgroundColor : settings . color
182+ } ) ;
183+ }
172184 point . css ( {
173185 width : settings . radius * 2 ,
174186 height : settings . radius * 2 ,
175187 borderRadius : settings . radius
176188 } ) ;
177189
178- if ( point . css ( 'background-color' ) === settings . color || point . css ( 'background-color' ) === 'transparent' ) {
179- point . css ( { backgroundColor : settings . color } ) ;
180- }
181-
182190 if ( settings . responsive ) {
183191 if ( typeof settings . xPos === 'string' || settings . xPos instanceof String ) {
184- if ( settings . xPos . indexOf ( '%' ) != - 1 ) {
185- point . css ( { left : ( ( parseFloat ( settings . xPos ) / 100 ) - ( settings . radius / point . parent ( ) . width ( ) ) ) * 100 + '%' } ) ;
192+ if ( settings . xPos . indexOf ( '%' ) !== - 1 ) {
193+ point . css ( {
194+ left : ( ( parseFloat ( settings . xPos ) / 100 ) - ( settings . radius / point . parent ( ) . width ( ) ) ) * 100 + '%'
195+ } ) ;
186196 } else {
187- point . css ( { left : settings . xPos } ) ;
197+ point . css ( {
198+ left : settings . xPos
199+ } ) ;
188200 }
189201 } else if ( typeof left === 'string' || left instanceof String ) {
190- if ( left . indexOf ( '%' ) != - 1 ) {
191- point . css ( { left : ( ( parseFloat ( left ) / 100 ) - ( settings . radius / point . parent ( ) . width ( ) ) ) * 100 + '%' } ) ;
192- }
193- else {
194- point . css ( { left : left } ) ;
202+ if ( left . indexOf ( '%' ) !== - 1 ) {
203+ point . css ( {
204+ left : ( ( parseFloat ( left ) / 100 ) - ( settings . radius / point . parent ( ) . width ( ) ) ) * 100 + '%'
205+ } ) ;
206+ } else {
207+ point . css ( {
208+ left : left
209+ } ) ;
195210 }
196211 } else {
197- point . css ( { left : settings . xPos } ) ;
212+ point . css ( {
213+ left : settings . xPos
214+ } ) ;
198215 }
199216 if ( typeof settings . yPos === 'string' || settings . yPos instanceof String ) {
200- if ( settings . yPos . indexOf ( '%' ) != - 1 ) {
201- point . css ( { bottom : ( ( parseFloat ( settings . yPos ) / 100 ) - ( settings . radius / point . parent ( ) . width ( ) ) ) * 100 + '%' } ) ;
217+ if ( settings . yPos . indexOf ( '%' ) !== - 1 ) {
218+ point . css ( {
219+ bottom : ( ( parseFloat ( settings . yPos ) / 100 ) - ( settings . radius / point . parent ( ) . width ( ) ) ) * 100 + '%'
220+ } ) ;
202221 } else {
203- point . css ( { bottom : settings . yPos } ) ;
222+ point . css ( {
223+ bottom : settings . yPos
224+ } ) ;
204225 }
205226 } else if ( typeof bottom === 'string' || bottom instanceof String ) {
206- if ( bottom . indexOf ( '%' ) != - 1 ) {
207- point . css ( { bottom : ( ( parseFloat ( bottom ) / 100 ) - ( settings . radius / point . parent ( ) . width ( ) ) ) * 100 + '%' } ) ;
208- }
209- else {
210- point . css ( { bottom : bottom } ) ;
227+ if ( bottom . indexOf ( '%' ) !== - 1 ) {
228+ point . css ( {
229+ bottom : ( ( parseFloat ( bottom ) / 100 ) - ( settings . radius / point . parent ( ) . width ( ) ) ) * 100 + '%'
230+ } ) ;
231+ } else {
232+ point . css ( {
233+ bottom : bottom
234+ } ) ;
211235 }
212236 } else {
213- point . css ( { bottom : settings . yPos } ) ;
237+ point . css ( {
238+ bottom : settings . yPos
239+ } ) ;
214240 }
215241 } else {
216- left = parseInt ( left ) ;
217- bottom = parseInt ( bottom ) ;
218- if ( left != - 1 && ! isNaN ( left ) ) {
219- point . css ( { left : left - settings . radius } ) ;
242+ left = parseInt ( left , 10 ) ;
243+ bottom = parseInt ( bottom , 10 ) ;
244+ if ( left !== - 1 && ! isNaN ( left ) ) {
245+ point . css ( {
246+ left : left - settings . radius
247+ } ) ;
220248 } else {
221- point . css ( { left : settings . xPos - settings . radius } ) ;
222- }
223- if ( bottom != - 1 && ! isNaN ( bottom ) ) {
224- point . css ( { bottom : bottom - settings . radius } ) ;
249+ point . css ( {
250+ left : settings . xPos - settings . radius
251+ } ) ;
225252 }
226- else {
227- point . css ( { bottom : settings . yPos - settings . radius } ) ;
253+ if ( bottom !== - 1 && ! isNaN ( bottom ) ) {
254+ point . css ( {
255+ bottom : bottom - settings . radius
256+ } ) ;
257+ } else {
258+ point . css ( {
259+ bottom : settings . yPos - settings . radius
260+ } ) ;
228261 }
229262 }
230263 } ) ;
0 commit comments