LuisSanchez commented on code in PR #36989:
URL: https://github.com/apache/superset/pull/36989#discussion_r2674558559


##########
superset-frontend/plugins/plugin-chart-echarts/test/Timeseries/transformProps.test.ts:
##########
@@ -723,3 +727,171 @@ describe('legend sorting', () => {
     ]);
   });
 });
+
+describe('Horizontal bar chart axis bounds', () => {
+  const baseFormData: SqlaFormData = {
+    colorScheme: 'bnbColors',
+    datasource: '3__table',
+    granularity_sqla: '__timestamp',
+    metric: 'sum__num',
+    groupby: [],
+    viz_type: 'echarts_timeseries',
+    seriesType: EchartsTimeseriesSeriesType.Bar,
+    orientation: OrientationType.Horizontal,
+    truncateYAxis: true,
+    yAxisBounds: [null, null],
+  };
+
+  it('should set yAxis max to actual data max for horizontal bar charts', () 
=> {
+    const queriesData = [
+      {
+        data: [
+          { 'Series A': 15000, __timestamp: 599616000000 },
+          { 'Series A': 20000, __timestamp: 599916000000 },
+          { 'Series A': 18000, __timestamp: 600216000000 },
+        ],
+      },
+    ];
+
+    const chartProps = new ChartProps({
+      formData: baseFormData,
+      width: 800,
+      height: 600,
+      queriesData,
+      theme: supersetTheme,
+    });
+
+    const transformedProps = transformProps(
+      chartProps as EchartsTimeseriesChartProps,
+    );
+
+    // In horizontal orientation, axes are swapped, so yAxis becomes xAxis
+    const xAxis = transformedProps.echartOptions.xAxis as any;

Review Comment:
   Applied



##########
superset-frontend/plugins/plugin-chart-echarts/test/Timeseries/transformProps.test.ts:
##########
@@ -723,3 +727,171 @@ describe('legend sorting', () => {
     ]);
   });
 });
+
+describe('Horizontal bar chart axis bounds', () => {
+  const baseFormData: SqlaFormData = {
+    colorScheme: 'bnbColors',
+    datasource: '3__table',
+    granularity_sqla: '__timestamp',
+    metric: 'sum__num',
+    groupby: [],
+    viz_type: 'echarts_timeseries',
+    seriesType: EchartsTimeseriesSeriesType.Bar,
+    orientation: OrientationType.Horizontal,
+    truncateYAxis: true,
+    yAxisBounds: [null, null],
+  };
+
+  it('should set yAxis max to actual data max for horizontal bar charts', () 
=> {
+    const queriesData = [
+      {
+        data: [
+          { 'Series A': 15000, __timestamp: 599616000000 },
+          { 'Series A': 20000, __timestamp: 599916000000 },
+          { 'Series A': 18000, __timestamp: 600216000000 },
+        ],
+      },
+    ];
+
+    const chartProps = new ChartProps({
+      formData: baseFormData,
+      width: 800,
+      height: 600,
+      queriesData,
+      theme: supersetTheme,
+    });
+
+    const transformedProps = transformProps(
+      chartProps as EchartsTimeseriesChartProps,
+    );
+
+    // In horizontal orientation, axes are swapped, so yAxis becomes xAxis
+    const xAxis = transformedProps.echartOptions.xAxis as any;
+    expect(xAxis.max).toBe(20000); // Should be the actual max value, not 
rounded
+  });
+
+  it('should set yAxis min and max for diverging horizontal bar charts', () => 
{
+    const queriesData = [
+      {
+        data: [
+          { 'Series A': -21000, __timestamp: 599616000000 },
+          { 'Series A': 20000, __timestamp: 599916000000 },
+          { 'Series A': 18000, __timestamp: 600216000000 },
+        ],
+      },
+    ];
+
+    const chartProps = new ChartProps({
+      formData: baseFormData,
+      width: 800,
+      height: 600,
+      queriesData,
+      theme: supersetTheme,
+    });
+
+    const transformedProps = transformProps(
+      chartProps as EchartsTimeseriesChartProps,
+    );
+
+    // In horizontal orientation, axes are swapped, so yAxis becomes xAxis
+    const xAxis = transformedProps.echartOptions.xAxis as any;

Review Comment:
   Applied



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