-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Filters #42
Filters #42
Conversation
@@ -3,6 +3,7 @@ var cartodb = global.cartodb || {}; | |||
var carto = global.carto || require('carto'); | |||
var _ = global._ || require('underscore'); | |||
var geo = require("./geo"); | |||
var Filter = require("./filter"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand why the Filter is part of the renderer, and why is renderer responsible of adding tiles to the Filter. I'd expect someone listening to the "tileAdded" event to load the data into an object where you can add filters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For me it's a bit strange as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The layer (CartoDBd3Layer
) receives a geojson tile that contains/can contain several layers, each one of which is represented by a renderer. Keeping that in mind, would it be better to create a new class, called something along the lines of sublayer
, and restrict the functions of the renderer to generating the svgs?
I've been looking into this a bit and I still don't quite get the concept of Filter and Expressions. Perhaps it's because of the naming... I would expect to have an object where you could add filters and query for the stuff we need for widgets. Here's some pseudocode (I called this object datasource but it could be whatever makes sense)
|
@alonsogarciapablo right now I'm focusing more on the logic of the widgets themselves, but here's the way I'm seeing it:
filter.addExpression("category_de_pepito", {
type: "aggregation",
column: "sov_a3",
aggregation: "count",
sync: true
});
filter.update();
// will update the this.report object, and return:
{
"category_de_pepito": {
"count": 2722,
"nulls": 0,
"min": 1,
"max": 145,
"categoriesCount": 136,
"categories": [
{
"category": "RUS",
"value": 145,
"agg": false
}, // [...]
],
"type": "aggregation"
}
}
|
I think the abstraction level for that api is higher than expected. I'd expect something like: for filtering:
and to fetch data:
|
OK so now the @rochoa @alonsogarciapablo this is ready to merge my side. |
function Filter(){ | ||
this.crossfilter = new Crossfilter(); | ||
this.dimensions = {}; | ||
this.tiles = new Set(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Set is a ES6 feature. We need another approach or a polyfill.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👌 just changed this, it was supposed to be a temporary use. Replaced it with a normal JS object.
As per previous comments I was expecting to have the filtering at layer level, but probably I'm missing something here. Having some kind of integration test would help a lot to understand the layer high level API. |
} | ||
|
||
WindshaftProvider.prototype = { | ||
initialize: function(){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why don't we have this in the constructor? Is there any other way to use initialize apart from being called from the constructor?
|
||
}, | ||
|
||
filterReject: function(column, terms){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All filter* functions are quite similar. Wouldn't be better to have a generic filter function that receives the actual filter function and applies it by column?
Or even better, having different filter entities with a common interface that can be applied. Having different functions for different types of filters means that we need as many public functions as filters we want to have.
I'm still missing some tests or examples displaying how the layer/high level API is. |
No description provided.