-
Notifications
You must be signed in to change notification settings - Fork 272
feat(plugin-chart-table): add column config control #1019
Conversation
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/superset/superset-ui/7YwTThF26FAcKh31pR5iXHr92sxB |
be03bb6
to
6f4cca2
Compare
Codecov Report
@@ Coverage Diff @@
## master #1019 +/- ##
==========================================
- Coverage 27.93% 27.68% -0.25%
==========================================
Files 417 427 +10
Lines 8608 8747 +139
Branches 1242 1311 +69
==========================================
+ Hits 2405 2422 +17
- Misses 6043 6152 +109
- Partials 160 173 +13
Continue to review full report at Codecov.
|
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.
halfway through
label: 'circular', | ||
value: 'circular', | ||
}, | ||
['force', t('Force')], |
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.
Is this related to the table?
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 changed the signature of the RadioButtonControl
to make it more consistent with the SelectControl
.
const [isHtml, text, customClassName] = formatValue(column, value); | ||
const style = { | ||
let rounded = value; | ||
if (fractionDigits !== undefined && isNumber && typeof value === 'number') { |
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.
fractionDigits !== undefined && isNumber
can be computed outside of function.
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 can move isNumber
out, fractionDigits !== undefined
would still be needed here since it can also be zero and I am using its real value later.
if (value === null) { | ||
return [false, 'N/A', 'dt-is-null']; |
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.
Do we no longer need this flag?
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.
Yes, it is moved to inline code as I realized this is not very generalized for formatValue
.
Also tried to use inline Emotion's css
prop but thought manually constructed css classNames are still faster, especially that we need to set it for every cell.
*/ | ||
debounceDelay?: number; | ||
} & (T extends 'Select' | ||
? { |
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.
Would it worth extracting the type definition after ?
into named type
?
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 don't think it's worth it as you'd have to name them and reference them. The indirectness means you'd have to jump back and forth when glancing through code. I also don't see much added value in terms of readability.
const [showAllColumns, setShowAllColumns] = useState(false); | ||
|
||
const getColumnInfo = (col: string) => columnConfigs[col] || {}; | ||
const setColumnConfig = (col: string, config: T) => { |
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.
useCallback
?
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 don't think this matters much in practice. This is only used in an event handler---onChange
of ColumnConfigItem
, which shouldn't trigger the component's re-render if it's the only prob being updated.
@@ -18,7 +18,7 @@ | |||
*/ | |||
import React from 'react'; | |||
import { Tooltip } from './Tooltip'; | |||
import { ColumnTypeLabel } from './ColumnTypeLabel'; | |||
import { ColumnTypeLabel, LaxColumnType } from './ColumnTypeLabel'; |
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 is Lax
?
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.
Like less strict... Supposedly column types should be mutually exclusive, but we also have some more random types from different places. LaxColumnType
makes sure the column type icon component can accept all these types, while more strict ColumnType
will be used elsewhere.
This is great improvement, thank you Jesse! Are you planning to implement more enhancements to table chart? |
@junlincc I don't have any other major work planned for table viz. |
After this PR is merged, I'll work on implementing totals if you don't mind |
@kristw Hey Krist, is this PR ready to move forward? we are happy to take it from here. 🙏 |
Thanks. I think I'm good with the current. |
Merging and will do a follow up PR if there are any bugs surfacing up while testing. |
Is the expected behavior - stretch to fit fit screen by default? @ktmud Screen.Recording.2021-04-28.at.10.48.37.PM.mov |
A couple more issues..
Screen.Recording.2021-04-28.at.11.47.20.PM.mov |
🏆 Enhancements
Add column formatting control to table chart, allowing users to change things like column width, text align, number/date formatting per column, all in the Explore view itself (previously you are able to set d3 formats per column, but you'd have to do it via calculated columns or saved metrics).
Also added a separate formatting config for small numbers, so that they can be display as
0
when needed. This is useful when you want to apply human readable SI prefix to big numbers, but don't want to add that to small numbers. When there are both small (abs(x) < 1
) and large numbers, users often confusem
for 10-3 withM
for 103 (e.g.$1.3m
is actually $0.0013, not $1,300,000, the latter would be formatted as$1.3M
). By having a separate formatting for small numbers, users can then decide whether to display them as0
or how many significant digits to use for them.Must used together with apache/superset#13758 , which passed query responses to chart controls.
After
column.formatting.demo.mp4
Before