-
Notifications
You must be signed in to change notification settings - Fork 77
feat(big-number): allow fallback to last available value and fix time range for trend lines #403
Conversation
In Superset, when a timeseries query has no data at the beginning period or end period of the filtered time range, there will not no data records at those periods, hence the trendline in Big Number chart would not render those periods. This often causes confusion and misinterpretaiton in dashboards, especially for those with multiple trendline charts aligned with each other. They could all be a very smooth line, but actually showing very different time ranges. This PR adds an option "alignTimeRange" to apply the filtered time range on the xAxis. Date periods for empty data will be rendered, but there will be no connected lines, dots, or tooltips for them. It's possible to still show tooltips for those periods, but I decided not to do that as: 1) it makes things much more complicated; 2) I don't want to confuse zero or nulls with empty data.
Deploy preview for superset-ui-plugins ready! Built with commit 3912f58 |
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.
There are eslint
errors.
/home/travis/build/apache-superset/superset-ui-plugins/packages/superset-ui-legacy-preset-chart-big-number/src/index.js
1:49 error Missing file extension "ts" for "./BigNumber/index" import/extensions
2:54 error Missing file extension "ts" for "./BigNumberTotal/index" import/extensions
/home/travis/build/apache-superset/superset-ui-plugins/packages/superset-ui-legacy-preset-chart-big-number/src/preset.js
20:34 error Missing file extension "ts" for "./BigNumber" import/extensions
21:39 error Missing file extension "ts" for "./BigNumberTotal" import/extensions
Don't add the ts
extension like it suggests. Just apply eslint-disable
because once these file are transpiled into js
in lib
and esm
, having the .ts
extension in import
statement will make it fail to find the file.
packages/superset-ui-legacy-preset-chart-big-number/src/BigNumber/BigNumber.tsx
Outdated
Show resolved
Hide resolved
packages/superset-ui-legacy-preset-chart-big-number/package.json
Outdated
Show resolved
Hide resolved
packages/superset-ui-legacy-preset-chart-big-number/src/BigNumber/BigNumber.tsx
Outdated
Show resolved
Hide resolved
Codecov Report
@@ Coverage Diff @@
## master #403 +/- ##
=========================================
+ Coverage 2.83% 3.38% +0.55%
=========================================
Files 186 187 +1
Lines 5821 5844 +23
Branches 373 405 +32
=========================================
+ Hits 165 198 +33
+ Misses 5631 5605 -26
- Partials 25 41 +16
Continue to review full report at Codecov.
|
I moved all files to |
"shortid": "^2.2.14" | ||
}, | ||
"peerDependencies": { | ||
"d3-color": "^1.2.3", |
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.
Let's keep this one as dependencies
.
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.
Any reason why would it be better? I thought it's preferable to have it in peerDependencies
as long as it is in the dependencies
of superset-frontend
.
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.
Usually peerDependencies
should be use when only one instance of that lib should exist in the entire app. This could be due to the use of singleton or because the dependency library is very heavy. The downside of peerDependencies
is it put more responsibility for the app developers who are consuming the library.
- Need to add that library to the app-level
dependencies
. - If every lib lists everything as
peerDependencies
, the app will have a long list ofdependencies
that many of them are not used directly in the app code. - If this lib stop using
d3-color
, app developers need to remove it from their app'sdependencies
or it will become redundant dependencies. - If the app needs
d3-color
version that is not compatible with this library, then there is a conflict.
So if the library is small and does not have singleton requirement, we should list as dependencies
and rely on npm
or yarn
to handle that. This will encapsulate the dependencies and avoid the additional task for app developers to manage d3-color
as its dependencies
.
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.
Understood. And this totally makes sense. I'm wondering whether we can issue an "official" list of peerDependencies
supported by Superset that plugin developers can trust will always be available and stable. I'd imagine d3
packages to be one of them.
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.
"official" list of peerDependencies supported by Superset that plugin developers can trust will always be available and stable. I'd imagine d3 packages to be one of them.
Each plugin may be developed on current version of d3 but then later on if d3 upgrades over time, but some plugins did not migrate, some did, it will cause problem what version Superset should say official, because everybody tries to point to the same d3. At this point, it is not clear what value we actually gain from having d3 as peerDependencies
. It is better to use dependencies
.
Also, these plugins can also be used in another app that is not Superset.
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'd say packing multi versions of d3 to the client side is still something we should actively try to avoid. Maybe incorporate something like InspectPack would help.
829826c
to
af8512e
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.
Agree with the direction of the solution.
packages/superset-ui-legacy-preset-chart-big-number/src/BigNumber/transformProps.ts
Outdated
Show resolved
Hide resolved
packages/superset-ui-legacy-preset-chart-big-number/src/BigNumber/transformProps.ts
Outdated
Show resolved
Hide resolved
packages/superset-ui-legacy-preset-chart-big-number/src/BigNumber/transformProps.ts
Outdated
Show resolved
Hide resolved
packages/superset-ui-legacy-preset-chart-big-number/src/BigNumber/transformProps.ts
Show resolved
Hide resolved
packages/superset-ui-legacy-preset-chart-big-number/src/BigNumber/BigNumber.tsx
Outdated
Show resolved
Hide resolved
packages/superset-ui-legacy-preset-chart-big-number/src/BigNumber/BigNumber.tsx
Outdated
Show resolved
Hide resolved
packages/superset-ui-legacy-preset-chart-big-number/src/BigNumber/BigNumber.tsx
Outdated
Show resolved
Hide resolved
packages/superset-ui-legacy-preset-chart-big-number/src/BigNumber/BigNumber.tsx
Outdated
Show resolved
Hide resolved
packages/superset-ui-legacy-preset-chart-big-number/src/BigNumber/BigNumber.tsx
Outdated
Show resolved
Hide resolved
packages/superset-ui-legacy-preset-chart-big-number/src/BigNumber/BigNumber.tsx
Outdated
Show resolved
Hide resolved
Keep running into building errors locally, so upgrade nimbus and fix all related packages to the working latest version.
522bda3
to
14da264
Compare
package.json
Outdated
"@airbnb/config-prettier": "^2.0.4", | ||
"@airbnb/config-typescript": "^2.1.2", | ||
"@airbnb/nimbus": "^2.1.3", | ||
"@airbnb/config-babel": "2.2.4", |
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.
Why pin to specific version without ^
?
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 having trouble building. Couldn't figure out why. Just don't want to deal with the unpredictability. Sometimes even with the implied "not a breaking change" in a minor version upgrade, things might still break.
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 repo already check in yarn.lock
so if you did not modify these package version, it should be the same version that was working in master
. Could you try reseting yarn.lock
and package.json
to master
's version while keeping the changes you made to BigNumber
's package.json
and yarn install
again?
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.
Weird, it works... I'm pretty sure I tried that yesterday... Maybe it's because I inadvertently pined @types/shortid
.
I think it's probably not a bad idea to pin devDependencies
as they are unlikely to cause dependency hell and the added stability is valuable. Renovate actually pin the dependencies for you once you set it up.
packages/superset-ui-legacy-preset-chart-big-number/package.json
Outdated
Show resolved
Hide resolved
… range for trend lines (apache-superset#403) * feat(big-number): add option to align time range In Superset, when a timeseries query has no data at the beginning period or end period of the filtered time range, there will not no data records at those periods, hence the trendline in Big Number chart would not render those periods. This often causes confusion and misinterpretaiton in dashboards, especially for those with multiple trendline charts aligned with each other. They could all be a very smooth line, but actually showing very different time ranges. This PR adds an option "alignTimeRange" to apply the filtered time range on the xAxis. Date periods for empty data will be rendered, but there will be no connected lines, dots, or tooltips for them. It's possible to still show tooltips for those periods, but I decided not to do that as: 1) it makes things much more complicated; 2) I don't want to confuse zero or nulls with empty data. * fix(big-number): disable alignRange by default * refactor(big-number): migrate to Typescript * fix(big-number): typescript build * fix(big-number): change tooltip trigger; fix storybook * fix(big-number): move @types to dependencies * fix(big-number): move all files to ts * build(big-number): add @types/d3-color as dependency * refactor(big-number): remove renderTooltip as prop * feat(big-number): add timeRangeUseFallback options and some refactor * fix(big-number): update formatting functions * fix(big-number): update copy for no data * fix(big-number): address PR feedbacks * feat(big-number): replace timeRangeUseFallback with bigNumberFallback * fix: upgrade @types/react-bootstrap * build(big-number): move react-bootstrap to dependencies * refactor(big-number): more coherent types * feat(big-number): use alert box for fallback values * build(big-number): remove react-bootstrap * build: upgrade nimbus and fix versions Keep running into building errors locally, so upgrade nimbus and fix all related packages to the working latest version. * feat(big-number): adjust fallback warning alignment * build: use a non-fixed version for @types/shortid * build: revert package versions in main
🏆 Enhancements
The Big Number chart has two problems related to the handling of null values:
This PR adds option
timeRangeFixed
to fix the first problem and adds a "fallback to last available value" behavior to address the second problem.The
timeRangedFixed
option is disabled by default. When enabled, the empty starting and ending periods will take space on the x-axis, but there will be no connected lines, dots, or tooltips, just as if the metric values are NULL.In case the last record has a NULL value for the metric, we will go back to the last available value and display it in grayed out style (see screen shots below).
Superset backend needs to be updated to return
query.from_dttm
andquery.to_dttm
. Frontend needs to be updated to add two checkbox controls for these options ( apache/superset#9341).This PR also rewrote the Big Number chart plugin with Typescript.
Screenshot
Before
After
Above chart has a time range between 2001 to 2014, yet only since 2006 it starts to have data. When
timeRangeFixed
is enabled, it will render from the beginning of the parsed filter time range (2001), instead of when it starts to actually have data (2006).In Superset
Before
After
I also increased the default font sizes a little bit.
After
Test Plan
Go to storybook and make sure all examples for Big Number chart work.
There is also a new unit test to ensure
timeRangeUseFallback
works.Related
#402
ktmud#2
Reviewer
cc @kristw @etr2460