Skip to content
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

Use chart plugins and remove code under visualizations #6838

Merged
merged 17 commits into from
Feb 14, 2019

Conversation

kristw
Copy link
Contributor

@kristw kristw commented Feb 7, 2019

Changes in this PR

This PR affects many files. 😱 However, the real edits only happen in

  • package.json
  • src/visualizations/presets/CommonChartPreset.js
  • src/visualizations/presets/LegacyChartPreset.js

The rest are deletions 💣. To sum up, here is what's happening.

Note: Currently applies to all charts except TimeTable, FilterBox and deck.gl.

What does this mean for the project?

This PR enable charts that are plugins to be embeddable in another application using ChartClient and <SuperChart /> from @superset-ui/chart. (Still need to work on demo and documentation. cc @xtinec)

This PR trim the core Superset codebase and make the chart plugins optional. The chart plugins potentially can be added/removed as the developers wish, or switched to different implementation, without everybody slamming all kinds of charts or customization into this repo, which makes the codebase become impossible to maintain over time and the Superset app has too many chart options that fits no one.

Future work

To enable developers to write their own chart plugins. There are still remaining work.

Part 1. Make control panels (left side of the explore page) part of the plugins

  • Separate control panel config from controls.jsx
  • Make control panel config part of chart plugins
  • Migrate control panel configs to read from plugins

At this point developers will be enable to define a new chart and its control panel. However, the backend logic that would have been added to viz.py in the previous approach will be replaced by calling the new query api via buildQuery logic defined in the plugin.

Part 2. We still have some work left on the backend to handle query objects created by buildQuery. Meanwhile the legacy charts will have useLegacyApi flag in the ChartMetadata to indicate that it is not using the new endpoint but use the old endpoints powered by viz.py instead.

Part 3. Documentation and better tooling for cross-repo work

  • Example of independent plugin repo
  • Generator for creating a new plugin repo
  • Handle symlink to plugin correctly when using npm link to enable interactive development.
  • Update storybook in @superset-ui/legacy-* to preview live code. (Currently reading from the distribution code)

With that said, I think we have made a lot of progress in the past few months and this PR is one major step forward. There are still remaining work so please hold on if you are eager to add your own chart. In the meantime if the developers want to see previews of how to write a chart plugin, please look at
https://github.com/apache-superset/superset-ui-legacy
and
https://github.com/apache-superset/superset-ui/packages/plugin-chart-word-cloud
for examples.

@kristw kristw added #code-quality risk:many-files Change has too many files labels Feb 7, 2019
@codecov-io
Copy link

codecov-io commented Feb 7, 2019

Codecov Report

Merging #6838 into master will increase coverage by 6.89%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #6838      +/-   ##
==========================================
+ Coverage   56.22%   63.11%   +6.89%     
==========================================
  Files         527      423     -104     
  Lines       23529    20672    -2857     
  Branches     2782     2281     -501     
==========================================
- Hits        13229    13048     -181     
+ Misses       9888     7487    -2401     
+ Partials      412      137     -275
Impacted Files Coverage Δ
...ts/src/visualizations/presets/LegacyChartPreset.js 0% <0%> (ø) ⬆️
...ssets/src/visualizations/presets/MapChartPreset.js 0% <0%> (ø) ⬆️
...ts/src/visualizations/presets/CommonChartPreset.js 0% <0%> (ø) ⬆️
...src/visualizations/presets/HierarchyChartPreset.js 0% <0%> (ø) ⬆️
superset/assets/src/query/index.ts 0% <0%> (-100%) ⬇️
superset/assets/src/query/buildQueryObject.ts 0% <0%> (-100%) ⬇️
superset/assets/src/query/buildQueryContext.ts 0% <0%> (-100%) ⬇️
superset/assets/src/query/Metric.ts 0% <0%> (-100%) ⬇️
superset/assets/src/query/FormData.ts 0% <0%> (-100%) ⬇️
superset/assets/src/query/Column.ts 0% <0%> (-100%) ⬇️
... and 5 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3f47c61...1946db0. Read the comment docs.

@mistercrunch
Copy link
Member

destruction

@DavidJHassan
Copy link
Contributor

−221,445 WOW!

@kristw kristw force-pushed the kristw--chart-integration branch from e464ed6 to 2bdb445 Compare February 11, 2019 23:50
@kristw kristw force-pushed the kristw--chart-integration branch from 2bdb445 to 3c01eeb Compare February 12, 2019 23:03
@kristw kristw changed the title [WIP] Use chart plugins and remove code under visualizations Use chart plugins and remove code under visualizations Feb 13, 2019
@kristw
Copy link
Contributor Author

kristw commented Feb 13, 2019

Hi reviewers, I think this is ready for review. Please let me know if you have any concern.

@williaster @mistercrunch @graceguo-supercat @michellethomas @xtinec @betodealmeida

Copy link
Contributor

@williaster williaster left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks for all of your hard work on this and debugging the nvd3 issue!

quite an epic PR 🙌 🏆 I can't believe the vis code had that many lines 😱

@kristw kristw merged commit 75e1045 into apache:master Feb 14, 2019
@kristw kristw deleted the kristw--chart-integration branch February 14, 2019 19:28
@joshbrooks
Copy link
Contributor

@kristw I'm interested in whether/how this affects the "Country Map" - how should we now add a new country to visualisations?

@@ -17,21 +17,19 @@
* under the License.
*/
import { Preset } from '@superset-ui/core';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(senv) [root@blade02 presets]# pwd
/root/incubator-superset/superset/assets/src/visualizations/presets
(senv) [root@blade02 presets]# ll
total 8
-rw-r--r--. 1 root root 6453 Feb 4 16:33 MainPreset.js

Hello, there is no such a file in this directory

Note: superset version 0.35.2

@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.34.0 labels Feb 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels risk:many-files Change has too many files 🚢 0.34.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants