feat: allow full circle in donut chart
This commit is contained in:
parent
f0a24a2ced
commit
49afbd8e6c
@ -2,7 +2,7 @@ import AggregationChart from './AggregationChart';
|
|||||||
import { getComponent } from '../objects/ChartComponents';
|
import { getComponent } from '../objects/ChartComponents';
|
||||||
import { getOffset } from '../utils/dom';
|
import { getOffset } from '../utils/dom';
|
||||||
import { getPositionByAngle } from '../utils/helpers';
|
import { getPositionByAngle } from '../utils/helpers';
|
||||||
import { makeArcStrokePathStr } from '../utils/draw';
|
import { makeArcStrokePathStr, makeStrokeCircleStr } from '../utils/draw';
|
||||||
import { lightenDarkenColor } from '../utils/colors';
|
import { lightenDarkenColor } from '../utils/colors';
|
||||||
import { transform } from '../utils/animation';
|
import { transform } from '../utils/animation';
|
||||||
import { FULL_ANGLE } from '../utils/constants';
|
import { FULL_ANGLE } from '../utils/constants';
|
||||||
@ -63,7 +63,10 @@ export default class DonutChart extends AggregationChart {
|
|||||||
curStart = startPosition;
|
curStart = startPosition;
|
||||||
curEnd = endPosition;
|
curEnd = endPosition;
|
||||||
}
|
}
|
||||||
const curPath = makeArcStrokePathStr(curStart, curEnd, this.center, this.radius, this.clockWise, largeArc);
|
const curPath =
|
||||||
|
originDiffAngle === 360
|
||||||
|
? makeStrokeCircleStr(curStart, curEnd, this.center, this.radius, this.clockWise, largeArc)
|
||||||
|
: makeArcStrokePathStr(curStart, curEnd, this.center, this.radius, this.clockWise, largeArc);
|
||||||
|
|
||||||
s.sliceStrings.push(curPath);
|
s.sliceStrings.push(curPath);
|
||||||
s.slicesProperties.push({
|
s.slicesProperties.push({
|
||||||
|
|||||||
@ -141,6 +141,18 @@ export function makeArcStrokePathStr(startPosition, endPosition, center, radius,
|
|||||||
${arcEndX} ${arcEndY}`;
|
${arcEndX} ${arcEndY}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function makeStrokeCircleStr(startPosition, endPosition, center, radius, clockWise=1, largeArc=0){
|
||||||
|
let [arcStartX, arcStartY] = [center.x + startPosition.x, center.y + startPosition.y];
|
||||||
|
let [arcEndX, midArc, arcEndY] = [center.x + endPosition.x, radius * 2 + arcStartY, center.y + startPosition.y];
|
||||||
|
|
||||||
|
return `M${arcStartX} ${arcStartY}
|
||||||
|
A ${radius} ${radius} 0 ${largeArc} ${clockWise ? 1 : 0}
|
||||||
|
${arcEndX} ${midArc}
|
||||||
|
M${arcStartX} ${midArc}
|
||||||
|
A ${radius} ${radius} 0 ${largeArc} ${clockWise ? 1 : 0}
|
||||||
|
${arcEndX} ${arcEndY}`;
|
||||||
|
}
|
||||||
|
|
||||||
export function makeGradient(svgDefElem, color, lighter = false) {
|
export function makeGradient(svgDefElem, color, lighter = false) {
|
||||||
let gradientId ='path-fill-gradient' + '-' + color + '-' +(lighter ? 'lighter' : 'default');
|
let gradientId ='path-fill-gradient' + '-' + color + '-' +(lighter ? 'lighter' : 'default');
|
||||||
let gradientDef = renderVerticalGradient(svgDefElem, gradientId);
|
let gradientDef = renderVerticalGradient(svgDefElem, gradientId);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user