Do explicit imports for d3 instead of wildcards

This commit is contained in:
Adrian Hall
2020-05-11 07:10:04 +01:00
parent 8ef3aee7e7
commit 053a86c0d4
20 changed files with 136 additions and 118 deletions

View File

@@ -1,7 +1,34 @@
import * as d3 from 'd3';
import {
curveBasis,
curveBasisClosed,
curveBasisOpen,
curveLinear,
curveLinearClosed,
curveMonotoneX,
curveMonotoneY,
curveNatural,
curveStep,
curveStepAfter,
curveStepBefore
} from 'd3';
import { logger } from './logger';
import { sanitizeUrl } from '@braintree/sanitize-url';
// Effectively an enum of the supported curve types, accessible by name
const d3CurveTypes = {
curveBasis: curveBasis,
curveBasisClosed: curveBasisClosed,
curveBasisOpen: curveBasisOpen,
curveLinear: curveLinear,
curveLinearClosed: curveLinearClosed,
curveMonotoneX: curveMonotoneX,
curveMonotoneY: curveMonotoneY,
curveNatural: curveNatural,
curveStep: curveStep,
curveStepAfter: curveStepAfter,
curveStepBefore: curveStepBefore
};
/**
* @function detectType
* Detects the type of the graph text.
@@ -85,7 +112,7 @@ export const interpolateToCurve = (interpolate, defaultCurve) => {
return defaultCurve;
}
const curveName = `curve${interpolate.charAt(0).toUpperCase() + interpolate.slice(1)}`;
return d3[curveName] || defaultCurve;
return d3CurveTypes[curveName] || defaultCurve;
};
export const formatUrl = (linkStr, config) => {