Skip to content
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

(WIP) Filter and GroupBy Transforms #859

Closed
wants to merge 9 commits into from

Conversation

timelyportfolio
Copy link
Contributor

@timelyportfolio timelyportfolio commented Aug 16, 2016

This pull makes the filter transform an actual part of Plotly and builds on the very fine transform work by @etpinard. The first filters available will be =, >, <, in, notin, within, notwithin (name changes welcome).

  • add groupby to this pull

@timelyportfolio timelyportfolio changed the title Filter Transforms (WIP) Filter Transforms Aug 17, 2016
@timelyportfolio timelyportfolio changed the title (WIP) Filter Transforms (WIP) Filter and GroupBy Transforms Aug 17, 2016
@etpinard
Copy link
Contributor

@chriddyp would you mind testing this out in the plot.ly workspace?

@@ -129,6 +158,30 @@ function getFilterFunc(opts) {
return function(v) { return v < value; };
case '>':
return function(v) { return v > value; };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this work for datetime strings too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will try to get an example up, but yes it does work with datetime strings. It does not seem to work though with Date and datetime strings.

@chriddyp
Copy link
Member

Nice! This is started to look good. Here's a prototype of this filter transform in Plotly 2:
filter-transforms

Here a few more things that I'll need to be able to integrate this into plotly 2:

  • Date, number, category support with the same auto-type checking that the axes.type: '-' uses
  • Support filtersrc to be an array instead of just trace.x or trace.y. In Plotly 2, this will usually be a column of data that isn't visualized in the plot itself
  • Filtering out nested data arrays. like marker.color or marker.line.color. (Note that this is different than just filtering out all arrays since we don't want to fill out style keys like colorscale)

@etpinard
Copy link
Contributor

@chriddyp

Date, number, category support with the same auto-type checking that the axes.type: '-' uses

Sounds good. I'm thinking the filter functions should respect the (maybe autotyped) axis types for data arrays that have a corresponding axis (e.g. x, y and z in 3D) and otherwise cast everything to numbers.

I'm thinking that the < and > filter for type: 'categories' axes should be determined by the categories order as used internally to map categories to axis values. For example,

var data = [{
  x: ['A', 'B', 'D'],
  transforms: [{
    type: 'filter',
    operation: '>',
    value: 'B'
  }]
}]

Plotly.plot(gd, data);

gd._fullData[0].x   // => ['D']

Support filtersrc to be an array instead of just trace.x or trace.y. In Plotly 2, this will usually be a column of data that isn't visualized in the plot itself

That sounds a bit odd. Why would anyone filter a trace with no x / y data? Do you want to use the filter transform for grids? In that case, you should use the filter module transform method with mock "data" without calling Plotly.plot.

Filtering out nested data arrays. like marker.color or marker.line.color. (Note that this is different than just filtering out all arrays since we don't want to fill out style keys like colorscale)

This one will be easily implemented after @monfera 's #936

@etpinard
Copy link
Contributor

made obsolete by #936

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature something new
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants