Skip to content
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

Size SVGs explicitly in axis system to fix zoom bug in Chrome #977

Merged
merged 3 commits into from
Feb 22, 2022
Merged
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
Binary file modified cypress/snapshots/app.spec.ts/auxspectrum.snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified cypress/snapshots/app.spec.ts/bgr_image.snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified cypress/snapshots/app.spec.ts/edit_domain.snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified cypress/snapshots/app.spec.ts/fullscreen.snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified cypress/snapshots/app.spec.ts/heatmap_2D.snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified cypress/snapshots/app.spec.ts/heatmap_2D_complex.snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified cypress/snapshots/app.spec.ts/heatmap_2D_inverted_cmap.snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified cypress/snapshots/app.spec.ts/heatmap_4d_default.snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified cypress/snapshots/app.spec.ts/heatmap_4d_remapped.snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified cypress/snapshots/app.spec.ts/heatmap_4d_sliced.snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified cypress/snapshots/app.spec.ts/heatmap_4d_zeros.snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified cypress/snapshots/app.spec.ts/line_1D.snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified cypress/snapshots/app.spec.ts/line_complex_1D.snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified cypress/snapshots/app.spec.ts/logspectrum.snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified cypress/snapshots/app.spec.ts/nximage.snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified cypress/snapshots/app.spec.ts/nxrgb.snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified cypress/snapshots/app.spec.ts/nxspectrum.snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified cypress/snapshots/app.spec.ts/rgb_image.snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 4 additions & 3 deletions packages/lib/src/vis/shared/Axis.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@ interface Props {
config: AxisConfig;
domain: Domain;
canvasSize: Size;
svgSize: Size;
flipAxis?: boolean;
}

function Axis(props: Props) {
const { type, config, domain, canvasSize, flipAxis } = props;
const { type, config, domain, canvasSize, svgSize, flipAxis } = props;

const { width, height } = canvasSize;
const axisLength = type === 'abscissa' ? width : height;
Expand All @@ -57,7 +58,7 @@ function Axis(props: Props) {

return (
<>
<svg className={styles.axis} data-type={type}>
<svg className={styles.axis} style={svgSize} data-type={type}>
<AxisComponent
scale={scale}
tickFormat={getTickFormatter(domain, axisLength, scaleType)}
Expand All @@ -69,7 +70,7 @@ function Axis(props: Props) {
/>
</svg>
{showGrid && (
<svg className={styles.grid}>
<svg className={styles.grid} style={canvasSize}>
loichuder marked this conversation as resolved.
Show resolved Hide resolved
<GridComponent
scale={scale}
width={width}
Expand Down
12 changes: 4 additions & 8 deletions packages/lib/src/vis/shared/AxisSystem.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
display: grid;
grid-template-areas:
'. top-axis .'
'. axis-grid right-axis'
'left-axis grid right-axis'
'. bottom-axis .';

/* - Prevent panning/zooming from axis when zoomed in.
Expand All @@ -13,19 +13,15 @@
.axisSystem > svg {
display: block;
overflow: visible;

/* Avoid potential overflow caused by default intrinsic size of `svg` elements. */
/* Chrome/Edge require values greater than 0. */
width: 1px;
height: 1px;
}

.axis[data-type='abscissa'] {
grid-area: bottom-axis;
}

.axis[data-type='ordinate'] {
grid-area: axis-grid;
grid-area: left-axis;
transform: translateX(100%);
loichuder marked this conversation as resolved.
Show resolved Hide resolved
}

.axis > g > line {
Expand Down Expand Up @@ -66,7 +62,7 @@
}

.grid {
grid-area: axis-grid;
grid-area: grid;
}

.grid line {
Expand Down
2 changes: 2 additions & 0 deletions packages/lib/src/vis/shared/AxisSystem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,14 @@ function AxisSystem(props: Props) {
config={abscissaConfig}
domain={xVisibleDomain}
canvasSize={canvasSize}
svgSize={{ width, height: axisOffsets.bottom }}
/>
<Axis
type="ordinate"
config={ordinateConfig}
domain={yVisibleDomain}
canvasSize={canvasSize}
svgSize={{ width: axisOffsets.left, height }}
flipAxis
/>
</Html>
Expand Down