From 1742f8e484b09c3590a36c9d78701d46d1e1517b Mon Sep 17 00:00:00 2001 From: Jacco van den Berg Date: Fri, 18 Mar 2022 16:21:25 +0100 Subject: [PATCH] resolve circulair import --- src/plugins/plugin.filler/filler.helper.js | 34 +++++++++++++++++++ src/plugins/plugin.filler/filler.target.js | 30 ++-------------- .../plugin.filler/filler.target.stack.js | 2 +- 3 files changed, 37 insertions(+), 29 deletions(-) create mode 100644 src/plugins/plugin.filler/filler.helper.js diff --git a/src/plugins/plugin.filler/filler.helper.js b/src/plugins/plugin.filler/filler.helper.js new file mode 100644 index 00000000000..ec9fcdbd704 --- /dev/null +++ b/src/plugins/plugin.filler/filler.helper.js @@ -0,0 +1,34 @@ +/** + * @typedef { import('../../core/core.controller').default } Chart + * @typedef { import('../../core/core.scale').default } Scale + * @typedef { import('../../elements/element.point').default } PointElement + */ + +import {LineElement} from '../../elements'; +import {isArray} from '../../helpers'; +import {_pointsFromSegments} from './filler.segment'; + +/** + * @param {PointElement[] | { x: number; y: number; }} boundary + * @param {LineElement} line + * @return {LineElement?} + */ +export function _createBoundaryLine(boundary, line) { + let points = []; + let _loop = false; + + if (isArray(boundary)) { + _loop = true; + // @ts-ignore + points = boundary; + } else { + points = _pointsFromSegments(boundary, line); + } + + return points.length ? new LineElement({ + points, + options: {tension: 0}, + _loop, + _fullLoop: _loop + }) : null; +} diff --git a/src/plugins/plugin.filler/filler.target.js b/src/plugins/plugin.filler/filler.target.js index e7dbf3dfb14..2547636c274 100644 --- a/src/plugins/plugin.filler/filler.target.js +++ b/src/plugins/plugin.filler/filler.target.js @@ -1,7 +1,6 @@ -import {LineElement} from '../../elements'; -import {isArray, isFinite} from '../../helpers'; +import {isFinite} from '../../helpers'; +import {_createBoundaryLine} from './filler.helper'; import {_getTargetPixel, _getTargetValue} from './filler.options'; -import {_pointsFromSegments} from './filler.segment'; import {_buildStackLine} from './filler.target.stack'; import {simpleArc} from './simpleArc'; @@ -35,31 +34,6 @@ export function _getTarget(source) { return _createBoundaryLine(boundary, line); } -/** - * @param {PointElement[] | { x: number; y: number; }} boundary - * @param {LineElement} line - * @return {LineElement?} - */ -export function _createBoundaryLine(boundary, line) { - let points = []; - let _loop = false; - - if (isArray(boundary)) { - _loop = true; - // @ts-ignore - points = boundary; - } else { - points = _pointsFromSegments(boundary, line); - } - - return points.length ? new LineElement({ - points, - options: {tension: 0}, - _loop, - _fullLoop: _loop - }) : null; -} - /** * @param {Chart} chart * @param {number} index diff --git a/src/plugins/plugin.filler/filler.target.stack.js b/src/plugins/plugin.filler/filler.target.stack.js index dcb974b8470..b32fa1fb54e 100644 --- a/src/plugins/plugin.filler/filler.target.stack.js +++ b/src/plugins/plugin.filler/filler.target.stack.js @@ -6,7 +6,7 @@ import {LineElement} from '../../elements'; import {_isBetween} from '../../helpers'; -import {_createBoundaryLine} from './filler.target'; +import {_createBoundaryLine} from './filler.helper'; /** * @param {{ chart: Chart; scale: Scale; index: number; line: LineElement; }} source