-
Notifications
You must be signed in to change notification settings - Fork 29
Merge Raw vis into Scalar vis #1770
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,36 +1,56 @@ | ||
| import { ScalarVis } from '@h5web/lib'; | ||
| import { | ||
| assertDataset, | ||
| assertPrintableType, | ||
| assertScalarShape, | ||
| } from '@h5web/shared/guards'; | ||
| import { DimensionMapper, getSliceSelection } from '@h5web/lib'; | ||
| import { assertDataset, assertNonNullShape } from '@h5web/shared/guards'; | ||
|
|
||
| import { useDimMappingState } from '../../../dim-mapping-store'; | ||
| import { useValuesInCache } from '../../../hooks'; | ||
| import visualizerStyles from '../../../visualizer/Visualizer.module.css'; | ||
| import { type VisContainerProps } from '../../models'; | ||
| import VisBoundary from '../../VisBoundary'; | ||
| import ValueFetcher from '../ValueFetcher'; | ||
| import { getFormatter } from './utils'; | ||
| import { useScalarConfig } from './config'; | ||
| import MappedScalarVis from './MappedScalarVis'; | ||
| import ScalarFetcher from './ScalarFetcher'; | ||
|
|
||
| function ScalarVisContainer(props: VisContainerProps) { | ||
| const { entity } = props; | ||
| const { entity, toolbarContainer } = props; | ||
| assertDataset(entity); | ||
| assertScalarShape(entity); | ||
| assertPrintableType(entity); | ||
|
Comment on lines
-17
to
-18
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| assertNonNullShape(entity); | ||
|
|
||
| const formatter = getFormatter(entity); | ||
| const { dims } = entity.shape; | ||
| const [dimMapping, setDimMapping] = useDimMappingState({ | ||
| dims, | ||
| axesCount: 0, // slicing only | ||
| }); | ||
|
|
||
| const config = useScalarConfig(); | ||
| const selection = getSliceSelection(dimMapping); | ||
| const canSliceFast = useValuesInCache(entity); | ||
|
|
||
| return ( | ||
| <VisBoundary> | ||
| <ValueFetcher | ||
| dataset={entity} | ||
| render={(value) => ( | ||
| <ScalarVis | ||
| className={visualizerStyles.vis} | ||
| value={formatter(value)} | ||
| /> | ||
| )} | ||
| /> | ||
| </VisBoundary> | ||
| <> | ||
| {dims.length > 0 && ( | ||
| <DimensionMapper | ||
| className={visualizerStyles.dimMapper} | ||
| dims={dims} | ||
| dimMapping={dimMapping} | ||
| canSliceFast={canSliceFast} | ||
| onChange={setDimMapping} | ||
| /> | ||
| )} | ||
| <VisBoundary resetKey={dimMapping} isSlice={dims.length > 0}> | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The code comes from |
||
| <ScalarFetcher | ||
| dataset={entity} | ||
| selection={selection} | ||
| render={(value) => ( | ||
| <MappedScalarVis | ||
| dataset={entity} | ||
| value={value} | ||
| toolbarContainer={toolbarContainer} | ||
| config={config} | ||
| /> | ||
| )} | ||
| /> | ||
| </VisBoundary> | ||
| </> | ||
| ); | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
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 renamed this component, since the term "Raw" no longer makes much sense.