Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve circulair import filler plugin #10247

Merged
merged 1 commit into from Mar 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
34 changes: 34 additions & 0 deletions 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;
}
30 changes: 2 additions & 28 deletions 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';

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/plugin.filler/filler.target.stack.js
Expand Up @@ -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
Expand Down