-
Notifications
You must be signed in to change notification settings - Fork 14.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add event-flow visualization (#3102)
* [event-flow] add event flow visualizaton type from @data-ui/event-flow. * [event-flow] update vis thumbnail * [event-flow] update row limit label, remove duplicate chart controls * [dependencies] add @data-ui/event-flow 0.0.2 * [linting] fix multiple imports * [deps] bump mapbox-gl and react-map-gl to fix build * [event-flow] bump to 0.0.3 for es2015 + stage-0 babel presets * [deps] revert mapbox version bumps * [event-flow] update png, bump to newest version, address reviewer comments, add min event count form. * [event-flow] pin version * [event-flow][spec] add test for coveralls * [event-flow] revert spec
- Loading branch information
1 parent
a141695
commit 40d9e15
Showing
9 changed files
with
170 additions
and
14 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
|
||
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters