-
Notifications
You must be signed in to change notification settings - Fork 14.4k
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
[SIP-6] [Embeddable Charts] Migrate visualization-specific code to js plugin #5692
Comments
DECISION: Out-of-scope After syncing offline with @john-bodley , it seems like we need to think more about What kind of UI we have in mind on the explore page?A. Users need to formulate query to get tabular data first, then map the columns from intermediate table to the encoding channels (color, size, length, position, etc.) B. The controls list encoding channels, which users can put columns/metrics/aggregates from datasource and our engine translates this back into database query + post-query transformation. What operations should be done on back-end/front-end?For example, group by and aggregates (count,sum,avg,etc.) should leverage database. |
I was thinking solely about the shortest path to making visualizations as JS plugins, without redesigning the explore user interface. I'm very supportive of redesigning the explore interface, but we may want to think of this as a different step or project altogether. Both these efforts are sizable on their own. Happy to go either way, but personally I prefer smaller chunks of work. |
Also if you don't redesign the explore interface now, the "charts as js plugin" feature can be integrated sooner and people will start using it, which should give lots of user inputs about how the explore interface should be redesigned. |
DEPRECATED: Please see more updated structure below. [Proposal] Each chart plugin package includes
index.js export default new ChartPlugin({
// Can separate into metadata.js
metadata: {
key: 'my-chart',
label: 'MyChart',
description: 'lorem ipsum dolor',
},
// Can separate into buildQuery.js
buildQuery: (formData) => { ... }, // #3
loadAdaptor: () => import('./Adaptor.jsx'),
// Can separate into controlPanelConfig.js
controlPanelConfig: ..., // #4
}); |
The types of each field in
|
Refractor of
|
PR | Visualization | Status |
---|---|---|
#5753 | Word cloud | merged |
#5861 | BigNumber | under review |
Tree Map | ||
Chord Vis | ||
iframe and markup | ||
Horizon Chart | ||
Force-directed Graph | ||
Sunburst | ||
Sankey | ||
Heatmap | ||
Pivot Table | ||
Table | ||
Partition | ||
World Map | ||
Country Map | ||
Histogram | ||
Calendar Heatmap | ||
Parallel Coordinates | ||
Paired t-test | ||
Rose | ||
Time Series Table | ||
MapBox | ||
FilterBox | ||
NVD3 |
@kristw How is such a cool diagram generated? |
@zhaoyongjie Drawn manually :) |
The directory structure for each plugin will look like this. Using
What is in each file?1. buildQuery.jsexport default function buildQuery(formData) {
return queryObject;
} 2. transformProps.jsexport default function transformProps({
slice,
payload,
setControlValue,
}) {
// Return props that are compatible with <WordCloud />
// In the future can enforce type for the returned object if we use TypeScript.
return props;
} Note: In the future, will replace 3. transformData.jsTransform props that are based on export default function transformData({ payload, formData }) {
return props;
} 4. metadata.jsDescription of this chart import thumbnail from './WordCloud.png';
export default new ChartMetadata({
key: 'word-cloud',
name: 'WordCloud',
description: 'Lorem ipsum dolor sit amet',
thumbnail,
}); 5.1 WordCloud.js and ReactWordCloud.jsxFor vanilla components that are not React yet, we have been refactoring to make it convertible WordCloud.jsexport default function(element, props) { ... } ReactWordCloud.jsximport reactify from '../../utils/reactify';
export default reactify(WordCloud); 5.2 WordCloud.jsxFor components that are already React component class WordCloud extends React.Component {
...
}
export default WordCloud; 6. adaptor.jsxShim to make it work with current Superset app. This file will be deleted after we completely move to the plugin system. import createAdaptor from '../../utils/createAdaptor';
import WordCloud from './ReactWordCloud';
import transformProps from './transformProps';
// return function(slice, payload, setControlValue) that render the component
export default createAdaptor(WordCloud, transformProps); 7. plugin.jsThis is how a chart plugin is defined. It will replace import buildQuery from './buildQuery';
import transformProps from './transformProps';
import metadata from './metadata';
import WordCloud from './ReactWordCloud';
export default new ChartPlugin({
key: 'word-cloud',
metadata,
buildQuery,
transformProps,
Chart: WordCloud,
}); Plugins are installed like this import wordCloudPlugin from './WordCloud/plugin';
wordCloudPlugin.install(); Then you can use <SupersetDataProvider type="word-cloud" formData={...}>
<SuperChart type="word-cloud" xxx={...} />
</SupersetDataProvider> There is an ongoing work for plugin system in #5882 which explains what happens behind-the-scene in |
Until the plugin mechanism is implement, we will be converting the existing chart to conform with the structure above. Example is this PR. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Continued from the discussion in [SIP-5] #5680
There is a decent amount of work to be done to make the visualization plugins are truly independent from the core superset.
Q1: What need to be converted to JS?
Q2: Where these new front-end methods should live?
Q3: How to actually implement these two parts?
The text was updated successfully, but these errors were encountered: