@@ -53,8 +53,20 @@ var minicharts_d3fns_date = function() {
5353 . on ( 'brush' , brushed )
5454 . on ( 'brushend' , brushend ) ;
5555
56+ function brushstart ( clickedLine ) {
57+ // remove selections and half selections
58+ var lines = d3 . selectAll ( options . view . queryAll ( '.selectable' ) ) ;
59+ lines . classed ( 'selected' , function ( ) {
60+ return this === clickedLine ;
61+ } ) ;
62+ lines . classed ( 'unselected' , function ( ) {
63+ return this !== clickedLine ;
64+ } ) ;
65+ }
66+
5667 function brushed ( ) {
5768 var lines = d3 . selectAll ( options . view . queryAll ( '.selectable' ) ) ;
69+ var numSelected = options . view . queryAll ( '.selectable.selected' ) . length ;
5870 var s = brush . extent ( ) ;
5971
6072 lines . classed ( 'selected' , function ( d ) {
@@ -64,6 +76,15 @@ var minicharts_d3fns_date = function() {
6476 var pos = barcodeX ( d . dt ) ;
6577 return s [ 0 ] > pos || pos > s [ 1 ] ;
6678 } ) ;
79+ if ( ! options . view ) return ;
80+ if ( numSelected !== options . view . queryAll ( '.selectable.selected' ) . length ) {
81+ // number of selected items has changed, trigger querybuilder event
82+ var evt = {
83+ type : 'drag' ,
84+ source : 'date'
85+ } ;
86+ options . view . trigger ( 'querybuilder' , evt ) ;
87+ }
6788 }
6889
6990 function brushend ( ) {
@@ -81,7 +102,6 @@ var minicharts_d3fns_date = function() {
81102 } ;
82103 options . view . trigger ( 'querybuilder' , evt ) ;
83104 }
84- // --- end chart setup ---
85105 var handleClick = function ( d ) {
86106 var evt = {
87107 d : d ,
0 commit comments