1
1
import * as d3 from 'd3' ;
2
2
3
3
import React , { useEffect , useRef , useState } from 'react' ;
4
- import { select , selectAll } from 'd3-selection' ;
4
+ import PropTypes from 'prop-types' ;
5
+ import { select } from 'd3-selection' ;
5
6
6
7
import { brushX } from 'd3-brush' ;
7
8
@@ -192,21 +193,6 @@ export default function MarecoMultiRange({
192
193
setBrushes ( ( brushes ) => [ ...brushes , ...extensionMapped ] ) ;
193
194
} , [ extensions ] ) ;
194
195
195
- const newBrush = ( qu ) => {
196
- console . log ( 'new Brush' , brushesRef . current ) ;
197
-
198
- const brush = brushX ( )
199
- . extent ( [
200
- [ margin . left , margin . top ] ,
201
- [ viewBoxWidth - margin . right , viewBoxHeight - margin . bottom - 6 ] ,
202
- ] )
203
- . on ( 'start' , brushstart ) // Make sure don't pass surrounding brushes
204
- . on ( 'brush' , brushed ) // Make sure don't pass surrounding brushes
205
- . on ( 'end' , brushend ) ; // Keep track of what brushes is surrounding
206
-
207
- setBrushes ( ( brushes ) => [ ...brushes , { id : brushes . length , brush } ] ) ;
208
- } ;
209
-
210
196
function brushstart ( { sourceEvent } ) {
211
197
// empty for now
212
198
}
@@ -269,6 +255,21 @@ export default function MarecoMultiRange({
269
255
// newBrush(); /// Only on drag mode
270
256
}
271
257
258
+ const newBrush = ( ) => {
259
+ console . log ( 'new Brush' , brushesRef . current ) ;
260
+
261
+ const brush = brushX ( )
262
+ . extent ( [
263
+ [ margin . left , margin . top ] ,
264
+ [ viewBoxWidth - margin . right , viewBoxHeight - margin . bottom - 6 ] ,
265
+ ] )
266
+ . on ( 'start' , brushstart ) // Make sure don't pass surrounding brushes
267
+ . on ( 'brush' , brushed ) // Make sure don't pass surrounding brushes
268
+ . on ( 'end' , brushend ) ; // Keep track of what brushes is surrounding
269
+
270
+ setBrushes ( ( brushes ) => [ ...brushes , { id : brushes . length , brush } ] ) ;
271
+ } ;
272
+
272
273
return (
273
274
< svg
274
275
ref = { ref }
@@ -286,3 +287,9 @@ export default function MarecoMultiRange({
286
287
</ svg >
287
288
) ;
288
289
}
290
+
291
+ MarecoMultiRange . propTypes = {
292
+ stops : PropTypes . array . isRequired ,
293
+ extensions : PropTypes . array . isRequired ,
294
+ setExtensions : PropTypes . func . isRequired ,
295
+ } ;
0 commit comments