feat: improve loading speed for legacy table chart#9234
Conversation
0f49084 to
6589e7b
Compare
ktmud
left a comment
There was a problem hiding this comment.
This is still a DRAFT. Waiting for apache-superset/superset-ui-plugins#385
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
etr2460
left a comment
There was a problem hiding this comment.
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.
could use const and ternary
const chartClassName = vizType === 'table' ? `superset-chart-${chartClassName}` : snakeCase(vizType);There was a problem hiding this comment.
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.
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.
Makes sense, will update.
There was a problem hiding this comment.
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.
What do you think of
const snakeCaseVizType = snakeCase(vizType);
const chartClassName = vizType === 'table' ? `superset-chart-${snakeCaseVizType}` : snakeCaseVizType;There was a problem hiding this comment.
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.
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.
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.
* perf(table-chart): upgrade to 0.11.6 Upgrade table chart `@superset-ui/legacy-plugins-chart-table` to apache-superset/superset-ui-plugins#385 * refactor: use ternary instead of if * fix: rename variables

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