-
Notifications
You must be signed in to change notification settings - Fork 16.1k
feat: improve loading speed for legacy table chart #9234
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
Conversation
0f49084 to
6589e7b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is still a DRAFT. Waiting for apache-superset/superset-ui-plugins#385
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
6589e7b to
9e7b7b5
Compare
ccd87b7 to
34d784d
Compare
|
this change will automatic/force to show pagination on large table? Or it's up to user to select show pagination? |
No, it will not. This PR only refactors the chart module and disabled a couple of already-broken features. The perf gain mainly comes from other optimizations. |
b423458 to
3cbb1af
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a couple comments. Will approve once 0.11.16 exists
27f313b to
75234d1
Compare
Codecov Report
@@ Coverage Diff @@
## master #9234 +/- ##
==========================================
+ Coverage 58.93% 58.94% +0.01%
==========================================
Files 373 373
Lines 12014 12017 +3
Branches 2945 2946 +1
==========================================
+ Hits 7080 7083 +3
Misses 4755 4755
Partials 179 179
Continue to review full report at Codecov.
|
|
@ktmud Please resolve conflict |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could use const and ternary
const chartClassName = vizType === 'table' ? `superset-chart-${chartClassName}` : snakeCase(vizType);There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was planning to allow more viz types in the future.
if (vizType === 'table' || vizType === 'another-one' ) {Ternary makes this code look one-off but we actually have more planned.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you could still use ternary for that when adding more vizType or use set if the list grows longer.
const visSet = new Set([...]);
const chartClassName = visSet.has(vizType) ? ... : ... ;There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, will update.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I think another reason why I didn't use ternary is that the new class is based on an existing variable. It just feels more natural to override it via if statement than either creating two variables or call snakeCase(vizType) twice.
let chartClassName = snakeCase(vizType);
if (vizType === 'table') {
chartClassName = `superset-chart-${chartClassName}`;
}vs
let chartClassName = snakeCase(vizType);
chartClassName = vizType === 'table' ? `superset-chart-${chartClassName}` : chartClassName;vs
const chartClassName = vizType === 'table' ? `superset-chart-${snakeCase(vizType)}` : snakeCase(vizType);Still thinks the if block is more readable... 😬
Upgrade table chart `@superset-ui/legacy-plugins-chart-table` to apache-superset/superset-ui-plugins#385
75234d1 to
8243b91
Compare
| // container. It may cause css conflicts as in the case of table chart. | ||
| // When migrating legacy chart types, we should gradually add the prefix | ||
| // `superset-chart-` to each one of them. | ||
| chartClassName = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think of
const snakeCaseVizType = snakeCase(vizType);
const chartClassName = vizType === 'table' ? `superset-chart-${snakeCaseVizType}` : snakeCaseVizType;There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I generally avoid reassigning variables. NVD3Vis.js is an example of many reassignments that made it very difficult to refactor because order of operations matter a lot.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think of
const snakeCaseVizType = snakeCase(vizType); const chartClassName = vizType === 'table' ? `superset-chart-${snakeCaseVizType}` : snakeCaseVizType;
I like this one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I generally avoid reassigning variables.
NVD3Vis.jsis an example of many reassignments that made it very difficult to refactor because order of operations matter a lot.
I think it makes sense to use a combination of both. const should be default, but let can be acceptable in small scopes.

CATEGORY
SUMMARY
One of the main pain points with the table chart is that it loads too slow for large datasets. This PR upgrades it to an updated version with improved performance. See superset-ui-plugins PR#385 for details.
In addition to upgrade the table chart plugin, this PR also refactors some styling code related to it.
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
Tested with a ~10,000 rows, 7 columns table in Superset, pagination enabled:
Before
Takes about 6 secs to load.
After
Takes only 3 secs to load!
TEST PLAN
ADDITIONAL INFORMATION
REVIEWERS
@kristw @graceguo-supercat @etr2460 @rusackas