Skip to content

Commit

Permalink
WIP(chord): animation
Browse files Browse the repository at this point in the history
  • Loading branch information
Ovilia committed Dec 18, 2024
1 parent 668aa13 commit 01bea53
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
1 change: 0 additions & 1 deletion src/chart/chord/ChordPiece.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ export default class ChordPiece extends graphic.Sector {

if (firstCreate) {
el.setShape(shape);
console.log(startAngle)

if (startAngle != null) {
el.setShape({
Expand Down
27 changes: 23 additions & 4 deletions src/chart/chord/chordLayout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import ExtensionAPI from '../../core/ExtensionAPI';
import { getCircleLayout } from '../../util/layout';
import SeriesModel from '../../model/Series';
import { CircleLayoutOptionMixin, SeriesOption } from '../../util/types';
import { getSpanAngle, normalizeArcAngles } from 'zrender/src/core/PathProxy';

Check warning on line 26 in src/chart/chord/chordLayout.ts

View workflow job for this annotation

GitHub Actions / lint (18.x)

'getSpanAngle' is defined but never used

Check warning on line 26 in src/chart/chord/chordLayout.ts

View workflow job for this annotation

GitHub Actions / lint (18.x)

'normalizeArcAngles' is defined but never used

const RADIAN = Math.PI / 180;

Expand All @@ -46,9 +47,24 @@ function chordLayout(seriesModel: ChordSeriesModel, api: ExtensionAPI) {
seriesModel as unknown as SeriesModel<CircleLayoutOptionMixin & SeriesOption<unknown>>,
api
);

const padAngle = (seriesModel.get('padAngle') || 0) * RADIAN;
const minAngle = (seriesModel.get('minAngle') || 0) * RADIAN;
const totalAngle = Math.PI * 2;
let startAngle = -seriesModel.get('startAngle') * RADIAN;

Check warning on line 53 in src/chart/chord/chordLayout.ts

View workflow job for this annotation

GitHub Actions / lint (18.x)

'startAngle' is never reassigned. Use 'const' instead
let endAngle = startAngle + Math.PI * 2;

Check warning on line 54 in src/chart/chord/chordLayout.ts

View workflow job for this annotation

GitHub Actions / lint (18.x)

'endAngle' is never reassigned. Use 'const' instead
const totalAngle = Math.abs(endAngle - startAngle);

// let endAngle = seriesModel.get('endAngle');
// endAngle = endAngle === 'auto' ? startAngle - Math.PI * 2 : -endAngle * RADIAN;

const clockwise = seriesModel.get('clockwise');

Check warning on line 60 in src/chart/chord/chordLayout.ts

View workflow job for this annotation

GitHub Actions / lint (18.x)

'clockwise' is assigned a value but never used
// const dir = clockwise ? 1 : -1;
// const angles = [startAngle, endAngle];
// normalizeArcAngles(angles, !clockwise);
// [startAngle, endAngle] = angles;

// const totalAngle = Math.abs(getSpanAngle(angles, !clockwise));
// console.log(endAngle, startAngle,'totalAngle', totalAngle);

// Sum of each node's edge values
const nodeValues: number[] = [];
Expand Down Expand Up @@ -76,7 +92,7 @@ function chordLayout(seriesModel: ChordSeriesModel, api: ExtensionAPI) {
let minAngleCount = 0;

const calculateNodeLayout = (scale: number = 1) => {
let angle = -seriesModel.get('startAngle') * RADIAN;
let angle = startAngle;
nonMinAngleAccAngle = 0;
edgeAccAngle = [];
minAngleCount = 0;
Expand All @@ -95,19 +111,22 @@ function chordLayout(seriesModel: ChordSeriesModel, api: ExtensionAPI) {
nodeScale = scale;
}

// const dir = clockwise ? 1 : -1;
const dir = 1;
node.setLayout({
cx,
cy,
r0,
r,
startAngle: angle,
endAngle: angle + spanAngle,
endAngle: angle + spanAngle * dir,
scale: nodeScale
});

edgeAccAngle[node.dataIndex] = angle;

angle += spanAngle + padAngle;
// TODO: not correct here
angle += (spanAngle + padAngle) * dir;
});
};
calculateNodeLayout();
Expand Down

0 comments on commit 01bea53

Please sign in to comment.