mirror of
https://github.com/apache/superset.git
synced 2026-06-08 17:19:20 +00:00
Remove isNumeric util function and use Number.isFinite instead (#6106)
* remove isNumeric util function and use lodash isFinite instead * use native Number.isFinite
This commit is contained in:
committed by
Chris Williams
parent
58be31af3f
commit
0aa6d90429
@@ -21,10 +21,6 @@ export function kmToPixels(kilometers, latitude, zoomLevel) {
|
||||
return d3.round(kilometers / kmPerPixel, 2);
|
||||
}
|
||||
|
||||
export function isNumeric(num) {
|
||||
return !isNaN(parseFloat(num)) && isFinite(num);
|
||||
}
|
||||
|
||||
export function rgbLuminance(r, g, b) {
|
||||
// Formula: https://en.wikipedia.org/wiki/Relative_luminance
|
||||
return LUMINANCE_RED_WEIGHT * r + LUMINANCE_GREEN_WEIGHT * g + LUMINANCE_BLUE_WEIGHT * b;
|
||||
|
||||
@@ -6,7 +6,6 @@ import ViewportMercator from 'viewport-mercator-project';
|
||||
import {
|
||||
kmToPixels,
|
||||
rgbLuminance,
|
||||
isNumeric,
|
||||
MILES_PER_KM,
|
||||
} from '../../utils/common';
|
||||
|
||||
@@ -154,7 +153,7 @@ class ScatterPlotGlowOverlay extends React.Component {
|
||||
ctx.fillStyle = gradient;
|
||||
ctx.fill();
|
||||
|
||||
if (isNumeric(clusterLabel)) {
|
||||
if (Number.isFinite(parseFloat(clusterLabel))) {
|
||||
if (clusterLabel >= 10000) {
|
||||
clusterLabel = Math.round(clusterLabel / 1000) + 'k';
|
||||
} else if (clusterLabel >= 1000) {
|
||||
@@ -187,7 +186,9 @@ class ScatterPlotGlowOverlay extends React.Component {
|
||||
}
|
||||
|
||||
if (pointMetric !== null) {
|
||||
pointLabel = isNumeric(pointMetric) ? d3.round(pointMetric, 2) : pointMetric;
|
||||
pointLabel = Number.isFinite(parseFloat(pointMetric))
|
||||
? d3.round(pointMetric, 2)
|
||||
: pointMetric;
|
||||
}
|
||||
|
||||
// Fall back to default points if pointRadius wasn't a numerical column
|
||||
|
||||
Reference in New Issue
Block a user