forked from yurukov/dc.leaflet.js
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
393b4cb
commit a27da44
Showing
30 changed files
with
246 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/*! | ||
* dc-addons v0.9.1 | ||
* dc-addons v0.10.0 | ||
* | ||
* 2015-07-31 13:51:20 | ||
* 2015-08-11 08:06:00 | ||
* | ||
*/ | ||
(function () { | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
/*! | ||
* dc-addons v0.10.0 | ||
* | ||
* 2015-08-11 08:06:00 | ||
* | ||
*/ | ||
(function () { | ||
'use strict'; | ||
|
||
var crossfilter = {}; | ||
|
||
//------------------------ | ||
// dimension | ||
//------------------------ | ||
|
||
function _filterChanged () { | ||
var list = dc.chartRegistry.list(); | ||
|
||
for (var e in list) { | ||
var chart = list[e]; | ||
var group = chart.group(); | ||
|
||
if (group) { | ||
group._filterChanged = true; | ||
} | ||
} | ||
} | ||
|
||
crossfilter.dimension = {}; | ||
crossfilter.dimension.filter = _filterChanged; | ||
crossfilter.dimension.filterExact = _filterChanged; | ||
crossfilter.dimension.filterRange = _filterChanged; | ||
crossfilter.dimension.filterFunction = _filterChanged; | ||
crossfilter.dimension.filterAll = _filterChanged; | ||
|
||
//------------------------ | ||
// group | ||
//------------------------ | ||
|
||
function _getFilters () { | ||
var result = {}; | ||
var list = dc.chartRegistry.list(); | ||
|
||
for (var e in list) { | ||
var chart = list[e]; | ||
result[chart.chartID()] = chart.filters(); | ||
} | ||
|
||
return result; | ||
} | ||
|
||
function _fetchData () { | ||
var filters = _getFilters(); | ||
var list = dc.chartRegistry.list(); | ||
|
||
for (var chartId in filters) { | ||
for (var x in list) { | ||
if (list[x].chartID() === parseInt(chartId, 10)) { | ||
var chart = list[x]; | ||
var group = chart.group(); | ||
|
||
if (group && group._filterChanged) { | ||
group._filterChanged = false; | ||
_fetch(group, chart, filters, chartId); | ||
} | ||
break; | ||
} | ||
} | ||
} | ||
} | ||
|
||
function _fetch (group, chart, filters, chartId) { | ||
var dummyGroup = group; | ||
group.fetch(filters, chartId, function (data) { | ||
dummyGroup._currentData = data; | ||
chart.redraw(); | ||
}); | ||
} | ||
|
||
crossfilter.group = function (fetch) { | ||
return { | ||
_filterChanged: true, | ||
_currentData: [], | ||
all: function () { | ||
_fetchData(); | ||
return this._currentData; | ||
}, | ||
top: function (e) { | ||
_fetchData(); | ||
return this._currentData; | ||
}, | ||
fetch: fetch, | ||
}; | ||
}; | ||
|
||
//------------------------ | ||
// quicksort | ||
//------------------------ | ||
|
||
crossfilter.quicksort = {}; | ||
crossfilter.quicksort.by = function (sort) { | ||
return function (data) { | ||
return data; | ||
}; | ||
}; | ||
|
||
window.crossfilterServer = crossfilter; | ||
|
||
if (!window.crossfilter) { | ||
window.crossfilter = crossfilter; | ||
} | ||
})(); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/*! | ||
* dc-addons v0.9.1 | ||
* dc-addons v0.10.0 | ||
* | ||
* 2015-07-31 13:51:20 | ||
* 2015-08-11 08:06:00 | ||
* | ||
*/ | ||
(function () { | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/*! | ||
* dc-addons v0.10.0 | ||
* | ||
* 2015-08-11 08:06:00 | ||
* | ||
*/ | ||
(function () { | ||
'use strict'; | ||
|
||
window.crossfilterServer.elasticSearch = { | ||
filter: function (filters, chartId, query, mapping) { | ||
var q = JSON.parse(JSON.stringify(query)); | ||
|
||
if (!q.hasOwnProperty('query')) { | ||
q.query = {}; | ||
} | ||
|
||
if (!q.query.hasOwnProperty('filtered')) { | ||
q.query.filtered = {}; | ||
} | ||
|
||
if (!q.query.filtered.hasOwnProperty('filter')) { | ||
q.query.filtered.filter = {}; | ||
} | ||
|
||
if (!q.query.filtered.filter.hasOwnProperty('bool')) { | ||
q.query.filtered.filter.bool = {}; | ||
} | ||
|
||
if (!q.query.filtered.filter.bool.hasOwnProperty('must')) { | ||
q.query.filtered.filter.bool.must = []; | ||
} | ||
|
||
for (var f in filters) { | ||
if (f !== chartId && mapping[f]) { | ||
if (filters[f].length > 0) { | ||
var term = {}; | ||
|
||
if (Array.isArray(filters[f][0])) { | ||
term.range = {}; | ||
term.range[mapping[f]] = { | ||
gte: filters[f][0][0] instanceof Date ? d3.time.format('%Y-%m-%d %H:%M:%S')(filters[f][0][0]) : filters[f][0][0], | ||
lte: filters[f][0][1] instanceof Date ? d3.time.format('%Y-%m-%d %H:%M:%S')(filters[f][0][1]) : filters[f][0][1], | ||
}; | ||
q.query.filtered.filter.bool.must.push(term); | ||
} else { | ||
term.terms = {}; | ||
term.terms[mapping[f]] = filters[f]; | ||
q.query.filtered.filter.bool.must.push(term); | ||
} | ||
} | ||
} | ||
} | ||
|
||
return JSON.stringify(q); | ||
}, | ||
|
||
send: function (filters, chartId, url, query, mapping, callback) { | ||
var q = this.filter(filters, chartId, query, mapping); | ||
d3.xhr(url).post(q, function (error, xhr) { | ||
var data = JSON.parse(xhr.responseText); | ||
callback(data); | ||
}); | ||
}, | ||
}; | ||
})(); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/*! | ||
* dc-addons v0.9.1 | ||
* dc-addons v0.10.0 | ||
* | ||
* 2015-07-31 13:51:20 | ||
* 2015-08-11 08:06:00 | ||
* | ||
*/ | ||
(function () { | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/*! | ||
* dc-addons v0.9.1 | ||
* dc-addons v0.10.0 | ||
* | ||
* 2015-07-31 13:51:20 | ||
* 2015-08-11 08:06:00 | ||
* | ||
*/ | ||
(function () { | ||
|
Oops, something went wrong.