mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-08-30 05:36:43 +02:00
Do explicit imports for d3 instead of wildcards
This commit is contained in:
31
src/utils.js
31
src/utils.js
@@ -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) => {
|
||||
|
Reference in New Issue
Block a user