@@ -53,8 +53,20 @@ var minicharts_d3fns_date = function() {
53
53
. on ( 'brush' , brushed )
54
54
. on ( 'brushend' , brushend ) ;
55
55
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
+
56
67
function brushed ( ) {
57
68
var lines = d3 . selectAll ( options . view . queryAll ( '.selectable' ) ) ;
69
+ var numSelected = options . view . queryAll ( '.selectable.selected' ) . length ;
58
70
var s = brush . extent ( ) ;
59
71
60
72
lines . classed ( 'selected' , function ( d ) {
@@ -64,6 +76,15 @@ var minicharts_d3fns_date = function() {
64
76
var pos = barcodeX ( d . dt ) ;
65
77
return s [ 0 ] > pos || pos > s [ 1 ] ;
66
78
} ) ;
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
+ }
67
88
}
68
89
69
90
function brushend ( ) {
@@ -81,7 +102,6 @@ var minicharts_d3fns_date = function() {
81
102
} ;
82
103
options . view . trigger ( 'querybuilder' , evt ) ;
83
104
}
84
- // --- end chart setup ---
85
105
var handleClick = function ( d ) {
86
106
var evt = {
87
107
d : d ,
0 commit comments