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


##########
superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/transformProps.ts:
##########
@@ -651,7 +694,14 @@ export default function transformProps(
 
     let displayName: string;
 
-    if (groupbyB.length > 0) {
+    if (!hasTimeComparison && truncateMetricB && groupbyB.length > 0) {

Review Comment:
   Good catch. Query B bypass now keys off `time_compare_b`, and A stays on 
`time_compare`.



##########
superset-frontend/plugins/plugin-chart-echarts/src/MixedTimeseries/transformProps.ts:
##########
@@ -544,7 +580,14 @@ export default function transformProps(
 
     let displayName: string;
 
-    if (groupby.length > 0) {
+    if (!hasTimeComparison && truncateMetric && groupby.length > 0) {
+      displayName = getTruncatedSeriesName({
+        labelMapValues: labelMapValues,

Review Comment:
   Applied the shorthand.



##########
superset-frontend/plugins/plugin-chart-echarts/test/MixedTimeseries/transformProps.test.ts:
##########
@@ -1967,3 +1967,145 @@ test('converts xAxisLabelInterval string "0" to number 
0', () => {
   // "All" must also disable hideOverlap so ECharts never drops a label.
   expect(xAxis.axisLabel.hideOverlap).toBe(false);
 });
+
+describe('truncateMetric / truncateMetricB', () => {
+  const getSeriesNames = (
+    overrides: Partial<EchartsMixedTimeseriesFormData>,
+  ) => {
+    const chartProps = createEchartsTimeseriesTestChartProps<
+      EchartsMixedTimeseriesFormData,
+      EchartsMixedTimeseriesProps
+    >({
+      ...MIXED_TIMESERIES_CHART_PROPS_DEFAULTS,
+      defaultQueriesData: queriesData,
+      formData: { ...formData, ...overrides },
+      queriesData,
+    });
+    const transformed = transformProps(chartProps);
+    return (transformed.echartOptions.series as SeriesOption[]).map(
+      s => s.name,
+    );
+  };
+
+  test('drops the metric prefix for both queries when both flags are on', () 
=> {
+    const seriesNames = getSeriesNames({
+      truncateMetric: true,
+      truncateMetricB: true,
+    });
+
+    expect(seriesNames).toContain('boy');
+    expect(seriesNames).toContain('girl');
+    expect(seriesNames).not.toContain('sum__num, boy');
+    expect(seriesNames).not.toContain('sum__num, girl');
+  });
+
+  test('keeps the "metric, dimension" name when both flags are off', () => {
+    const seriesNames = getSeriesNames({});
+
+    expect(seriesNames).toContain('sum__num, boy');
+    expect(seriesNames).toContain('sum__num, girl');
+  });
+
+  test('truncateMetricB truncates query B independently of query A', () => {
+    const seriesNames = getSeriesNames({ truncateMetricB: true });

Review Comment:
   Added a case with `showQueryIdentifiers` on that pins `sum__num (Query A), 
boy` against `boy (Query B)`, so swapped flags now fail.



-- 
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