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

Commit

Permalink
feat: allow toggling of table viz's bar chart backgrounds (#352)
Browse files Browse the repository at this point in the history
* feat: allow toggling of bar chart backgrounds

* fix: inverting bar-chart-bg hide/show

* fix: keeping metrics right aligned
  • Loading branch information
rusackas committed Apr 13, 2020
1 parent 8a45c1a commit 5d5ade9
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 2 deletions.
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,10 @@
},
"eslint": {
"rules": {
"arrow-parens": ["warn", "as-needed"]
"arrow-parens": [
"warn",
"as-needed"
]
},
"overrides": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export const basic = () => (
orderDesc: true,
pageLength: 0,
percentMetrics: null,
showCellBars: true,
tableFilter: false,
tableTimestampFormat: '%Y-%m-%d %H:%M:%S',
timeseriesLimitMetric: null,
Expand Down
1 change: 1 addition & 0 deletions packages/superset-ui-demo/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"jsx": "react",
"outDir": "../../build/lib",
"rootDir": "../../",
"emitDeclarationOnly": false,
Expand Down
4 changes: 3 additions & 1 deletion plugins/table/src/ReactDataTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export default function ReactDataTable(props: DataTableProps) {
metrics: aggMetrics,
pageLength,
percentMetrics,
showCellBars = true,
tableTimestampFormat,
// orderDesc,
// TODO: add back the broken dashboard filters feature
Expand Down Expand Up @@ -236,6 +237,7 @@ export default function ReactDataTable(props: DataTableProps) {
const keyIsMetric = metricsSet.has(key);
const text = cellText(key, format, val);
const isHtml = !keyIsMetric && isProbablyHTML(text);
const showCellBar = keyIsMetric && showCellBars;
return (
<td
key={key}
Expand All @@ -244,7 +246,7 @@ export default function ReactDataTable(props: DataTableProps) {
data-sort={val}
className={keyIsMetric ? 'text-right' : ''}
style={{
backgroundImage: keyIsMetric ? cellBar(key, val as number) : undefined,
backgroundImage: showCellBar ? cellBar(key, val as number) : undefined,
}}
title={keyIsMetric || percentMetricsSet.has(key) ? String(val) : ''}
>
Expand Down
4 changes: 4 additions & 0 deletions plugins/table/src/transformProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export interface DataTableProps {
alignPositiveNegative: boolean;
colorPositiveNegative: boolean;
columns: DataColumnMeta[];
showCellBars: boolean;
metrics: string[];
percentMetrics: string[];
includeSearch: boolean;
Expand All @@ -55,6 +56,7 @@ export interface DataTableProps {
export interface TableChartFormData {
alignPn?: boolean;
colorPn?: boolean;
showCellBars?: boolean;
includeSearch?: boolean;
orderDesc?: boolean;
pageLength?: string;
Expand All @@ -80,6 +82,7 @@ export default function transformProps(chartProps: ChartProps): DataTableProps {
const {
alignPn = true,
colorPn = true,
showCellBars = true,
includeSearch = false,
orderDesc = false,
pageLength = 0,
Expand Down Expand Up @@ -118,6 +121,7 @@ export default function transformProps(chartProps: ChartProps): DataTableProps {
percentMetrics,
alignPositiveNegative: alignPn,
colorPositiveNegative: colorPn,
showCellBars,
includeSearch,
orderDesc,
pageLength: pageLength ? parseInt(pageLength, 10) : 0,
Expand Down
1 change: 1 addition & 0 deletions plugins/table/test/testData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { ChartProps } from '@superset-ui/chart';
const basicFormData = {
alignPn: false,
colorPn: false,
showCellBars: true,
includeSearch: false,
orderDesc: true,
pageLength: 0,
Expand Down

1 comment on commit 5d5ade9

@vercel
Copy link

@vercel vercel bot commented on 5d5ade9 Apr 13, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.