Skip to content

Commit

Permalink
Merge pull request #258 from Renumics/feature/no-default-histogram-fo…
Browse files Browse the repository at this point in the history
…r-string-cols

dont show strings and ints by default in hist
  • Loading branch information
neindochoh authored Oct 9, 2023
2 parents 3086976 + efe3535 commit d3b38aa
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/widgets/Histogram/Histogram.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import Info from '../../components/ui/Info';
const columnsSelector = (d: Dataset) => d.columns;

const validTypes = ['Category', 'str', 'bool', 'int', 'float'];
const defaultTypes = ['Category', 'bool', 'float'];

const Histogram: Widget = () => {
const wrapper = useRef<HTMLDivElement>(null);
Expand All @@ -39,12 +40,21 @@ const Histogram: Widget = () => {
.map((col) => col.key),
[columns]
);
const defaultColumnKey = useMemo(
() =>
columns
.filter(
(col) => !col.isInternal && defaultTypes.includes(col.type.kind)
)
.map((col) => col.key)[0],
[columns]
);

const [filter, setFilter] = useWidgetConfig('filter', false);

const [_columnKey, setColumnKey] = useWidgetConfig<string | undefined>(
'columnKey',
columnKeys[0]
defaultColumnKey
);

const columnKey =
Expand Down

0 comments on commit d3b38aa

Please sign in to comment.