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

Refactor the data flow inside of Scaler #313

Closed
wants to merge 85 commits into from
Closed

Conversation

evancharlton
Copy link
Contributor

@evancharlton evancharlton commented May 30, 2019

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 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 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.

@evancharlton evancharlton requested a review from valgussev May 30, 2019 11:42
@evancharlton evancharlton force-pushed the scaler-flow branch 3 times, most recently from 2d9d905 to 8b01e76 Compare May 30, 2019 19:27
@cognite-cicd
Copy link

[pr-server]
The storybook for this PR is hosted on https://griff-react-pr-313.surge.sh

Evan Charlton added 25 commits May 30, 2019 21:41
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
Copy link
Contributor

@valgussev valgussev left a 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)
  1. If to hover over the chart, ruler jumped to the beginning of timeseries
  2. If to zoom on context chart subdomain should follow the timsereries but currently it is sticky

src/components/XAxis/index.tsx Outdated Show resolved Hide resolved
series: IncomingSeries[];
collections: IncomingCollection[];

children: JSX.Element | JSX.Element[];
Copy link
Contributor

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}
Copy link
Contributor

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,
Copy link
Contributor

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?

Copy link
Contributor Author

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 = (
Copy link
Contributor

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';
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch!

src/components/Joiner/index.tsx Show resolved Hide resolved
src/components/DataProvider/index.tsx Show resolved Hide resolved
});
}

getLoaderReason = (series: ScaledSeries) => {
Copy link
Contributor

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}
Copy link
Contributor

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

@evancharlton
Copy link
Contributor Author

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.

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

Successfully merging this pull request may close these issues.

3 participants