chore: replace Lodash usage with native JS implementation (#31907)

Signed-off-by: hainenber <dotronghai96@gmail.com>
This commit is contained in:
Đỗ Trọng Hải
2025-01-22 01:33:31 +07:00
committed by GitHub
parent eec374426f
commit f8fe780f52
17 changed files with 45 additions and 54 deletions

View File

@@ -16,7 +16,6 @@
* specific language governing permissions and limitations
* under the License.
*/
import { isNumber } from 'lodash';
import { DataRecord, DTTM_ALIAS, ValueFormatter } from '@superset-ui/core';
import type { OptionName } from 'echarts/types/src/util/types';
import type { TooltipMarker } from 'echarts/types/src/util/format';
@@ -64,7 +63,7 @@ export const extractForecastValuesFromTooltipParams = (
const { marker, seriesId, value } = param;
const context = extractForecastSeriesContext(seriesId);
const numericValue = isHorizontal ? value[0] : value[1];
if (isNumber(numericValue)) {
if (typeof numericValue === 'number') {
if (!(context.name in values))
values[context.name] = {
marker: marker || '',
@@ -97,7 +96,7 @@ export const formatForecastTooltipSeries = ({
formatter: ValueFormatter;
}): string[] => {
const name = `${marker}${sanitizeHtml(seriesName)}`;
let value = isNumber(observation) ? formatter(observation) : '';
let value = typeof observation === 'number' ? formatter(observation) : '';
if (forecastTrend || forecastLower || forecastUpper) {
// forecast values take the form of "20, y = 30 (10, 40)"
// where the first part is the observation, the second part is the forecast trend

View File

@@ -17,7 +17,7 @@
* under the License.
*/
import { DataRecord, DataRecordValue } from '@superset-ui/core';
import { groupBy as _groupBy, isNumber, transform } from 'lodash';
import { groupBy as _groupBy, transform } from 'lodash';
export type TreeNode = {
name: DataRecordValue;
@@ -28,7 +28,7 @@ export type TreeNode = {
};
function getMetricValue(datum: DataRecord, metric: string) {
return isNumber(datum[metric]) ? (datum[metric] as number) : 0;
return typeof datum[metric] === 'number' ? (datum[metric] as number) : 0;
}
export function treeBuilder(