Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// If none of the above criterias are met assume that we
// are dealing with a completely new dataset
if (pointsFrom.length < pointsTo.length) {
const seqPos = findSequencePositionInArray(pointsTo, pointsFrom);
return seqPos ? { frontDelta: seqPos.start, backDelta: pointsTo.length - seqPos.stop - 1 } : null;
}
if (pointsFrom.length > pointsTo.length) {
const seqPos = findSequencePositionInArray(pointsFrom, pointsTo);
return seqPos ? { frontDelta: -seqPos.start, backDelta: seqPos.stop + 1 - pointsFrom.length } : null;
}
for (let i = 1; i < pointsFrom.length; i++) {
if (pointsFrom[i] === pointsTo[0]) {
if (arrayEqual(pointsFrom.slice(i), pointsTo.slice(0, pointsTo.length - i))) {
return { frontDelta: -i, backDelta: i };
}
}
}
return null;
}
const buttons = activePath.reduce((buttons, pathIndex, index) => {
const child = pathChildren[pathIndex];
// Written like this because of Flow type refinements.
if (stringFound || typeof child === 'string') {
stringFound = true;
return buttons;
}
pathChildren = child.props.children;
const key = getElementKey(child);
// Enforce autoFocus via activePath. Remember autoFocus uses identity.
const autoFocus = index === activePath.length - 1 && activePath;
buttonPath = buttonPath.concat(pathIndex);
const active =
activeSection === 'element' && arrayEqual(activePath, buttonPath);
return [
...buttons,
{child.type}
,
];
}, []);
const {
points,
stroke,
strokeWidth,
className,
style,
...rest
} = this.props;
const { width, height, pointsFrom, pointsTo } = this.state;
const styles = Object.assign({
width: !this.props.width ? '100%' : `${width}px`,
height: !this.props.height ? '100%' : `${height}px`,
}, style);
let pointsToRender;
if (!pointsFrom || arrayEqual(pointsFrom, pointsTo)) {
pointsToRender = transformPoints(points, width, height, strokeWidth);
}
return (
<svg viewBox="{`0" style="{styles}"> {
this.svgNode = node;
}}
>
</svg>
chartScales.scales.forEach(chartScale => {
if (arrayEquals(scale, chartScale)) {
result.push(chartScales.constructor);
}
});
});
function pointInterpolator(pointsFrom, pointsTo, width, height, strokeWidth) {
if (!pointsFrom || arrayEqual(pointsFrom, pointsTo)) {
return null;
}
const from = pointsFrom.length === 1 ? [...pointsFrom, ...pointsFrom] : pointsFrom;
const to = pointsTo.length === 1 ? [...pointsTo, ...pointsTo] : pointsTo;
const pointChange = analyzeDataPattern(from, to);
const coordsFrom = transformPoints(from, width, height, strokeWidth);
const coordsTo = transformPoints(to, width, height, strokeWidth);
let res;
if (pointChange) {
res = addSmoothTransisionPoints(coordsFrom, coordsTo, pointChange.frontDelta, pointChange.backDelta);
} else {
res = addUndefinedTransitionPoints(coordsFrom, coordsTo);
}
chartScales.scales.forEach(chartScale => {
if (arrayEquals(scale, chartScale)) {
result.push(chartScales.constructor);
}
});
});
function colorInterpolator(pointsFrom, pointsTo, strokeFrom, strokeTo) {
if (!pointsFrom || arrayEqual(pointsFrom, pointsTo)) {
return null;
}
const from = getStrokeColor(pointsFrom, strokeFrom);
const to = getStrokeColor(pointsTo, strokeTo);
if (from !== to) {
return interpolateRgb(from, to);
}
return null;
}
static pathEqual = (path1: Path, path2: Path) => arrayEqual(path1, path2);