-
Notifications
You must be signed in to change notification settings - Fork 221
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
Implement Data.KeyFunction #2870
Conversation
This reverts commit e0f25c6.
# Conflicts: # plottable.d.ts
# Conflicts: # plottable.d.ts
# Conflicts: # plottable.d.ts
# Conflicts: # plottable.d.ts
Can you edit your pull request description to reference the other pull request and vice versa? After that, we can close the other pull request, and we can continue discussion here. |
Feel free to copy paste the original pull request description here as well. Specify what exactly this pull request brings to the table (if it's nothing at all from user-perspective, then mention this). |
I just pushed in the changes for our Gruntfile. Can you check to see if this helps? |
# Conflicts: # plottable.d.ts # plottable.js
Whoops, it seems that I missed something. @softwords can you look into my comment? After you follow up, feel free to proceed with your next pull request. |
Hey @softwords, I just wanna say sorry for the holdup, I was pretty busy at the end of last week. I'm going to take a look at this now :) |
Testing Fiddles Plot Types: Axis Types: Data stuff: edit: just kidding! apparently this is mostly a regression pass. |
Hi @softwords, In this fiddle, I'm using the rankcolor function that you had written (with some tweaks), and there's something I'm confused about. rankColor uses the index to color bars. It seems to work correctly when there is no object constancy or when it's joined on the index, but I'm seeing something I don't expect when object constancy is enabled. But when I press the "2010" button, the blues and purples get mixed up: I would expect the fill function, rankColor, to just be based on the index, but it seems like something else is going on. Can you explain that? |
adding on to last comment: on this branch: I don't want to QE +1 this until I understand what's happening, but this is the only thing i've found so far. regression pass looks good. |
Looked into your JSFiddle @crmorford and I found why there is an inconsistency (which seems to me that we should ship with the index constancy which I believe keeps the default behavior). It has to do with how D3 does its enter/exit selections in accordance with the data. Unless I'm mistaken, let's say I have an array |
The realization that the "same" datum maintains their index across changing data is something that caught us off guard, but it makes sense after a bunch of discussion. We're going to need some time to think about think specific realization, but we should come up with an answer soon. |
Ok, this looks good for now. I think it'll be far easier to test intensively when the next PR comes in, and I don't see it causing any problems with existing use cases. |
@softwords We are awaiting your next pull request! |
@bluong I was just replying to @crmorford when the merge came through, so I am overtaken by the speed of events! |
hello @crmorford, rankColor = function (d) {
if (d.R == 1) return "#FF0000";
if (d.R == 2) return "#FFA500";
if (d.R <= 4) return "#FFFF00";
if (d.R <= 8) return "#00FF00";
if (d.R <= 16) return "#0000FF";
return "#FF00FF";
} then it works as you would expect. rankColor = function (d, i) {
if (d.R - 1 === i) return "#FF0000";
return "#FF00FF";
} demonstrates this is not so when constancy is on. |
@softwords , I am mainly curious in your approach regarding the |
@bluong @crmorford I have been putting together these notes explaining what is in my next PR from branch 'DrawingTarget'. (within 24 hours) DrawingTarget A key change in this PR is to expose the D3 "enter / update / exit" pattern to the animators. animate(selection: d3.Selection<any>|d3.Transition<any>, attrToAppliedProjector: AttributeToAppliedProjector,
drawingTarget?: Drawers.DrawingTarget, drawer?: Drawer): d3.Selection<any> | d3.Transition<any>; Note that _bindSelectionData no longer calls Initializer Usually, in the d3 "enter update exit" pattern, there is some initialization of attributes when the
Responsibilities of Animators Animators now get a lot of opportunities to work in detail with the "enter update exit" pattern, and in particular, to apply transitions to the drawingTarget.enter = this.getTransition(drawingTarget.enter, 1000); The point of this is that a subsequent transition derived from Easing Functions This PR introduces some custom easing functions: Animator Hierarchy There are a number of new animator classes: Legacy behaviour Current animation resets all elements to a "start" state, and animates them back to their final state. To get this to happen in the new architecture, the Quicktests See the animation.html in the quicktests/overlay folder. Click on any of these animations to toggle between two datasets. The data items in these datasets have a function.prototype.bind To maintain //# sourceURL The new quicktests use the annotation |
Resubmitted against objectConstancy branch - previously #2833
also see issue #2512
This pull request
adds the key function to Dataset
uses this key in Drawer when binding data to the selection
provides 2 predefined keys:
-- NoConstancy - which will return a new value each time it is called, therefore ensuring that there is never object constancy; that is, all elements in the selection are removed and recreated
-- useIndex - returns the index of the datum n the array, which is the default behaviour of d3 anyway
This PR provides a necessary foundation for developing animations in plottable that respect "object constancy" - proving visual representation of elements moving, entering or exiting the datasets being plotted.