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 Series and Collection data flow #302

Merged
merged 87 commits into from
May 8, 2019
Merged
Show file tree
Hide file tree
Changes from 77 commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
101d9d2
Refactor the Series and Collection data flow
May 4, 2019
630f904
Remove a bunch of unused code
May 4, 2019
d8bd830
Added collections
May 4, 2019
ff21019
Added ySubDomain
May 4, 2019
d21469f
Added hidden
May 4, 2019
e515289
Add loader
May 4, 2019
ea53ed5
Ported sized
May 4, 2019
09e96f9
Ported Full-size
May 4, 2019
3e98fd6
Moved the Collection/Series stories
May 4, 2019
35f26e6
Ported resizing
May 4, 2019
6d59962
Added min/max support
May 4, 2019
9195608
Add step
May 4, 2019
5137349
Ported min/max with raw points
May 4, 2019
bcb8748
Ported loading data from API
May 4, 2019
1422fef
Add hidden
May 4, 2019
98a5cc5
Custom default accessors working
May 4, 2019
0286a43
Port over specified y domains
May 4, 2019
c55357f
Ported Annotation
May 4, 2019
2acce3f
Ported click events
May 4, 2019
789cf75
Port drawPoints / add default drawPoints
May 4, 2019
196c508
Port without context chart
May 4, 2019
bb697a2
Add zoomable
May 4, 2019
f95a773
Add ySubDomain
May 4, 2019
cb4a843
Port dyanmic time subdomain
May 4, 2019
c82a63d
Port enable/disable series
May 4, 2019
9e841e7
Sticky time subdomain -- FIXME
May 4, 2019
e92ad82
Port sticky subdomain and ruler -- FIXME
May 4, 2019
93f86e5
Port limit timesubdomain -- FIXME
May 4, 2019
39150bd
Port limit time subdomain -- FIXME
May 4, 2019
d15a7ab
Port onMouseOut
May 4, 2019
c696d0d
Port onUpdaetDomains
May 4, 2019
a3c7e12
Starting on Scatterplots
May 4, 2019
0dec119
Add live loading
May 4, 2019
e833cee
Port live loading with ruler
May 4, 2019
c0c3d2d
Remove old series prop
May 4, 2019
ae4ecdc
Remove some copy/paste boilerplate
May 4, 2019
3623fb2
Ordering of Series props doesn't matter
May 4, 2019
2f397ea
Remove unused DataProvider code
May 4, 2019
191e7ab
Ported Basic Usage
May 4, 2019
6484762
Port different domains
May 4, 2019
357db35
Port domains
May 4, 2019
450454a
Port custom tick formatting
May 4, 2019
22f3956
Port grid
May 4, 2019
f876a45
Port axes
May 4, 2019
600db42
Port split axes
May 4, 2019
85495dc
Port strokeWidth & pointWidth
May 4, 2019
b7e9e65
Ported opacity
May 4, 2019
532ba10
Port min/max
May 4, 2019
f3b6f47
Port context chart
May 4, 2019
9dcd84b
Port zoomable
May 4, 2019
defba08
Port drawLines
May 4, 2019
ae4700b
Port pointRenderer
May 4, 2019
4c0d305
Fix scatterplot zooming
May 4, 2019
0635561
Removing old APIs
May 4, 2019
fb1da45
Ported dynamic time domain
May 4, 2019
0274580
Ported AxisCollection stories
May 5, 2019
7615822
Ported ContextChart stories
May 5, 2019
af0cafd
Ported GridLines stories
May 5, 2019
a9e7561
Ported Plotly stories
May 5, 2019
dcae6e2
Ported InteractionLayer stories
May 5, 2019
f984f9a
Port XAxis stories
May 5, 2019
87bbc30
Ported XAxisPlacements stories
May 5, 2019
f443a2d
Ported YAxisModes stories
May 5, 2019
3aa643d
Ported YAxisPlacement stories
May 5, 2019
6b5753c
Ported SeriesCollection stories
May 5, 2019
7246909
Remove series prop
May 5, 2019
9729a2e
Clean up DataProvider a bit
May 5, 2019
4b1cd62
Added opacity to line
May 5, 2019
f07208b
Added toggles to the Collection stories
May 5, 2019
5ec6a3d
Extract prop names
May 5, 2019
18acdc8
Support legacy rendering (for now)
May 5, 2019
7456e60
Clean up eslint warnings
May 5, 2019
2b5c344
Add proptype for legacy collections
May 5, 2019
b7889e0
Make TypeScript happy with Collection
May 5, 2019
f36dc2d
Document (or remove) @ts-ignore wherever possible.
May 5, 2019
dd8e28e
Clean up the "Change props" stories a bit
May 6, 2019
d7a929a
Make the arrays a bit prettier
May 6, 2019
5e8445c
Fix the Plotly story
May 6, 2019
865a630
Add comments about the placeholder domains
May 6, 2019
5301735
Merge branch 'master' of github.com:cognitedata/griff-react into seri…
May 6, 2019
84792cc
Add displayNames to Series / Collection
May 6, 2019
fe7a22f
Pull out the series toggler thing
May 6, 2019
26ec34a
Make the borders align
May 6, 2019
b58b7c1
Added basic stories for Scatterplots
May 6, 2019
4fb5c14
Merge branch 'master' of github.com:cognitedata/griff-react into seri…
May 7, 2019
af89c96
Fix the ChartJS stories
May 7, 2019
0dac5c5
Rework stripPlaceholderDomain
May 7, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
76 changes: 76 additions & 0 deletions src/components/Collection/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import * as React from 'react';
evancharlton marked this conversation as resolved.
Show resolved Hide resolved
import Data from '../../context/Data';
import { ItemProps, WATCHED_PROP_NAMES, Props as SeriesProps } from '../Series';
import { ItemId } from '../../external';

export interface Props extends ItemProps {
id: ItemId;
}

type UnregisterCollectionFunction = () => void;

type RegisterCollectionFunction = (
collectionProps: Props
) => UnregisterCollectionFunction;

type UpdateCollectionFunction = (collectionProps: Props) => void;

interface InternalProps {
registerCollection: RegisterCollectionFunction;
updateCollection: UpdateCollectionFunction;
children?: React.ReactNode[];
}

// @ts-ignore - I don't know how to make TypeScript happy about ...props
const Collection: React.FunctionComponent<Props & InternalProps> = ({
id,

registerCollection,
updateCollection,
children,

...props
}) => {
React.useEffect(() => {
return registerCollection({
id,
...props,
});
}, []);

React.useEffect(() => {
return updateCollection({
id,
...props,
});
// @ts-ignore - It's okay for props[name] to be implicit any.
}, WATCHED_PROP_NAMES.map(name => props[name]));

if (React.Children.count(children) === 0) {
return null;
}

return React.Children.map(children, child => {
if (!child || !React.isValidElement(child)) {
return null;
}
return React.cloneElement(child as React.ReactElement<SeriesProps>, {
...child.props,
collectionId: id,
});
});
};

export default (props: Props & { children: React.ReactNode[] }) => (
<Data.Consumer>
{({ registerCollection, updateCollection }: InternalProps) => (
<Collection
registerCollection={registerCollection}
updateCollection={updateCollection}
{...props}
>
{props.children}
</Collection>
)}
</Data.Consumer>
);
2 changes: 1 addition & 1 deletion src/components/ContextChart/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const renderXAxis = (position, xAxis, { xAxisPlacement }) => {
return xAxis;
}
if (xAxisPlacement === AxisPlacement.BOTH) {
return React.cloneElement(xAxis, { xAxisPlacement: position });
return React.cloneElement(xAxis, { placement: position });
}
return null;
};
Expand Down