-
Notifications
You must be signed in to change notification settings - Fork 4
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
Refactor the data flow inside of Scaler #313
Conversation
2d9d905
to
8b01e76
Compare
[pr-server] |
Clean up the internal data flow inside of the Scaler component. This refactoring had a few main goals: 1. Fully-own the responsibility of providing scaled data downstream alongside the Series and Collection items. 2. Increase performance by using better checks to detect when the incoming Series and Collections objects were externally changed. 3. Stop exposing domainsByItemId / subDomainsByItemId to the downstream rendering components, in deference to Series and Collection objects directly. 4. Get closer toward enabling per-Series timeDomains / timeSubDomains as documented in #301. The end result of this is that the (internal) API has nontrivially changed. Instead of Scaler exposing maps of domainsByItemId and subDomainByItemId, it will simply pass through the series and collections arrays, but they are now all guaranteed to be fully-populated with domain and subDomain information. This means that rendering components can simply render using the timeDomain, timeSubDomain, xDomain, xSubDomain, yDomain, and ySubDomain domains (which are guaranteed to be present) and don't need to concern themselves with how they were populated (user/state, props, calculated from data, or placeholders). This does not yet fully enable separate timeDomain / timeSubdomain throughout the library, but it removes almost all blockers. The final piece to this puzzle is in DataProvider -- it needs to learn a one more trick in order to support this (it currently only knows about one timeSubDomain). That cleanup will be saved for a future PR.
Tweak .bulldozer.yaml to: - Use the PR description & title when merging - Respect [auto-merge] and [auto-update] labels - Response [do-not-merge] and [do-not-update]
I think I'm gonna introduce a final pipeline step
except for domains on collections
Or at least it seems to. Gotta update the storybook.
The step one is broken though
8b01e76
to
64daf7c
Compare
Also strip the empty collections
These aren't needed anymore.
Maybe this is what's going on with Jenkins
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.
Please don't forget to update readme at least about DataProvider
Stories:
Uncaught TypeError: Cannot read property 'priority' of null
at domains.ts:61
at Array.sort (<anonymous>)
at highestPriorityDomain (domains.ts:60)
at index.tsx:367
at Array.map (<anonymous>)
at Scaler._this.getSeriesWithDomains (index.tsx:347)
at Scaler.render (index.tsx:540)
at finishClassComponent (react-dom.development.js:14741)
at updateClassComponent (react-dom.development.js:14696)
at beginWork (react-dom.development.js:15644)
- If to hover over the chart, ruler jumped to the beginning of timeseries
- If to zoom on context chart subdomain should follow the timsereries but currently it is sticky
- http://localhost:9001/?path=/story/linechart-live-loading--limit-time-subdomain
sub domain is not limited
series: IncomingSeries[]; | ||
collections: IncomingCollection[]; | ||
|
||
children: JSX.Element | JSX.Element[]; |
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.
Can't find onFetchData
prop, has it been removed in older versions?
|
||
return ( | ||
<Scaler | ||
timeSubDomainChanged={() => null} |
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 probably missed that but I can't find on how it is used
return domain; | ||
} | ||
return newDomain( | ||
extent[0] - diff * 0.025, |
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 wondering what is the reasoning behind 0.025
, 0.25
, 1e-3
?
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.
This was just a buffer that "seemed right". I don't know the reasoning behind it.
export const placeholder = (min: number, max: number): Domain => | ||
newDomain(min, max, DomainPriority.PLACEHOLDER); | ||
|
||
export const withoutPlaceholder = ( |
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.
It seems everywhere withoutPlaceholder
is used we return placeholder as a default value (i.e. withoutPlaceholder(c.xDomain) || PLACEHOLDER_DOMAIN
), shouldn't it be renamed to something like withPlaceholder
and take in placeholder as an argument?
@@ -1,123 +1,125 @@ | |||
import * as React from 'react'; | |||
import * as PropTypes from 'prop-types'; | |||
import DataContext from '../../context/Data'; |
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.
We should remove unused ../../context/Data
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.
Good catch!
}); | ||
} | ||
|
||
getLoaderReason = (series: ScaledSeries) => { |
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 see INTERVAL
and UPDATE_POINTS_PER_SERIES
have they been replaced or obsolete with a newer logic?
<DataProvider | ||
defaultLoader={liveLoader} | ||
<Griff | ||
loader={liveLoader} |
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 believe entire functionality about isTimeSubDomainSticky
is gone
Thanks for the review, @valerii-cognite ! I've gone ahead and updated the README and addressed some of the comments -- I'll continue to work on the others. |
Clean up the internal data flow inside of the Scaler component. This
refactoring had a few main goals:
alongside the Series and Collection items.
incoming Series and Collections objects were externally changed.
domainsByItemId
/subDomainsByItemId
to thedownstream rendering components, in deference to Series and
Collection objects directly.
timeDomains
/timeSubDomains
as documented in Add possibility to have more than one time domains #301.
The end result of this is that the (internal) API has nontrivially
changed. Instead of Scaler exposing maps of
domainsByItemId
andsubDomainByItemId
, it will simply pass through theseries
andcollections
arrays, but they are now all guaranteed to befully-populated with domain and subDomain information. This means that
rendering components can simply render using the
timeDomain
,timeSubDomain
,xDomain
,xSubDomain
,yDomain
, andySubDomain
domains(which are guaranteed to be present) and don't need to concern
themselves with how they were populated (user/state, props, calculated
from data, or placeholders).
This does not yet fully enable separate
timeDomain
/timeSubdomain
throughout the library, but it removes almost all blockers. The final
piece to this puzzle is in
DataProvider
-- it needs to learn a one moretrick in order to support this (it currently only knows about one
timeSubDomain
). That cleanup will be saved for a future PR.