-
Notifications
You must be signed in to change notification settings - Fork 14.5k
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-4] [Embeddable Charts] Create Superset JS Client #5667
Comments
Hello, full-disclosure, I'm not a user of superset (although, it looks awesome!), I'm just browsing and had a question: Why go with React components instead of an iframe based approach? Seems like the latter affords more flexibility from implementation, maintenance and usage perspectives? |
@tiffon good question. we already support embedding charts (and dahsboards) with an iframe via a instead we'd like to introduce modular data providers (for data sources and queries) and embeddable charts to enable greater flexibility in apps which hope to leverage the Superset backend. you could imagine wanting to build a complex visualization in another web app, but wanting to leverage Superset data to power it. This would also support that use case. finally, we also expect that the modularity that's enforced by this approach will also greatly reduce coupled code/related bugs. |
@williaster great work, I would most certainly be a user of this feature! Two small questions:
|
@victornoel also good questions! I think it's actually easier to answer your second question first. It's a bit beyond the scope of this SIP (another one will be posted shortly that describes this in depth) but we are hoping to refactor the frontend code into a series of NPM packages, for the time being you could imagine As for exposing controls like group bys and filters in another application, here's an overview of some different usage scenarios we have thought about with associated components. If the app using the embeddable charts knows about column metadata, it can create the appropriate group bys and filters that then affect the query for the chart. (note this doesn't use the filter widget specifically, the other application would need to write the logic for controls; in the long-run we would also hope to create |
@williaster thanks for your answer, this new endeavour around embeddable charts and chars as plugins is really a great advancement for superset I think :) |
@mistercrunch what are your thoughts on where JS packages should live? I can create this within the Overall it seems like there are more pros to moving it outside of the superset-repo, but I also see the merits of keeping it in one. |
@williaster I'm open to both approaches, though apache makes things harder on us as we cannot create repos easily under the I think it's fairly easy to revisit this decision too. The question is if not under Options:
We may be able to dig out Ashutosh's GH account and tag him here. |
@mistercrunch one clarification here is that we don't need multiple repos for the ui packages. It's pretty common to have one mono repo (eg So an example repo dir structure would look like
// root package.json that has deps like lerna.js and shared things like build, testing, linting
package.json
// each of these packages can be developed independently, and have dependencies on each other
// lerna.js is used to manage inter-package dependencies + publishing.
packages/
superset-core/
package.json
README.md
src/ // source for THIS package only
tests/
…
superset-plugin-vis-timeseries/
superset-plugin-vis-histogram/
…
superset-preset-vis-core/
superset-preset-vis-airbnb/
superset-preset-vis-lyft/ so you could do that in a separate repo, or include it within superset/
assets/
// this defines the deps of the overall Superset app (including superset
// npm packages) + manages the build. This allows the packages to be developed
// and versioned independently from the Superset app 🎉
package.json
webpack.config.js
…
src/
// these do NOT have package.json’s, their deps are defined in the root.
// when an app has a dependency on a package (e.g., @superset/core),
// it is referencing the npm version of that code, not the code in the local
// repository. In development you can symlink such deps
apps/
explore/
dashboard/
…
// each of these packages can be developed separately from the app.
// lerna.js is used to manage inter-package dependencies + publishing.
packages/
superset-core/
package.json
README.md
src/ // source for THIS package only
tests/
…
superset-plugin-vis-timeseries/
superset-plugin-vis-histogram/
… |
@williaster @kristw We need to expose a interface that will be adhered by visualisation to be embeddable in suoerset dashboard. The interface will be derived from refactoring proposed in multiple SIP One open question at this point of time is how and when to pull third party code and security sandboxing. |
@graceguo-supercat adding my responses to your SIP-4 Dashboard refactor comments here.
With my series of PRs, the intention is to remove all
Couple thoughts
We discussed this in person a bit. To start we'll play it by ear, if something would be useful in another repository, we could make it into a package. |
@arpit-agarwal thanks for the thoughts. I think that the chart plugins will enable embedding 3rd party react components/charts in a dashboard. @kristw is working on fleshing out some of the requirements for the plugin system now in SIP-6. Thanks for the link to how kibana supports plugins, we'll 👀 |
@williaster I'm trying to plan our migration to superset and we are wondering if there is some kind of tentative timeline for the availability of this feature. Thanks for any information, even if there is no commitment on them :) |
Hey @victornoel 👋 The @kristw is working on untangling all of the visualizations to support the actual Chart Plugin system in described in SIP-6. The plugins themselves are coming along well (e.g., this PR) and should be wrapped up in Q4 this year. The trickier part of this will be defining consistent APIs for query + data munging, and fully migrating query specifications and data munging to JS from Python. @conglei is working the latter right now. I would say that work will be complete in Q1 next year most likely. |
@williaster thanks a lot for the detailed answer, all of this new architecture is very exciting, both So basically, we can already (with current master and One last small question: any idea when the next stable superset will be released? |
Yes waiting for a stable release of this feature |
Going to close this as complete: Noting that this SIP was used more as formalizing architecture design and not for any formal voting. |
I am trying to embed chart into my angular app .What is the best way to do it? |
Hi @rojan507 this is not quite ready to embed in an external app. It is likely that this ability will be added chart by chart because we have to migrate backend code for every vis type to the client to allow for JS-only plugins. You can follow SIP-6 and see the first plugin PR (word cloud) for further details. |
@williaster I thought this was already possible as long as the chart and its backend code was already included in superset? |
Hello Friends, |
@kristw @conglei @mistercrunch @betodealmeida @hughhhh
cc @john-bodley @michellethomas @graceguo-supercat @timifasubaa
[SIP] [Embeddable Charts] Create Superset Client
This is the first of a few SIPs to progress toward a world where we can embed Superset Charts as React components in other web applications. At a high level this will require
@superset/xxx
NPM packages with data providers + chart components.Motivation
This specific SIP is for creating a Superset JS client to handle asynchronous requests for data including authentication.
The motivation for this change is two-fold
Proposed Change
Write a single JS
SupersetClient
class thatGET
/POST
/PUT
/DELETE
methodsAfter this we can write corresponding React components to handle fetching specific types of Superset data (including in other apps):
<DatasourceProvider />
returns available datasources<MetadataProvider />
given a datasource id, returns metadata on all of its columns, metrics, etc.<QuerydataProvider />
given a query, returns the data for that query; this can be uncoupled from visualizations over time.We can do this in three phases:
New or Changed Public Interfaces
Example usage of the client:
Authentication and CORS
In order to support requests made from other web applications, we must
The Superset backend already supports enabling CORS for specific endpoints and resources. This is an example
config.py
:By setting the fetch parameter
{ credentials: 'include' }
we can also forward credentials for the current user.Proof of concept
This is a proof of concept using the
SupersetClient
code in another web application (PR to come). It demonstratesCSRF token
in requestsGET
andPOST
requests for Superset data that ultimately powers a chart.New dependencies
This should only require the
whatwg-fetch
polyfill, which has been added / considered in other PRs (eg #5524) and has no license concerns.Migration Plan and Compatibility
We don't anticipate that any migration will be necessary or breaking compatibility changes.
Rejected Alternatives
We considered a client that also handles redux state management, but this seems too complex to start and could be added as another layer in the future if it was needed for embeddable charts (we think it won't be)
Major open questions
A major open question is WHERE this code (and other future
@superset/...
JS npm packages) should ultimately live. The options are:within the
apache/incubator-superset
repo under asrc/packages/
subfolder, ora separate repository (which?!)
Pros of
apache/incubator-superset
Cons of
apache/incubator-superset
(ie superset app does not pull from local package source code, rather it pulls from npm for a particular version of that source code)
Overall it seems we should move packages to a different repsoitory. Where should this be? (note: I grabbed the npm
@superset
namespace for publishing so we should be good there! 👍The text was updated successfully, but these errors were encountered: