From 2dbd417fdd1c9ef5cac6bd288bd29a20a0d8c99a Mon Sep 17 00:00:00 2001 From: Dominik Haentsch Date: Mon, 20 Nov 2023 09:09:58 +0100 Subject: [PATCH 1/5] feat: new number icon --- src/icons/Number.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/icons/Number.tsx b/src/icons/Number.tsx index 81820ebc..e87f48ec 100644 --- a/src/icons/Number.tsx +++ b/src/icons/Number.tsx @@ -1,8 +1,8 @@ import type { IconType } from 'react-icons'; -import { VscSymbolNumeric } from 'react-icons/vsc'; +import { GoNumber } from 'react-icons/go'; import tw from 'twin.macro'; const Number: IconType = tw( - VscSymbolNumeric + GoNumber )`w-4 h-4 font-semibold inline-block align-middle stroke-current`; export default Number; From e67046a0755d2dabe49218fad9136686903a8d0e Mon Sep 17 00:00:00 2001 From: Dominik Haentsch Date: Mon, 20 Nov 2023 09:22:28 +0100 Subject: [PATCH 2/5] refactor: remove unused settings store --- src/stores/settings.ts | 102 ----------------------------------------- 1 file changed, 102 deletions(-) delete mode 100644 src/stores/settings.ts diff --git a/src/stores/settings.ts b/src/stores/settings.ts deleted file mode 100644 index 5da38c2f..00000000 --- a/src/stores/settings.ts +++ /dev/null @@ -1,102 +0,0 @@ -import { produce } from 'immer'; -import _ from 'lodash'; -import { create } from 'zustand'; -import { DataColumn, Vec2 } from '../types'; - -type Domain = [number, number]; - -export interface Settings { - sequence: { - yAxis: { - multiple: boolean; - setMultiple: (multiple: boolean) => void; - domains: { [key: string]: [number, number] }; - syncDomain: (key: string, domain: Domain) => void; - unsyncDomain: (key: string) => void; - }; - xAxis: { - extents: Vec2; - setExtents: (ext: Vec2) => void; - isSynchronized: boolean; - setIsSynchronized: (value: boolean) => void; - }; - visibleColumns: Map; - setSelectableColumns: (columns: DataColumn[]) => void; - setIsColumnVisible: (column: DataColumn, isVisible: boolean) => void; - }; -} - -const useSettings = create((set) => { - const prod = (func: (draft: Settings) => void) => - set(produce(func) as (state: Settings) => Settings); - - return { - sequence: { - yAxis: { - multiple: false, - setMultiple: (multiple: boolean) => { - prod((d) => { - d.sequence.yAxis.multiple = multiple; - }); - }, - domains: {}, - syncDomain: (key: string, domain: Domain) => { - set((s) => ({ - sequence: { - ...s.sequence, - yAxis: { - ...s.sequence.yAxis, - domains: { - ...s.sequence.yAxis.domains, - [key]: domain, - }, - }, - }, - })); - }, - unsyncDomain: (key: string) => { - set((s) => ({ - sequence: { - ...s.sequence, - yAxis: { - ...s.sequence.yAxis, - domains: _.omit(s.sequence.yAxis.domains, key), - }, - }, - })); - }, - }, - xAxis: { - extents: [-Infinity, Infinity], - setExtents: (ext: Vec2) => { - prod((d) => { - d.sequence.xAxis.extents = ext; - }); - }, - isSynchronized: true, - setIsSynchronized: (value: boolean) => { - prod((d) => { - d.sequence.xAxis.isSynchronized = value; - }); - }, - }, - visibleColumns: new Map(), - setIsColumnVisible: (column: DataColumn, isVisible: boolean) => { - prod((d) => { - d.sequence.visibleColumns.set(column, isVisible); - }); - }, - setSelectableColumns: (columns: DataColumn[]) => { - prod((d) => { - columns.forEach( - (col) => - d.sequence.visibleColumns.get(col) === undefined && - d.sequence.visibleColumns.set(col, true) - ); - }); - }, - }, - }; -}); - -export default useSettings; From d80b0358e4e54cddc5ec25501abc70e960dde182 Mon Sep 17 00:00:00 2001 From: Dominik Haentsch Date: Mon, 20 Nov 2023 11:45:51 +0100 Subject: [PATCH 3/5] feat: configure notation of numbers through global setting --- src/components/AppBar.tsx | 32 +++ .../ColumnSelector/ColumnSelector.tsx | 6 +- src/components/FilterBar/FilterText.tsx | 17 +- src/components/FilterBar/ValueInput.tsx | 7 +- src/components/LineChart/LineChart.tsx | 34 ++- src/components/ScalarValue.tsx | 16 +- .../shared/Plot/Legend/ContinuousLegend.tsx | 14 +- src/components/shared/Plot/XAxis.tsx | 8 +- src/components/shared/Plot/YAxis.tsx | 8 +- src/{dataformat.ts => dataformat/index.ts} | 268 +++++++++--------- src/lenses/RougeScoreLens.tsx | 9 +- src/lib.ts | 2 +- src/stores/appSettings.ts | 27 ++ src/widgets/ConfusionMatrix/hooks.ts | 12 +- src/widgets/DataGrid/Cell/DefaultCell.tsx | 16 +- src/widgets/DataGrid/Cell/HeaderCell.tsx | 16 +- src/widgets/DataGrid/RelevanceIndicator.tsx | 6 +- .../ViewConfigurator/ViewConfigurator.tsx | 6 +- src/widgets/MetricsWidget/index.tsx | 8 +- 19 files changed, 287 insertions(+), 225 deletions(-) rename src/{dataformat.ts => dataformat/index.ts} (54%) create mode 100644 src/stores/appSettings.ts diff --git a/src/components/AppBar.tsx b/src/components/AppBar.tsx index 2b2799fe..9c776959 100644 --- a/src/components/AppBar.tsx +++ b/src/components/AppBar.tsx @@ -4,6 +4,7 @@ import GithubIcon from '../icons/Github'; import HelpIcon from '../icons/Help'; import OpenFolderIcon from '../icons/OpenFolder'; import ColorPaletteIcon from '../icons/ColorPalette'; +import NumberIcon from '../icons/Number'; import Button from './ui/Button'; import Dialog from './ui/Dialog'; import Dropdown, { DropdownContext } from './ui/Dropdown'; @@ -21,6 +22,8 @@ import MainWalkthrough, { import { useColors } from '../stores/colors'; import ColorPaletteSelect from './ui/ColorPaletteSelect'; import { categoricalPalettes, continuousPalettes } from '../palettes'; +import Select from './ui/Select'; +import { Notation, notations, useAppSettings } from '../stores/appSettings'; const NavBar = tw.nav`py-0.5 px-1 bg-gray-200 flex items-center w-full top-0 z-10 border-b border-gray-400`; @@ -190,6 +193,34 @@ const ColorMenu = () => { ); }; +const NumberMenu = () => { + const notation = useAppSettings((s) => s.numberNotation); + const onChangeNotation = (value?: Notation) => { + if (value) useAppSettings.getState().setNumberNotation(value); + }; + + const content = ( +
+ + Notation + +