rusackas commented on code in PR #42713:
URL: https://github.com/apache/superset/pull/42713#discussion_r3752763682


##########
superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/transformProps.ts:
##########
@@ -844,6 +844,8 @@ export default function transformProps(
         },
         scale: truncateYAxis,
         name: yAxisTitleSecondary,
+        nameGap: convertInteger(yAxisTitleMargin),
+        nameLocation: yAxisTitlePosition === 'Left' ? 'middle' : 'end',

Review Comment:
   Good catch, fixed. Computed 
`convertInteger(yAxisTitleMargin)`/`convertInteger(xAxisTitleMargin)` once as 
`yAxisTitleMarginPx`/`xAxisTitleMarginPx` and reused across both yAxis entries, 
the xAxis, and the padding calcs.



##########
superset-frontend/plugins/plugin-chart-echarts/test/MixedTimeseries/transformProps.test.ts:
##########
@@ -1243,3 +1243,55 @@ test('regression #37921: multi-metric Query A with 
groupby does not duplicate fi
     expect(name).not.toMatch(/score_one,\s+score_two/);
   }
 });
+
+test('y-axis title position: Left sets nameLocation to middle', () => {
+  const chartProps = createEchartsTimeseriesTestChartProps<
+    EchartsMixedTimeseriesFormData,
+    EchartsMixedTimeseriesProps
+  >({
+    ...MIXED_TIMESERIES_CHART_PROPS_DEFAULTS,
+    defaultQueriesData: queriesData,
+    formData: {
+      ...formData,
+      yAxisTitlePosition: 'Left',
+      yAxisTitleMargin: 20,
+    },
+    queriesData,
+  });
+  const transformed = transformProps(chartProps as 
EchartsMixedTimeseriesProps);
+
+  expect((transformed.echartOptions.yAxis as any)[0].nameGap).toEqual(20);
+  expect((transformed.echartOptions.yAxis as any)[0].nameLocation).toEqual(
+    'middle',
+  );
+  expect((transformed.echartOptions.yAxis as any)[1].nameGap).toEqual(20);
+  expect((transformed.echartOptions.yAxis as any)[1].nameLocation).toEqual(
+    'middle',
+  );

Review Comment:
   Fixed, replaced the repeated `as any` casts with a single typed cast on 
`transformed.echartOptions.yAxis` in each test.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to