forked from apache/superset
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
19006a7
commit de6af1e
Showing
13 changed files
with
176 additions
and
890 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
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
Oops, something went wrong.