-
Notifications
You must be signed in to change notification settings - Fork 14.6k
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
Add event-flow visualization #3102
Changes from all commits
b77566b
4314a54
45f25ea
7ff7270
f1caccf
7b9eb37
e869ef3
347a4dd
d54cd89
4aef4eb
66970b1
4550d06
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 |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
|
||
import { | ||
App, | ||
withParentSize, | ||
cleanEvents, | ||
TS, | ||
EVENT_NAME, | ||
ENTITY_ID, | ||
} from '@data-ui/event-flow'; | ||
|
||
/* | ||
* This function takes the slice object and json payload as input and renders a | ||
* responsive <EventFlow /> component using the json data. | ||
*/ | ||
function renderEventFlow(slice, json) { | ||
const container = document.querySelector(slice.selector); | ||
const hasData = json.data && json.data.length > 0; | ||
|
||
// the slice container overflows ~80px in explorer, so we have to correct for this | ||
const isExplorer = (/explore/).test(window.location.pathname); | ||
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. not sure if I understand why, but I'm wondering if using 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 tried this to begin with but it doesn't seem to work/couldn't come up with any fix for the css. The panel dom looks like: <div class="panel">
<div class="panel-heading">...</div>
<div class="panel-body">...</div>
</div>
|
||
|
||
const ResponsiveVis = withParentSize(({ | ||
parentWidth, | ||
parentHeight, | ||
...rest | ||
}) => ( | ||
<App | ||
width={parentWidth} | ||
height={parentHeight - (isExplorer ? 80 : 0)} | ||
{...rest} | ||
/> | ||
)); | ||
|
||
// render the component if we have data, otherwise render a no-data message | ||
let Component; | ||
if (hasData) { | ||
const userKey = json.form_data.entity; | ||
const eventNameKey = json.form_data.all_columns_x; | ||
|
||
// map from the Superset form fields to <EventFlow />'s expected data keys | ||
const accessorFunctions = { | ||
[TS]: datum => new Date(datum.__timestamp), // eslint-disable-line no-underscore-dangle | ||
[EVENT_NAME]: datum => datum[eventNameKey], | ||
[ENTITY_ID]: datum => String(datum[userKey]), | ||
}; | ||
|
||
const dirtyData = json.data; | ||
const cleanData = cleanEvents(dirtyData, accessorFunctions); | ||
const minEventCount = slice.formData.min_leaf_node_event_count; | ||
|
||
Component = <ResponsiveVis data={cleanData} initialMinEventCount={minEventCount} />; | ||
} else { | ||
Component = <div>Sorry, there appears to be no data</div>; | ||
} | ||
|
||
ReactDOM.render(Component, container); | ||
} | ||
|
||
module.exports = renderEventFlow; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,43 @@ | ||
text { | ||
.treemap text { | ||
pointer-events: none; | ||
} | ||
|
||
.grandparent text { | ||
.treemap .grandparent text { | ||
font-weight: bold; | ||
} | ||
|
||
rect { | ||
.treemap rect { | ||
fill: none; | ||
stroke: #fff; | ||
} | ||
|
||
rect.parent, | ||
.grandparent rect { | ||
.treemap rect.parent, | ||
.treemap .grandparent rect { | ||
stroke-width: 2px; | ||
} | ||
|
||
rect.parent { | ||
.treemap rect.parent { | ||
pointer-events: none; | ||
} | ||
|
||
.grandparent rect { | ||
.treemap .grandparent rect { | ||
fill: #eee; | ||
} | ||
|
||
.grandparent:hover rect { | ||
.treemap .grandparent:hover rect { | ||
fill: #aaa; | ||
} | ||
|
||
.children rect.parent, | ||
.grandparent rect { | ||
.treemap .children rect.parent, | ||
.treemap .grandparent rect { | ||
cursor: pointer; | ||
} | ||
|
||
.children rect.parent { | ||
.treemap .children rect.parent { | ||
fill: #bbb; | ||
fill-opacity: .5; | ||
} | ||
|
||
.children:hover rect.child { | ||
.treemap .children:hover rect.child { | ||
fill: #bbb; | ||
} |
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.
what does '@%' do? where does the event-flow code live?
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's just a name-spaced package on npm, under the "@data-ui" user but mainly so all the
@data-ui
packages are in the same repo.it will live at https://github.com/williaster/data-ui/packages/event-flow but I haven't quite merged the chart into the master @data-ui repo, adding one more feature. this is the (massive 🙈) PR