-
Notifications
You must be signed in to change notification settings - Fork 33
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
Adding heatmap and graph_type #134
Changes from 3 commits
1bc5860
e326cc4
2ba0fed
663693a
0f54638
8e2e0ad
1596234
daa5b3d
22ebea0
f064018
2f6b271
d79246b
76d4281
8eb3ffb
1cc4587
d4247d1
44ee97b
29f53da
ebe69ad
39c9f49
c188f8c
322b7c1
8c08420
92d561c
bf6c4e9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,21 +3,55 @@ import React from 'react'; | |
import C3Chart from 'react-c3js'; | ||
import 'c3/c3.css'; | ||
import { AXIS, DATA, GRID, POINT, TRANSITION } from '../../../constants'; | ||
import Grid from './Grid/Grid'; | ||
|
||
function composeID(q) { | ||
const modFuncArity = q.split(':'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you shouldn't assume anything about the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. there used to be a utility function There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll use the |
||
const mod = modFuncArity[0]; | ||
const func = modFuncArity[1].split('/')[0]; | ||
const arity = modFuncArity[1].split('/')[1]; | ||
return `${mod}${func}${arity}`; | ||
} | ||
|
||
const propTypes = { | ||
dps: PropTypes.arrayOf(PropTypes.object).isRequired, | ||
type: PropTypes.string.isRequired, | ||
query: PropTypes.string.isRequired, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe this can be the whole There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we are composing the ID inside
What do you think? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. right, so |
||
}; | ||
|
||
const Graph = ({ dps, type, query }) => { | ||
const queryID = composeID(query); | ||
const wrapperID = `graphWrapper-${queryID}`; | ||
const wrapper = document.getElementById(wrapperID); | ||
if (type === 'grid') { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can create constant for types and put it somewhere in
|
||
return ( | ||
<div | ||
id={wrapperID} | ||
style={{ | ||
textAlign: 'center', | ||
justifyContent: 'center', | ||
}} | ||
> | ||
{wrapper && <Grid | ||
data={{ ...DATA, json: dps }} | ||
outerWidth={wrapper.clientWidth} | ||
graphID={queryID} | ||
/>} | ||
</div> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As we introduced new type of graph we can add new layer of components here
|
||
); | ||
} | ||
return ( | ||
<div> | ||
<C3Chart | ||
data={{ ...DATA, json: dps }} | ||
point={POINT} | ||
grid={GRID} | ||
axis={AXIS} | ||
transition={TRANSITION} | ||
/> | ||
</div> | ||
); | ||
}; | ||
const Graph = ({ dps }) => ( | ||
<div> | ||
<C3Chart | ||
data={{ ...DATA, json: dps }} | ||
point={POINT} | ||
grid={GRID} | ||
axis={AXIS} | ||
transition={TRANSITION} | ||
/> | ||
</div> | ||
); | ||
Graph.propTypes = propTypes; | ||
|
||
export default Graph; |
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.
nitpicking: you could perform and collect
mfas.map(f => f.query)
before filtering to do it only once instead of doing it for eachmfa
from incommingjson
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.
Now it is:
(for the sake of clarity, given in old, already changed naming convention)