Skip to content
This repository has been archived by the owner on Dec 10, 2021. It is now read-only.

Please help! How does getChartComponentRegistry work in SuperChartCore? #902

Closed
sysstudy20 opened this issue Jan 16, 2021 · 2 comments
Closed

Comments

@sysstudy20
Copy link

sysstudy20 commented Jan 16, 2021

I recently started looking into the Superset codebase and having a hard time grasping how some parts work.
In the SuperChart component, which I assume works as a parent component for all chart types that Superset has, it uses a SuperChartCore component, which has the core logic of it.

Chart: () => getChartComponentRegistry().getAsPromise(chartType),

In this part of the code,

const Renderer = createLoadableRenderer({
          loader: {
            Chart: () => getChartComponentRegistry().getAsPromise(chartType),
            transformProps: overrideTransformProps
              ? () => Promise.resolve(overrideTransformProps)
              : () => getChartTransformPropsRegistry().getAsPromise(chartType),
          },

I think createLoadableRenderer takes care of rendering the chart based on the chartType string passed in. However, I am still not sure how getChartComponentRegistry() works.

I looked into the file https://github.com/apache-superset/superset-ui/blob/4bda6f5305ea51225bd3eaed93d19a2f93a3f04c/packages/superset-ui-core/src/chart/registries/ChartComponentRegistrySingleton.ts to understand further.

What I am missing is, if I try to debug what getChartComponentRegistry() tries to return, I see something like

{
 items: {area: {loader: f}, bar: {loader: f} ...},
 name: 'ChartComponent',
 overwritePolicy: 'ALLOW',
 promises: {}
}

but I am not sure where the items come from. I don't see anywhere in the code that puts in the loaders into the items object.

Please help me understanding the logic. Thanks!

@ktmud
Copy link
Contributor

ktmud commented Jan 18, 2021

They are registered in superset/supersetfrontend, which in turn calls Preset.ts that calls each plugin's register() function that puts each part of the plugin into different registries...

Man, this is so convoluted.

@villebro
Copy link
Contributor

The codebase on this repo has been moved to the main Apache Superset repo, and consequently the repo is in the process of being archived. See the Superset Improvement Proposal for details: apache/superset#13013 . While all currently open issues and PRs will be closed, we encourage you to reopen this issue on the main repo if it is still relevant.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants