Skip to content

Commit bf4a2e1

Browse files
authored
Merge pull request #639 from vizzuhq/preset_axis
Fix: determine main axis based on preset name
2 parents 9c1d26a + fac6120 commit bf4a2e1

File tree

2 files changed

+21
-13
lines changed

2 files changed

+21
-13
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## [Unreleased]
44

5+
## [0.17.0] - 2025-07-31
6+
57
### Fixed
68

79
- Split chart handled when same dimension on main and sub axis.

src/apps/weblib/ts-api/plugins/presets.ts

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -181,23 +181,29 @@ export default class Presets {
181181
})
182182
}
183183

184-
private _getMainAxis(presetConfig: Config.Chart): keyof Config.Channels {
185-
const channel = presetConfig.channels?.x
186-
if (
187-
this._isChannel(channel) &&
188-
channel.set?.find((series) => {
189-
return series.name === 'stackedBy' || series.name === 'splittedBy'
190-
})
191-
) {
192-
return 'y' as keyof Config.Channels
193-
}
194-
195-
return 'x' as keyof Config.Channels
184+
private _getMainAxis(presetName: PresetNames): keyof Config.Channels {
185+
const presetsWithYMainAxis = new Set([
186+
'bar',
187+
'groupedBar',
188+
'stackedBar',
189+
'splittedBar',
190+
'percentageBar',
191+
'verticalStream',
192+
'verticalViolin',
193+
'verticalLine',
194+
'pie',
195+
'radialBar',
196+
'radialStackedBar',
197+
'donut',
198+
'nestedDonut'
199+
])
200+
201+
return presetsWithYMainAxis.has(presetName) ? 'y' : 'x'
196202
}
197203

198204
private _buildPresetConfig(presetName: PresetNames, config: Config.Chart): Config.Chart {
199205
const presetConfig = this._createPresetConfig(presetName)
200-
const mainAxis = this._getMainAxis(presetConfig)
206+
const mainAxis = this._getMainAxis(presetName)
201207
this._fillChannels(presetConfig, config)
202208
this._setupUserParams(presetConfig, config, mainAxis)
203209
return presetConfig

0 commit comments

Comments
 (0)