-
Notifications
You must be signed in to change notification settings - Fork 13.9k
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-5] [Embeddable Charts] Decouple charts from slice and formData #5680
Comments
slice
and formData
Note that the chart function's signature is actually To make this frontend visualization plugin possible, we'll need to figure out how to get rid of the visualization-specific backend code in So I'm wondering where these new frontend methods should live. I'm guessing you were thinking about export the adaptor and using this as an the interface between export const visualization = {
adaptor,
queryGenerator: (formData) => {
return generateQuery(formData);
},
dataframeOperations: (formData) => (['pivot_table', { cols: [formData.cols], rows: formData.groupby }]),
}; I'm not sure how to model the query vs dataframe operations, should it be incorporate into the query, or made into its own thing. Clearly on the backend we need two abstractions as one is used to interact with connectors (querying) and the other applies to all connectors (dataframe transformation). I also wonder whether we could expose most of the pandas API from the frontend by doing a bit of magic, where the |
Thanks @mistercrunch
I have revised the proposal above to include how to handle
Agree. Let me move this discussion into another SIP, so this one will be kept small and focus on the front-end chart code clean up. We aim that the first pass of this process is to decouple front-end side of these classic vis into packages and be able to use current APIs to power them (i.e. without modifying viz.py yet). Meanwhile there are other workstreams on defining the common query and data format for explore API v2 that can be used to power multiple visualizations and decide what are the post-transformations in js. |
@mistercrunch I agree with your comment
and I'm also perplexed as to how to best generalize this. It seems a first step is to map arbitrary data (via a query) into a somewhat generic (potentially visualization aware) form. |
Going to close this as complete: All visualization components have been refactored as described here. Noting that this SIP was used more as formalizing architecture design and not for any formal voting. |
@williaster @conglei @mistercrunch @betodealmeida @hughhhh
cc @john-bodley @michellethomas @graceguo-supercat @timifasubaa
[Embeddable Charts] Decouple charts from
slice
andformData
Motivation
One key part of the embeddable project is to move towards chart plugins system, which we can register only necessary charts for superset or register custom ones as wish. This will give more flexibility to the developers to customize their superset instances (making it more lightweight, include-only-needed, or include custom vis type) as well as improve maintainability of the superset codebase.
In order to do that, we aim to split the chart types (i.e. most of the things in
src/visualizations
) into one or more plugins (npm packages), independent from superset. Then, we will implement a registry mechanism for importing plugins. However, before getting to that points, there are a few issues:slice
. The charts are technically a child of theslice
, but they take the parent as argument and call utility functions fromslice
(mostly jquery wrapper, which can be replaced with native js). It should to be more one-way dataflow and dispatch events that parent can pick-up rather than calling parents.formData
is a big object that contains many fields, very different from one chart to another. It should be clearer what fields each chart needs.<div>
then callReactDOM.render()
on the<div>
. This was done to support the non-React components. This may be not addressed yet in this SIP but the refactored chart code will enable us to remove this complicated logic.Proposed change.
The goal of this SIP is to make each chart decoupled, ready to be converted into an independent React component, before separating them into plugins. And we do this cleanup early so we can continue to take improvements/bugfixes from the community while we replace the core part to use plugin system.
The immediate benefit of this process is clearer documenting the props for each visualization, and repairs/revision of some visualization code.
After the work in this SIP is done, the code in
Chart.jsx
can be simplified.ChartBody.jsx
can be replaced with another component that handle only lazy-loading logic and rendering (extracted from Chart.jsx).New or Changed Public Interfaces
Current chart code are in the form
We will change it to
Eventually the
adaptor
will be broken into their own files or adapted to other formats. First pass will keep them in the same file to avoid merge conflicts atindex.js
.Please see more concrete example in the "Work in progress" section below.
New dependencies
None
Progress
Also completed
The text was updated successfully, but these errors were encountered: