fix(charts): add X Axis Number Format control for numeric X-axis columns (#38809)

Co-authored-by: codeant-ai-for-open-source[bot] <244253245+codeant-ai-for-open-source[bot]@users.noreply.github.com>
(cherry picked from commit e0a0a22542)
This commit is contained in:
Enzo Martellucci
2026-03-31 12:38:07 +02:00
committed by Michael S. Molina
parent 850c33fa6b
commit ddb285b4c3
13 changed files with 816 additions and 73 deletions

View File

@@ -407,6 +407,119 @@ describe('ControlPanelsContainer', () => {
getChartControlPanelRegistry().remove('line');
});
test('should stash control value when visibility is false and disableStash is not set', async () => {
getChartControlPanelRegistry().remove('table');
getChartControlPanelRegistry().registerValue('table', {
controlPanelSections: [
{
label: t('Query'),
expanded: true,
controlSetRows: [
[
{
name: 'x_axis_time_format',
config: {
type: 'SelectControl',
label: t('Time Format'),
default: 'smart_date',
choices: [['smart_date', 'Adaptive Formatting']],
visibility: () => false,
},
},
],
],
},
],
});
const props = getDefaultProps();
props.form_data = {
...props.form_data,
x_axis_time_format: 'smart_date',
};
const { getByTestId } = render(
<>
<ControlPanelsContainer {...props} />
<FormDataMock />
</>,
{
useRedux: true,
initialState: {
explore: {
form_data: {
...defaultState.form_data,
x_axis_time_format: 'smart_date',
},
},
},
},
);
await waitFor(() => {
expect(getByTestId('mock-formdata')).not.toHaveTextContent(
'x_axis_time_format',
);
});
});
test('should preserve control value when visibility is false and disableStash is true', async () => {
getChartControlPanelRegistry().remove('table');
getChartControlPanelRegistry().registerValue('table', {
controlPanelSections: [
{
label: t('Query'),
expanded: true,
controlSetRows: [
[
{
name: 'x_axis_time_format',
config: {
type: 'SelectControl',
label: t('Time Format'),
default: 'smart_date',
choices: [['smart_date', 'Adaptive Formatting']],
visibility: () => false,
disableStash: true,
},
},
],
],
},
],
});
const props = getDefaultProps();
props.form_data = {
...props.form_data,
x_axis_time_format: 'smart_date',
};
const { getByTestId } = render(
<>
<ControlPanelsContainer {...props} />
<FormDataMock />
</>,
{
useRedux: true,
initialState: {
explore: {
form_data: {
...defaultState.form_data,
x_axis_time_format: 'smart_date',
},
},
},
},
);
await waitFor(() => {
expect(getByTestId('mock-formdata')).toHaveTextContent(
'x_axis_time_format',
);
});
});
test('should not show Matrixify tab for table chart types', async () => {
// Enable Matrixify feature flag
mockIsFeatureEnabled.mockImplementation(