This is an automated email from the ASF dual-hosted git repository.
michaelsmolina pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git
The following commit(s) were added to refs/heads/master by this push:
new b4371f68b7 feat: Adds a control to set the Secondary Y-axis bounds in
Mixed charts (#23917)
b4371f68b7 is described below
commit b4371f68b77a98231619d0288578b49d57b21053
Author: Michael S. Molina <[email protected]>
AuthorDate: Fri May 5 10:11:54 2023 -0300
feat: Adds a control to set the Secondary Y-axis bounds in Mixed charts
(#23917)
Co-authored-by: Evan Rusackas <[email protected]>
---
.../src/MixedTimeseries/controlPanel.tsx | 21 +++++++++++++++++++--
.../src/MixedTimeseries/transformProps.ts | 12 +++++++++---
2 files changed, 28 insertions(+), 5 deletions(-)
diff --git
a/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/controlPanel.tsx
b/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/controlPanel.tsx
index c1a3007785..76abcb0b21 100644
---
a/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/controlPanel.tsx
+++
b/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/controlPanel.tsx
@@ -367,11 +367,11 @@ const config: ControlPanelConfig = {
name: 'y_axis_bounds',
config: {
type: 'BoundsControl',
- label: t('Y Axis Bounds'),
+ label: t('Primary y-axis Bounds'),
renderTrigger: true,
default: yAxisBounds,
description: t(
- 'Bounds for the Y-axis. When left empty, the bounds are ' +
+ 'Bounds for the primary Y-axis. When left empty, the bounds
are ' +
'dynamically defined based on the min/max of the data. Note
that ' +
"this feature will only expand the axis range. It won't " +
"narrow the data's extent.",
@@ -400,6 +400,23 @@ const config: ControlPanelConfig = {
},
},
],
+ [
+ {
+ name: 'y_axis_bounds_secondary',
+ config: {
+ type: 'BoundsControl',
+ label: t('Secondary y-axis Bounds'),
+ renderTrigger: true,
+ default: yAxisBounds,
+ description: t(
+ `Bounds for the secondary Y-axis. Only works when Independent
Y-axis
+ bounds are enabled. When left empty, the bounds are
dynamically defined
+ based on the min/max of the data. Note that this feature will
only expand
+ the axis range. It won't narrow the data's extent.`,
+ ),
+ },
+ },
+ ],
[
{
name: `y_axis_format_secondary`,
diff --git
a/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/transformProps.ts
b/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/transformProps.ts
index a924292980..d47b0047c9 100644
---
a/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/transformProps.ts
+++
b/superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/transformProps.ts
@@ -139,6 +139,7 @@ export default function transformProps(
yAxisFormatSecondary,
xAxisTimeFormat,
yAxisBounds,
+ yAxisBoundsSecondary,
yAxisIndex,
yAxisIndexB,
yAxisTitleSecondary,
@@ -285,10 +286,13 @@ export default function transformProps(
// yAxisBounds need to be parsed to replace incompatible values with
undefined
let [min, max] = (yAxisBounds || []).map(parseYAxisBound);
+ let [minSecondary, maxSecondary] = (yAxisBoundsSecondary || []).map(
+ parseYAxisBound,
+ );
const maxLabelFormatter = getOverMaxHiddenFormatter({ max, formatter });
const maxLabelFormatterSecondary = getOverMaxHiddenFormatter({
- max,
+ max: maxSecondary,
formatter: formatterSecondary,
});
@@ -348,6 +352,8 @@ export default function transformProps(
if (contributionMode === 'row' && stack) {
if (min === undefined) min = 0;
if (max === undefined) max = 1;
+ if (minSecondary === undefined) minSecondary = 0;
+ if (maxSecondary === undefined) maxSecondary = 1;
}
const tooltipFormatter =
@@ -415,8 +421,8 @@ export default function transformProps(
{
...defaultYAxis,
type: logAxisSecondary ? 'log' : 'value',
- min,
- max,
+ min: minSecondary,
+ max: maxSecondary,
minorTick: { show: true },
splitLine: { show: false },
minorSplitLine: { show: minorSplitLine },