From a80c2ba4e0e6fe35885a38e76229593705ffd2b7 Mon Sep 17 00:00:00 2001 From: Moritz Heckmann Date: Mon, 28 Oct 2024 15:33:33 +0100 Subject: [PATCH 1/8] Added the option to scale an axis logarithmically --- src/vis/scatter/ScatterVis.tsx | 2 +- src/vis/scatter/interfaces.ts | 3 ++ src/vis/scatter/useDataPreparation.ts | 18 ++------- src/vis/scatter/useLayout.tsx | 40 ++++++++++++++----- src/vis/scatter/utils.ts | 2 + .../Vis/Scatter/ScatterIris.stories.tsx | 2 + 6 files changed, 43 insertions(+), 24 deletions(-) diff --git a/src/vis/scatter/ScatterVis.tsx b/src/vis/scatter/ScatterVis.tsx index c7b53220b..209f509fb 100644 --- a/src/vis/scatter/ScatterVis.tsx +++ b/src/vis/scatter/ScatterVis.tsx @@ -115,7 +115,7 @@ export function ScatterVis({ // If the useAsync arguments change, clear the internal layout state. // Why not just use the config to compare things? // Because the useAsync takes one render cycle to update the value, and inbetween that, plotly has already updated the internalLayoutRef again with the old one. - if (args?.[1] !== previousArgs.current?.[1] || args?.[5] !== previousArgs.current?.[5]) { + if (args?.[1] !== previousArgs.current?.[1] || args?.[6] !== previousArgs.current?.[6] || args?.[3] !== previousArgs.current?.[3]) { internalLayoutRef.current = {}; previousArgs.current = args; } diff --git a/src/vis/scatter/interfaces.ts b/src/vis/scatter/interfaces.ts index 975ddc3d8..004f218ce 100644 --- a/src/vis/scatter/interfaces.ts +++ b/src/vis/scatter/interfaces.ts @@ -18,6 +18,9 @@ export interface IScatterConfig extends BaseVisConfig { regressionLineOptions?: IRegressionLineOptions; showLegend?: boolean; labelColumns?: ColumnInfo[]; + + xAxisType?: 'linear' | 'log'; + yAxisType?: 'linear' | 'log'; } /** diff --git a/src/vis/scatter/useDataPreparation.ts b/src/vis/scatter/useDataPreparation.ts index 112259ba0..40b66267c 100644 --- a/src/vis/scatter/useDataPreparation.ts +++ b/src/vis/scatter/useDataPreparation.ts @@ -185,21 +185,11 @@ export function useDataPreparation({ return index !== -1 ? index : Infinity; }); - let xDomain: [number, number] | [undefined, undefined] = [0, 1]; - let yDomain: [number, number] | [undefined, undefined] = [0, 1]; - // Get shared range for all plots - xDomain = d3v7.extent(value.validColumns[0].resolvedValues.map((v) => v.val as number)); - yDomain = d3v7.extent(value.validColumns[1].resolvedValues.map((v) => v.val as number)); - - if (xDomain[0] !== undefined && xDomain[1] !== undefined && yDomain[0] !== undefined && yDomain[1] !== undefined) { - const xStretch = xDomain[1] - xDomain[0]; - const yStretch = yDomain[1] - yDomain[0]; - console.log(xStretch, yStretch); - - xDomain = [xDomain[0] - xStretch * 0.5, xDomain[1] + xStretch * 0.5]; - yDomain = [yDomain[0] - yStretch * 0.5, yDomain[1] + yStretch * 0.5]; - } + const { xDomain, yDomain } = getStretchedDomains( + value.validColumns[0].resolvedValues.map((v) => v.val as number), + value.validColumns[1].resolvedValues.map((v) => v.val as number), + ); const resultData = groupedData.map((grouped, index) => { const idToIndex = new Map(); diff --git a/src/vis/scatter/useLayout.tsx b/src/vis/scatter/useLayout.tsx index 0102f2ad8..7c6df9b12 100644 --- a/src/vis/scatter/useLayout.tsx +++ b/src/vis/scatter/useLayout.tsx @@ -1,5 +1,6 @@ import * as React from 'react'; import clamp from 'lodash/clamp'; +import isFinite from 'lodash/isFinite'; import { PlotlyTypes } from '../../plotly'; import { VIS_NEUTRAL_COLOR, VIS_TRACES_COLOR } from '../general/constants'; import { IInternalScatterConfig } from './interfaces'; @@ -55,6 +56,21 @@ function gaps(width: number, height: number, nSubplots: number) { }; } +function toLogRange(axisType: 'linear' | 'log', domain: [number, number] | [undefined, undefined]) { + if (axisType === 'linear') { + return domain; + } + + const e0 = Math.log10(domain[0]); + const e1 = Math.log10(domain[1]); + + if (isFinite(e1)) { + return [isFinite(e0) ? e0 : 0, e1]; + } + + return [0, 1]; +} + export function useLayout({ scatter, facet, @@ -86,7 +102,8 @@ export function useLayout({ subplots.xyPairs.forEach((pair, plotCounter) => { axes[`xaxis${plotCounter > 0 ? plotCounter + 1 : ''}`] = { ...AXIS_TICK_STYLES, - range: pair.xDomain, + range: toLogRange(config.xAxisType!, pair.xDomain), + type: config.xAxisType, // Spread the previous layout to keep things like zoom ...(internalLayoutRef.current?.[`xaxis${plotCounter > 0 ? plotCounter + 1 : ''}` as 'xaxis'] || {}), title: { @@ -100,7 +117,8 @@ export function useLayout({ }; axes[`yaxis${plotCounter > 0 ? plotCounter + 1 : ''}`] = { ...AXIS_TICK_STYLES, - range: pair.yDomain, + range: toLogRange(config.yAxisType!, pair.yDomain), + type: config.yAxisType, // Spread the previous layout to keep things like zoom ...(internalLayoutRef.current?.[`yaxis${plotCounter > 0 ? plotCounter + 1 : ''}` as 'yaxis'] || {}), title: { @@ -171,8 +189,9 @@ export function useLayout({ ...BASE_LAYOUT, xaxis: { ...AXIS_TICK_STYLES, - range: scatter.xDomain, + range: toLogRange(config.xAxisType!, scatter.xDomain), ...internalLayoutRef.current?.xaxis, + type: config.xAxisType, title: { font: { size: 12, @@ -183,8 +202,9 @@ export function useLayout({ }, yaxis: { ...AXIS_TICK_STYLES, - range: scatter.yDomain, + range: toLogRange(config.yAxisType!, scatter.yDomain), ...internalLayoutRef.current?.yaxis, + type: config.yAxisType, title: { font: { size: 12, @@ -212,7 +232,8 @@ export function useLayout({ facet.resultData.forEach((group, plotCounter) => { axes[`xaxis${plotCounter > 0 ? plotCounter + 1 : ''}`] = { ...AXIS_TICK_STYLES, - range: facet.xDomain, + range: toLogRange(config.xAxisType!, facet.xDomain), + type: config.xAxisType, // Spread the previous layout to keep things like zoom ...(internalLayoutRef.current?.[`xaxis${plotCounter > 0 ? plotCounter + 1 : ''}` as 'xaxis'] || {}), ...(plotCounter > 0 ? { matches: 'x' } : {}), @@ -229,7 +250,8 @@ export function useLayout({ }; axes[`yaxis${plotCounter > 0 ? plotCounter + 1 : ''}`] = { ...AXIS_TICK_STYLES, - range: facet.yDomain, + range: toLogRange(config.yAxisType!, facet.yDomain), + type: config.yAxisType, // Spread the previous layout to keep things like zoom ...(internalLayoutRef.current?.[`yaxis${plotCounter > 0 ? plotCounter + 1 : ''}` as 'yaxis'] || {}), ...(plotCounter > 0 ? { matches: 'y' } : {}), @@ -302,14 +324,14 @@ export function useLayout({ // SPLOM case const axes: Record = {}; - const axis = () => + const axis = (which: string) => ({ ...AXIS_TICK_STYLES, }) as PlotlyTypes.LayoutAxis; for (let i = 0; i < splom.dimensions.length; i++) { - axes[`xaxis${i > 0 ? i + 1 : ''}`] = axis(); - axes[`yaxis${i > 0 ? i + 1 : ''}`] = axis(); + axes[`xaxis${i > 0 ? i + 1 : ''}`] = axis('x'); + axes[`yaxis${i > 0 ? i + 1 : ''}`] = axis('y'); } const finalLayout: Partial = { diff --git a/src/vis/scatter/utils.ts b/src/vis/scatter/utils.ts index 9a7648982..da93d3eb7 100644 --- a/src/vis/scatter/utils.ts +++ b/src/vis/scatter/utils.ts @@ -42,6 +42,8 @@ export const defaultConfig: IScatterConfig = { lineStyle: defaultRegressionLineStyle, showStats: true, }, + xAxisType: 'linear', + yAxisType: 'linear', }; export function scatterMergeDefaultConfig(columns: VisColumn[], config: IScatterConfig): IScatterConfig { diff --git a/src/vis/stories/Vis/Scatter/ScatterIris.stories.tsx b/src/vis/stories/Vis/Scatter/ScatterIris.stories.tsx index dd9859072..f8d0f5520 100644 --- a/src/vis/stories/Vis/Scatter/ScatterIris.stories.tsx +++ b/src/vis/stories/Vis/Scatter/ScatterIris.stories.tsx @@ -48,6 +48,8 @@ Basic.args = { name: 'Sepal Width', }, ], + xAxisType: 'log', + yAxisType: 'log', color: null, facets: null, numColorScaleType: ENumericalColorScaleType.SEQUENTIAL, From 49b8381f377713853db8489f16944a7ebe810259 Mon Sep 17 00:00:00 2001 From: Moritz Heckmann Date: Tue, 29 Oct 2024 09:23:31 +0100 Subject: [PATCH 2/8] Added option on sidebar to change scale type --- src/vis/scatter/ScatterVis.tsx | 8 +++++++- src/vis/scatter/ScatterVisSidebar.tsx | 29 ++++++++++++++++++++++++++- src/vis/scatter/useLayout.tsx | 2 +- 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/src/vis/scatter/ScatterVis.tsx b/src/vis/scatter/ScatterVis.tsx index 209f509fb..555c01901 100644 --- a/src/vis/scatter/ScatterVis.tsx +++ b/src/vis/scatter/ScatterVis.tsx @@ -115,7 +115,13 @@ export function ScatterVis({ // If the useAsync arguments change, clear the internal layout state. // Why not just use the config to compare things? // Because the useAsync takes one render cycle to update the value, and inbetween that, plotly has already updated the internalLayoutRef again with the old one. - if (args?.[1] !== previousArgs.current?.[1] || args?.[6] !== previousArgs.current?.[6] || args?.[3] !== previousArgs.current?.[3]) { + if ( + args?.[1] !== previousArgs.current?.[1] || + args?.[6] !== previousArgs.current?.[6] || + args?.[3] !== previousArgs.current?.[3] || + config?.xAxisType !== internalLayoutRef.current?.xaxis?.type || + config?.yAxisType !== internalLayoutRef.current?.yaxis?.type + ) { internalLayoutRef.current = {}; previousArgs.current = args; } diff --git a/src/vis/scatter/ScatterVisSidebar.tsx b/src/vis/scatter/ScatterVisSidebar.tsx index fad89e5ab..1fb95437f 100644 --- a/src/vis/scatter/ScatterVisSidebar.tsx +++ b/src/vis/scatter/ScatterVisSidebar.tsx @@ -1,4 +1,4 @@ -import { Divider } from '@mantine/core'; +import { Divider, Select } from '@mantine/core'; import merge from 'lodash/merge'; import * as React from 'react'; import { useMemo } from 'react'; @@ -131,6 +131,33 @@ export function ScatterVisSidebar({ config, optionsConfig, columns, filterCallba ) : null} + + { + setConfig({ ...config, yAxisType: value as 'log' | 'linear' }); + }} + /> + {filterCallback && mergedOptionsConfig.filter.enable ? mergedOptionsConfig.filter.customComponent || ( <> diff --git a/src/vis/scatter/useLayout.tsx b/src/vis/scatter/useLayout.tsx index 7c6df9b12..528ed2801 100644 --- a/src/vis/scatter/useLayout.tsx +++ b/src/vis/scatter/useLayout.tsx @@ -58,7 +58,7 @@ function gaps(width: number, height: number, nSubplots: number) { function toLogRange(axisType: 'linear' | 'log', domain: [number, number] | [undefined, undefined]) { if (axisType === 'linear') { - return domain; + return [...domain]; } const e0 = Math.log10(domain[0]); From 5c7a1b710c05958e1ccfc39e5ff46a8fa8550606 Mon Sep 17 00:00:00 2001 From: Moritz Heckmann Date: Tue, 29 Oct 2024 11:20:35 +0100 Subject: [PATCH 3/8] Removed large delay when coloring facets --- src/vis/general/utils.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/vis/general/utils.ts b/src/vis/general/utils.ts index 424ad10f5..f771259e7 100644 --- a/src/vis/general/utils.ts +++ b/src/vis/general/utils.ts @@ -1,5 +1,12 @@ import { NAN_REPLACEMENT, VIS_NEUTRAL_COLOR } from './constants'; +const formatter = new Intl.NumberFormat('en-US', { + maximumFractionDigits: 4, + maximumSignificantDigits: 4, + notation: 'compact', + compactDisplay: 'short', +}); + /** * * @param label the label to check for undefined, null or empty @@ -7,12 +14,6 @@ import { NAN_REPLACEMENT, VIS_NEUTRAL_COLOR } from './constants'; * @returns the label if it is not undefined, null or empty, otherwise NAN_REPLACEMENT (Unknown) */ export function getLabelOrUnknown(label: string | number | null | undefined, unknownLabel: string = NAN_REPLACEMENT): string { - const formatter = new Intl.NumberFormat('en-US', { - maximumFractionDigits: 4, - maximumSignificantDigits: 4, - notation: 'compact', - compactDisplay: 'short', - }); return label === null || label === 'null' || label === undefined || label === 'undefined' || label === '' ? unknownLabel : Number(label) && !Number.isInteger(label) // if it is a number, but not an integer, apply NumberFormat From 3347c055daff5de2daab67bd0290fd0978a80349 Mon Sep 17 00:00:00 2001 From: Holger Stitz Date: Tue, 29 Oct 2024 13:10:25 +0100 Subject: [PATCH 4/8] style: update select label --- src/vis/scatter/ScatterVisSidebar.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/vis/scatter/ScatterVisSidebar.tsx b/src/vis/scatter/ScatterVisSidebar.tsx index 1fb95437f..f3cee0fdc 100644 --- a/src/vis/scatter/ScatterVisSidebar.tsx +++ b/src/vis/scatter/ScatterVisSidebar.tsx @@ -133,7 +133,7 @@ export function ScatterVisSidebar({ config, optionsConfig, columns, filterCallba : null} Date: Tue, 29 Oct 2024 13:10:36 +0100 Subject: [PATCH 5/8] chore: remove orphan variable --- src/vis/scatter/useLayout.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vis/scatter/useLayout.tsx b/src/vis/scatter/useLayout.tsx index 528ed2801..592ae3798 100644 --- a/src/vis/scatter/useLayout.tsx +++ b/src/vis/scatter/useLayout.tsx @@ -324,7 +324,7 @@ export function useLayout({ // SPLOM case const axes: Record = {}; - const axis = (which: string) => + const axis = () => ({ ...AXIS_TICK_STYLES, }) as PlotlyTypes.LayoutAxis; From c28e8df786538e9821d3866ca06117f8b081abd5 Mon Sep 17 00:00:00 2001 From: Holger Stitz Date: Tue, 29 Oct 2024 13:12:22 +0100 Subject: [PATCH 6/8] refactor: rename `*AxisType` to `*AxisType` --- src/vis/scatter/ScatterVis.tsx | 4 ++-- src/vis/scatter/ScatterVisSidebar.tsx | 8 +++---- src/vis/scatter/interfaces.ts | 11 +++++++-- src/vis/scatter/useLayout.tsx | 24 +++++++++---------- src/vis/scatter/utils.ts | 4 ++-- .../Vis/Scatter/ScatterIris.stories.tsx | 4 ++-- 6 files changed, 31 insertions(+), 24 deletions(-) diff --git a/src/vis/scatter/ScatterVis.tsx b/src/vis/scatter/ScatterVis.tsx index 555c01901..a9f2c8cf0 100644 --- a/src/vis/scatter/ScatterVis.tsx +++ b/src/vis/scatter/ScatterVis.tsx @@ -119,8 +119,8 @@ export function ScatterVis({ args?.[1] !== previousArgs.current?.[1] || args?.[6] !== previousArgs.current?.[6] || args?.[3] !== previousArgs.current?.[3] || - config?.xAxisType !== internalLayoutRef.current?.xaxis?.type || - config?.yAxisType !== internalLayoutRef.current?.yaxis?.type + config?.xAxisScale !== internalLayoutRef.current?.xaxis?.type || + config?.yAxisScale !== internalLayoutRef.current?.yaxis?.type ) { internalLayoutRef.current = {}; previousArgs.current = args; diff --git a/src/vis/scatter/ScatterVisSidebar.tsx b/src/vis/scatter/ScatterVisSidebar.tsx index f3cee0fdc..0bfbc1fc7 100644 --- a/src/vis/scatter/ScatterVisSidebar.tsx +++ b/src/vis/scatter/ScatterVisSidebar.tsx @@ -139,9 +139,9 @@ export function ScatterVisSidebar({ config, optionsConfig, columns, filterCallba { value: 'log', label: 'Logarithmic' }, ]} clearable={false} - value={config.xAxisType} + value={config.xAxisScale} onChange={(value) => { - setConfig({ ...config, xAxisType: value as 'log' | 'linear' }); + setConfig({ ...config, xAxisScale: value as 'log' | 'linear' }); }} /> @@ -152,9 +152,9 @@ export function ScatterVisSidebar({ config, optionsConfig, columns, filterCallba { value: 'log', label: 'Logarithmic' }, ]} clearable={false} - value={config.yAxisType} + value={config.yAxisScale} onChange={(value) => { - setConfig({ ...config, yAxisType: value as 'log' | 'linear' }); + setConfig({ ...config, yAxisScale: value as 'log' | 'linear' }); }} /> diff --git a/src/vis/scatter/interfaces.ts b/src/vis/scatter/interfaces.ts index 004f218ce..42ab03eef 100644 --- a/src/vis/scatter/interfaces.ts +++ b/src/vis/scatter/interfaces.ts @@ -19,8 +19,15 @@ export interface IScatterConfig extends BaseVisConfig { showLegend?: boolean; labelColumns?: ColumnInfo[]; - xAxisType?: 'linear' | 'log'; - yAxisType?: 'linear' | 'log'; + /** + * Scale type of the x-axis (linear or log) + */ + xAxisScale?: 'linear' | 'log'; + + /** + * Scale type of the y-axis (linear or log) + */ + yAxisScale?: 'linear' | 'log'; } /** diff --git a/src/vis/scatter/useLayout.tsx b/src/vis/scatter/useLayout.tsx index 592ae3798..9fae73aa3 100644 --- a/src/vis/scatter/useLayout.tsx +++ b/src/vis/scatter/useLayout.tsx @@ -102,8 +102,8 @@ export function useLayout({ subplots.xyPairs.forEach((pair, plotCounter) => { axes[`xaxis${plotCounter > 0 ? plotCounter + 1 : ''}`] = { ...AXIS_TICK_STYLES, - range: toLogRange(config.xAxisType!, pair.xDomain), - type: config.xAxisType, + range: toLogRange(config.xAxisScale!, pair.xDomain), + type: config.xAxisScale, // Spread the previous layout to keep things like zoom ...(internalLayoutRef.current?.[`xaxis${plotCounter > 0 ? plotCounter + 1 : ''}` as 'xaxis'] || {}), title: { @@ -117,8 +117,8 @@ export function useLayout({ }; axes[`yaxis${plotCounter > 0 ? plotCounter + 1 : ''}`] = { ...AXIS_TICK_STYLES, - range: toLogRange(config.yAxisType!, pair.yDomain), - type: config.yAxisType, + range: toLogRange(config.yAxisScale!, pair.yDomain), + type: config.yAxisScale, // Spread the previous layout to keep things like zoom ...(internalLayoutRef.current?.[`yaxis${plotCounter > 0 ? plotCounter + 1 : ''}` as 'yaxis'] || {}), title: { @@ -189,9 +189,9 @@ export function useLayout({ ...BASE_LAYOUT, xaxis: { ...AXIS_TICK_STYLES, - range: toLogRange(config.xAxisType!, scatter.xDomain), + range: toLogRange(config.xAxisScale!, scatter.xDomain), ...internalLayoutRef.current?.xaxis, - type: config.xAxisType, + type: config.xAxisScale, title: { font: { size: 12, @@ -202,9 +202,9 @@ export function useLayout({ }, yaxis: { ...AXIS_TICK_STYLES, - range: toLogRange(config.yAxisType!, scatter.yDomain), + range: toLogRange(config.yAxisScale!, scatter.yDomain), ...internalLayoutRef.current?.yaxis, - type: config.yAxisType, + type: config.yAxisScale, title: { font: { size: 12, @@ -232,8 +232,8 @@ export function useLayout({ facet.resultData.forEach((group, plotCounter) => { axes[`xaxis${plotCounter > 0 ? plotCounter + 1 : ''}`] = { ...AXIS_TICK_STYLES, - range: toLogRange(config.xAxisType!, facet.xDomain), - type: config.xAxisType, + range: toLogRange(config.xAxisScale!, facet.xDomain), + type: config.xAxisScale, // Spread the previous layout to keep things like zoom ...(internalLayoutRef.current?.[`xaxis${plotCounter > 0 ? plotCounter + 1 : ''}` as 'xaxis'] || {}), ...(plotCounter > 0 ? { matches: 'x' } : {}), @@ -250,8 +250,8 @@ export function useLayout({ }; axes[`yaxis${plotCounter > 0 ? plotCounter + 1 : ''}`] = { ...AXIS_TICK_STYLES, - range: toLogRange(config.yAxisType!, facet.yDomain), - type: config.yAxisType, + range: toLogRange(config.yAxisScale!, facet.yDomain), + type: config.yAxisScale, // Spread the previous layout to keep things like zoom ...(internalLayoutRef.current?.[`yaxis${plotCounter > 0 ? plotCounter + 1 : ''}` as 'yaxis'] || {}), ...(plotCounter > 0 ? { matches: 'y' } : {}), diff --git a/src/vis/scatter/utils.ts b/src/vis/scatter/utils.ts index da93d3eb7..d707c6ea4 100644 --- a/src/vis/scatter/utils.ts +++ b/src/vis/scatter/utils.ts @@ -42,8 +42,8 @@ export const defaultConfig: IScatterConfig = { lineStyle: defaultRegressionLineStyle, showStats: true, }, - xAxisType: 'linear', - yAxisType: 'linear', + xAxisScale: 'linear', + yAxisScale: 'linear', }; export function scatterMergeDefaultConfig(columns: VisColumn[], config: IScatterConfig): IScatterConfig { diff --git a/src/vis/stories/Vis/Scatter/ScatterIris.stories.tsx b/src/vis/stories/Vis/Scatter/ScatterIris.stories.tsx index f8d0f5520..46f11052c 100644 --- a/src/vis/stories/Vis/Scatter/ScatterIris.stories.tsx +++ b/src/vis/stories/Vis/Scatter/ScatterIris.stories.tsx @@ -48,8 +48,8 @@ Basic.args = { name: 'Sepal Width', }, ], - xAxisType: 'log', - yAxisType: 'log', + xAxisScale: 'log', + yAxisScale: 'log', color: null, facets: null, numColorScaleType: ENumericalColorScaleType.SEQUENTIAL, From a31fe5f8fe73e9c6ff8ac6f27ac3f155d71ae331 Mon Sep 17 00:00:00 2001 From: Moritz Heckmann Date: Mon, 4 Nov 2024 12:01:07 +0100 Subject: [PATCH 7/8] removed x,y for splom --- src/vis/scatter/useLayout.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/vis/scatter/useLayout.tsx b/src/vis/scatter/useLayout.tsx index 9fae73aa3..22569297b 100644 --- a/src/vis/scatter/useLayout.tsx +++ b/src/vis/scatter/useLayout.tsx @@ -330,8 +330,8 @@ export function useLayout({ }) as PlotlyTypes.LayoutAxis; for (let i = 0; i < splom.dimensions.length; i++) { - axes[`xaxis${i > 0 ? i + 1 : ''}`] = axis('x'); - axes[`yaxis${i > 0 ? i + 1 : ''}`] = axis('y'); + axes[`xaxis${i > 0 ? i + 1 : ''}`] = axis(); + axes[`yaxis${i > 0 ? i + 1 : ''}`] = axis(); } const finalLayout: Partial = { From 94e519c96b2b00296f4d4e297e0b4036701fb9de Mon Sep 17 00:00:00 2001 From: Moritz Heckmann Date: Tue, 5 Nov 2024 11:47:06 +0100 Subject: [PATCH 8/8] added safeguard for log scale / markers+text --- src/vis/scatter/useData.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/vis/scatter/useData.tsx b/src/vis/scatter/useData.tsx index fe1219fae..ab73491ef 100644 --- a/src/vis/scatter/useData.tsx +++ b/src/vis/scatter/useData.tsx @@ -80,7 +80,7 @@ export function useData({ yaxis: pair.yref, textposition: subplots.text.map((_, i) => textPositionOptions[i % textPositionOptions.length]), ...(isEmpty(selectedList) ? {} : { selectedpoints: selectedList.map((idx) => subplots.idToIndex.get(idx)) }), - mode: config.showLabels === ELabelingOptions.NEVER ? 'markers' : 'text+markers', + mode: config.showLabels === ELabelingOptions.NEVER || config.xAxisScale === 'log' || config.yAxisScale === 'log' ? 'markers' : 'text+markers', ...(config.showLabels === ELabelingOptions.NEVER ? {} : config.showLabels === ELabelingOptions.ALWAYS @@ -118,7 +118,7 @@ export function useData({ // text: scatter.plotlyData.text, textposition: scatter.plotlyData.text.map((_, i) => textPositionOptions[i % textPositionOptions.length]), ...(isEmpty(selectedList) ? {} : { selectedpoints: selectedList.map((idx) => scatter.idToIndex.get(idx)) }), - mode: config.showLabels === ELabelingOptions.NEVER ? 'markers' : 'text+markers', + mode: config.showLabels === ELabelingOptions.NEVER || config.xAxisScale === 'log' || config.yAxisScale === 'log' ? 'markers' : 'text+markers', ...(config.showLabels === ELabelingOptions.NEVER ? {} : config.showLabels === ELabelingOptions.ALWAYS @@ -162,7 +162,7 @@ export function useData({ y: group.data.y, xaxis: group.xref, yaxis: group.yref, - mode: config.showLabels === ELabelingOptions.NEVER ? 'markers' : 'text+markers', + mode: config.showLabels === ELabelingOptions.NEVER || config.xAxisScale === 'log' || config.yAxisScale === 'log' ? 'markers' : 'text+markers', textposition: group.data.text.map((_, i) => textPositionOptions[i % textPositionOptions.length]), ...(config.showLabels === ELabelingOptions.NEVER ? {}