Skip to content

Commit

Permalink
real-time query builder updates for date/objectid
Browse files Browse the repository at this point in the history
  • Loading branch information
rueckstiess committed Aug 20, 2015
1 parent 1d5a1aa commit 9289b3a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
22 changes: 21 additions & 1 deletion src/minicharts/d3fns/date.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,20 @@ var minicharts_d3fns_date = function() {
.on('brush', brushed)
.on('brushend', brushend);

function brushstart(clickedLine) {
// remove selections and half selections
var lines = d3.selectAll(options.view.queryAll('.selectable'));
lines.classed('selected', function() {
return this === clickedLine;
});
lines.classed('unselected', function() {
return this !== clickedLine;
});
}

function brushed() {
var lines = d3.selectAll(options.view.queryAll('.selectable'));
var numSelected = options.view.queryAll('.selectable.selected').length;
var s = brush.extent();

lines.classed('selected', function(d) {
Expand All @@ -64,6 +76,15 @@ var minicharts_d3fns_date = function() {
var pos = barcodeX(d.dt);
return s[0] > pos || pos > s[1];
});
if (!options.view) return;
if (numSelected !== options.view.queryAll('.selectable.selected').length) {
// number of selected items has changed, trigger querybuilder event
var evt = {
type: 'drag',
source: 'date'
};
options.view.trigger('querybuilder', evt);
}
}

function brushend() {
Expand All @@ -81,7 +102,6 @@ var minicharts_d3fns_date = function() {
};
options.view.trigger('querybuilder', evt);
}
// --- end chart setup ---
var handleClick = function(d) {
var evt = {
d: d,
Expand Down
5 changes: 1 addition & 4 deletions src/minicharts/d3fns/many.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ var $ = require('jquery');
var _ = require('lodash');
var tooltipHtml = require('./tooltip.jade');
var shared = require('./shared');
var debug = require('debug')('scout:minicharts:many');
// var debug = require('debug')('scout:minicharts:many');

require('../d3-tip')(d3);

Expand Down Expand Up @@ -285,9 +285,6 @@ var minicharts_d3fns_many = function() {
.attr('height', height)
.on('mouseover', tip.show)
.on('mouseout', tip.hide);
// @note currently the bgbars are only use for the day/week and hour/day charts.
// they don't support query building anyway.
// .on('mousedown', handleMouseDown)
} else {
// ... or attach tooltips directly to foreground bars if we don't use background bars
barEnter.selectAll('.fg')
Expand Down

0 comments on commit 9289b3a

Please sign in to comment.