[Dashboards] - Min Max range on secondary axis bar charts (#15118)
video QA https://github.com/user-attachments/assets/70c37188-2398-43de-bbf6-5882bb79940a --------- Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
+35
@@ -0,0 +1,35 @@
|
||||
import { type ChartConfiguration } from '@/command-menu/pages/page-layout/types/ChartConfiguration';
|
||||
import { CHART_CONFIGURATION_SETTING_IDS } from '@/command-menu/pages/page-layout/types/ChartConfigurationSettingIds';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
export const isMinMaxRangeValid = (
|
||||
settingId:
|
||||
| CHART_CONFIGURATION_SETTING_IDS.MIN_RANGE
|
||||
| CHART_CONFIGURATION_SETTING_IDS.MAX_RANGE,
|
||||
newValue: number,
|
||||
configuration: ChartConfiguration,
|
||||
): boolean => {
|
||||
if (!('rangeMax' in configuration || 'rangeMin' in configuration)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (settingId === CHART_CONFIGURATION_SETTING_IDS.MIN_RANGE) {
|
||||
if (
|
||||
isDefined(configuration.rangeMax) &&
|
||||
newValue > configuration.rangeMax
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (settingId === CHART_CONFIGURATION_SETTING_IDS.MAX_RANGE) {
|
||||
if (
|
||||
isDefined(configuration.rangeMin) &&
|
||||
newValue < configuration.rangeMin
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
Reference in New Issue
Block a user