Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions packages/app/src/vis-packs/core/complex/MappedComplexLineVis.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,14 @@ function MappedComplexLineVis(props: Props) {
} = props;

const { visType } = config;
const { customDomain, yScaleType, xScaleType, curveType, showGrid } =
lineConfig;
const {
customDomain,
yScaleType,
xScaleType,
curveType,
showGrid,
exactNotation,
} = lineConfig;

const numAxisArrays = useToNumArrays(axisValues);
const [dataArray, ...auxArrays] = useMappedComplexArrays(
Expand Down Expand Up @@ -110,6 +116,7 @@ function MappedComplexLineVis(props: Props) {
label: auxLabels[i],
array,
}))}
exactNotation={exactNotation}
testid={dimMapping.toString()}
/>
</>
Expand Down
2 changes: 2 additions & 0 deletions packages/app/src/vis-packs/core/complex/MappedComplexVis.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ function MappedComplexVis(props: Props) {
keepRatio,
showGrid,
invertColorMap,
exactNotation,
} = heatmapConfig;

const numAxisArrays = useToNumArrays(axisValues);
Expand Down Expand Up @@ -111,6 +112,7 @@ function MappedComplexVis(props: Props) {
scaleType={scaleType}
aspect={keepRatio ? 'equal' : 'auto'}
showGrid={showGrid}
exactNotation={exactNotation}
invertColorMap={invertColorMap}
abscissaParams={{
label: axisLabels[xDimIndex],
Expand Down
10 changes: 10 additions & 0 deletions packages/app/src/vis-packs/core/heatmap/HeatmapToolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { COLOR_SCALE_TYPES } from '@h5web/shared/vis-utils';
import {
MdAspectRatio,
MdGridOn,
MdQueryStats,
MdSwapHoriz,
MdSwapVert,
} from 'react-icons/md';
Expand All @@ -39,6 +40,7 @@ function HeatmapToolbar(props: Props) {
invertColorMap,
flipXAxis,
flipYAxis,
exactNotation,
setCustomDomain,
setColorMap,
setScaleType,
Expand All @@ -47,6 +49,7 @@ function HeatmapToolbar(props: Props) {
toggleColorMapInversion,
toggleXAxisFlip,
toggleYAxisFlip,
toggleExactNotation,
} = config;

return (
Expand Down Expand Up @@ -105,6 +108,13 @@ function HeatmapToolbar(props: Props) {
onToggle={toggleGrid}
/>

<ToggleBtn
label="Exact"
Icon={MdQueryStats}
value={exactNotation}
onToggle={toggleExactNotation}
/>

<Separator />

{exportEntries.length > 0 && (
Expand Down
2 changes: 2 additions & 0 deletions packages/app/src/vis-packs/core/heatmap/MappedHeatmapVis.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ function MappedHeatmapVis(props: Props) {
invertColorMap,
flipXAxis,
flipYAxis,
exactNotation,
} = config;

const numArray = useToNumArray(value);
Expand Down Expand Up @@ -116,6 +117,7 @@ function MappedHeatmapVis(props: Props) {
}}
flipXAxis={flipXAxis}
flipYAxis={flipYAxis}
exactNotation={exactNotation}
ignoreValue={ignoreValue}
/>
</>
Expand Down
7 changes: 7 additions & 0 deletions packages/app/src/vis-packs/core/heatmap/config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ export interface HeatmapConfig {

flipYAxis: boolean;
toggleYAxisFlip: () => void;

exactNotation: boolean;
toggleExactNotation: () => void;
}

function createHeatmapConfigStore() {
Expand Down Expand Up @@ -69,6 +72,10 @@ function createHeatmapConfigStore() {
flipXAxis: false,
toggleXAxisFlip: () =>
set((state) => ({ flipXAxis: !state.flipXAxis })),

exactNotation: false,
toggleExactNotation: () =>
set((state) => ({ exactNotation: !state.exactNotation })),
}),
{
name: 'h5web:heatmap',
Expand Down
11 changes: 10 additions & 1 deletion packages/app/src/vis-packs/core/line/LineToolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
} from '@h5web/lib';
import { type Domain, type ExportEntry } from '@h5web/shared/vis-models';
import { AXIS_SCALE_TYPES } from '@h5web/shared/vis-utils';
import { MdGridOn } from 'react-icons/md';
import { MdGridOn, MdQueryStats } from 'react-icons/md';

import { INTERACTIONS_WITH_AXIAL_ZOOM } from '../utils';
import { type LineConfig } from './config';
Expand All @@ -34,12 +34,14 @@ function LineToolbar(props: Props) {
xScaleType,
yScaleType,
showErrors,
exactNotation,
setCustomDomain,
setCurveType,
toggleGrid,
setXScaleType,
setYScaleType,
toggleErrors,
toggleExactNotation,
} = config;

return (
Expand Down Expand Up @@ -82,6 +84,13 @@ function LineToolbar(props: Props) {
onToggle={toggleGrid}
/>

<ToggleBtn
label="Exact"
Icon={MdQueryStats}
value={exactNotation}
onToggle={toggleExactNotation}
/>

<Separator />

<ToggleGroup
Expand Down
2 changes: 2 additions & 0 deletions packages/app/src/vis-packs/core/line/MappedLineVis.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ function MappedLineVis(props: Props) {
curveType,
showGrid,
showErrors,
exactNotation,
} = config;

const { shape: dims } = dataset;
Expand Down Expand Up @@ -160,6 +161,7 @@ function MappedLineVis(props: Props) {
errorsArray={errorsArray}
showErrors={showErrors}
auxiliaries={auxiliaries}
exactNotation={exactNotation}
testid={dimMapping.toString()}
ignoreValue={ignoreValue}
/>
Expand Down
7 changes: 7 additions & 0 deletions packages/app/src/vis-packs/core/line/config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ export interface LineConfig {

showErrors: boolean;
toggleErrors: () => void;

exactNotation: boolean;
toggleExactNotation: () => void;
}

function createLineConfigStore() {
Expand All @@ -47,6 +50,10 @@ function createLineConfigStore() {

showErrors: true,
toggleErrors: () => set((state) => ({ showErrors: !state.showErrors })),

exactNotation: false,
toggleExactNotation: () =>
set((state) => ({ exactNotation: !state.exactNotation })),
}),
{
name: 'h5web:line',
Expand Down
16 changes: 12 additions & 4 deletions packages/lib/src/vis/heatmap/HeatmapVis.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ interface Props extends ClassStyleAttrs {
minFilter?: MinificationTextureFilter;
flipXAxis?: boolean;
flipYAxis?: boolean;
exactNotation?: boolean;
renderTooltip?: (data: TooltipData) => ReactElement;
children?: ReactNode;
interactions?: DefaultInteractionsConfig;
Expand All @@ -74,13 +75,15 @@ function HeatmapVis(props: Props) {
minFilter,
flipXAxis,
flipYAxis,
exactNotation,
renderTooltip,
children,
interactions,
ignoreValue,
className = '',
style,
} = props;

const { label: abscissaLabel, value: abscissaValue } = abscissaParams;
const { label: ordinateLabel, value: ordinateValue } = ordinateParams;
const { rows, cols } = getDims(dataArray);
Expand Down Expand Up @@ -142,12 +145,17 @@ function HeatmapVis(props: Props) {

return (
<>
{`${abscissaLabel ?? 'x'}=${formatTooltipVal(abscissa)}, `}
{`${ordinateLabel ?? 'y'}=${formatTooltipVal(ordinate)}`}
{`${abscissaLabel ?? 'x'}=${exactNotation ? abscissa : formatTooltipVal(abscissa)}, `}
{`${ordinateLabel ?? 'y'}=${exactNotation ? ordinate : formatTooltipVal(ordinate)}`}
<div className={styles.tooltipValue}>
<strong>{formatTooltipVal(dataArray.get(yi, xi))}</strong>
<strong>
{exactNotation
? dataArray.get(yi, xi)
: formatTooltipVal(dataArray.get(yi, xi))}
</strong>
{dtype && <em>{` (${dtype})`}</em>}
{alpha && ` (${formatTooltipVal(alpha.array.get(yi, xi))})`}
{alpha &&
` (${exactNotation ? alpha.array.get(yi, xi) : formatTooltipVal(alpha.array.get(yi, xi))})`}
</div>
</>
);
Expand Down
18 changes: 13 additions & 5 deletions packages/lib/src/vis/line/LineVis.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ interface Props extends ClassStyleAttrs {
errorsArray?: NdArray<NumArray>;
showErrors?: boolean;
auxiliaries?: AuxiliaryParams[];
exactNotation?: boolean;
renderTooltip?: (data: TooltipData) => ReactElement;
children?: ReactNode;
interactions?: DefaultInteractionsConfig;
Expand All @@ -58,6 +59,7 @@ function LineVis(props: Props) {
errorsArray,
showErrors = false,
auxiliaries = [],
exactNotation,
renderTooltip,
children,
interactions,
Expand Down Expand Up @@ -137,7 +139,7 @@ function LineVis(props: Props) {

return (
<>
{`${abscissaLabel ?? 'x'} = ${formatTooltipVal(abscissa)}`}
{`${abscissaLabel ?? 'x'} = ${exactNotation ? abscissa : formatTooltipVal(abscissa)}`}

<div className={styles.tooltipValue}>
{auxiliaries.length > 0 && (
Expand All @@ -148,8 +150,11 @@ function LineVis(props: Props) {
/>
)}
<span>
<strong>{formatTooltipVal(value)}</strong>
{error !== undefined && ` ±${formatTooltipErr(error)}`}
<strong>
{exactNotation ? value : formatTooltipVal(value)}
</strong>
{error !== undefined &&
` ±${exactNotation ? error : formatTooltipErr(error)}`}
{dtype && <em>{` (${dtype})`}</em>}
</span>
</div>
Expand All @@ -162,8 +167,11 @@ function LineVis(props: Props) {
style={{ color: auxColors[index % auxColors.length] }}
/>
{label ? `${label} = ` : ''}
{formatTooltipVal(array.get(xi))}
{errors && ` ±${formatTooltipErr(errors.get(xi))}`}
{exactNotation
? array.get(xi)
: formatTooltipVal(array.get(xi))}
{errors &&
` ±${exactNotation ? errors.get(xi) : formatTooltipErr(errors.get(xi))}`}
</div>
))}
</>
Expand Down
2 changes: 1 addition & 1 deletion packages/lib/src/vis/shared/TooltipMesh.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ interface Props {
}

function TooltipMesh(props: Props) {
const { guides, renderTooltip, size } = props;
const { size, guides, renderTooltip } = props;
const { canvasSize, worldToData } = useVisCanvasContext();
const { width, height } = canvasSize;

Expand Down
Loading