Skip to content

Commit

Permalink
fix: use transform instead of x/y (#315)
Browse files Browse the repository at this point in the history
* fix: use transform instead of x/y

* fix: indicator

* fix: timebar

* fix: axis

* chore: update snapshots

* chore: update snapshots

* fix: label transform

* fix: axis title

* chore: skip axis animation update#13 for now

* chore: update snapshots

* chore: bump version

* chore: update to the latest g

* chore: lint
  • Loading branch information
xiaoiver authored Mar 21, 2024
1 parent 006ddd1 commit 505dae5
Show file tree
Hide file tree
Showing 429 changed files with 45,088 additions and 68,723 deletions.
9 changes: 3 additions & 6 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
{
"cSpell.words": [
"bbox",
"Sparkline",
"timebar"
]
}
"cSpell.words": ["bbox", "Sparkline", "timebar"],
"svg.preview.background": "white"
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,15 @@ export const AxisAnimationUpdate12 = () => {
const g1 = group.appendChild(
new Group({
style: {
x: 100,
y: 100,
transform: 'translate(100, 100)',
},
})
);

const g2 = group.appendChild(
new Group({
style: {
x: 50,
y: 50,
transform: 'translate(50, 50)',
},
})
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,15 @@ export const AxisAnimationUpdate13 = () => {
group.appendChild(
new Group({
style: {
x: 100,
y: 100,
transform: 'translate(100, 100)',
},
})
);

const g2 = group.appendChild(
new Group({
style: {
x: 50,
y: 50,
transform: 'translate(50, 50)',
},
})
);
Expand Down Expand Up @@ -57,7 +55,7 @@ export const AxisAnimationUpdate13 = () => {
titleTransformOrigin: 'center',
titleTextBaseline: 'middle',
titlePosition: 'left',
titleTransform: 'translate(50%, 0) rotate(-90)',
titleTransform: 'translate(-100%, 0) rotate(-90)',
labelDirection: 'positive',
tickDirection: 'positive',
gridDirection: 'negative',
Expand Down Expand Up @@ -117,3 +115,4 @@ export const AxisAnimationUpdate13 = () => {
AxisAnimationUpdate13.tags = ['坐标轴', '动画', '更新', '标题'];

AxisAnimationUpdate13.wait = 500;
AxisAnimationUpdate13.skip = true;
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ export const AxisAnimationUpdate5 = () => {
new Button({
style: {
x: 80,
y: 0,
text: 'reset',
onClick: reset,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,3 @@ export const AxisAnimationUpdate9 = () => {
AxisAnimationUpdate9.tags = ['坐标轴', '动画', '更新'];

AxisAnimationUpdate9.wait = 500;

// FIXME: skip for now
// - transform="matrix(1,0,0,1,54.239998,265.750000)"
// + transform="matrix(1,0,0,1,54.240002,265.750000)"
AxisAnimationUpdate9.skip = true;
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const AxisLinearBasis5 = () => {
lineExtension: [10, 10],
tickLength: 10,
labelSpacing: 5,
labelTransform: 'rotate(90)',
labelTransform: 'rotate(45)',
type: 'linear',
tickLineWidth: 5,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@ export const AxisLinearCustomTick = () => {
data: mockData,
labelFormatter: () => '',
tickFormatter: (datum: any, index: number, data: any, [cx, cy]: any) => {
if (index === 3) return new Rect({ style: { width: 20, height: 20, fill: 'green', anchor: '0.5 0.5' } });
if (index === 3)
return new Rect({
style: { x: 0, y: 0, width: 20, height: 20, fill: 'green', transform: 'translate(-10, -10)' },
});
return index % 5 === 0
? new Circle({ style: { r: index % 10 === 0 ? 10 : 5 } })
? new Circle({ style: { cx: 0, cy: 0, r: index % 10 === 0 ? 10 : 5 } })
: new Line({ style: { x1: 0, x2: 0, y1: 50 * cx, y2: 10 * cy } });
},
type: 'linear',
Expand Down
4 changes: 3 additions & 1 deletion __tests__/integration/components/axis/axis-linear-label.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,11 @@ export const AxisLinearLabel = () => {
const labelIcon = new Image({
style: {
src: icon,
x: 0,
y: 0,
width: 30,
height: 30,
anchor: '0.5 0.5',
transform: 'translate(-15, -15)',
},
});
const labelText = new Text({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const AxisLinearTitlePosition = () => {
titleText: 'left',
titlePosition: 'l',
titleSpacing: 10,
titleTransform: 'translate(50%, 0) rotate(-90)',
titleTransform: 'rotate(-90)',
});
createAxis({
startPos: [50, 500],
Expand All @@ -46,8 +46,7 @@ export const AxisLinearTitlePosition = () => {
endPos: [550, 500],
titleText: 'right',
titlePosition: 'r',
titleSpacing: 10,
titleTransform: 'translate(-50%, 0) rotate(-90)',
titleTransform: 'rotate(-90)',
});

const g1 = group.appendChild(
Expand All @@ -63,15 +62,14 @@ export const AxisLinearTitlePosition = () => {
titleText: 'right',
titlePosition: 'r',
titleSpacing: 10,
titleTransform: 'translate(-50%, 0) rotate(-90)',
titleTransform: 'rotate(-90)',
})
);

const g2 = group.appendChild(
new Group({
style: {
x: 60,
y: 60,
transform: 'translate(60, 60)',
},
})
);
Expand All @@ -83,7 +81,7 @@ export const AxisLinearTitlePosition = () => {
titleText: 'right',
titlePosition: 'r',
titleSpacing: 10,
titleTransform: 'translate(-50%, 0) rotate(-90)',
titleTransform: 'rotate(-90)',
})
);

Expand Down
1 change: 0 additions & 1 deletion __tests__/integration/components/axis/axis-linear-title.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ export const AxisLinearTitle = () => {
src: 'https://gw.alipayobjects.com/mdn/rms_6ae20b/afts/img/A*N4ZMS7gHsUIAAAAAAAAAAABkARQnAQ',
height: 30,
width: 30,
anchor: '0 0',
},
})
);
Expand Down
6 changes: 1 addition & 5 deletions __tests__/integration/components/bugs/axis-title-position.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,10 @@ export const BugAxisTitlePosition = () => {
titleSpacing: 10,
titleTextBaseline: 'middle',
titleTransformOrigin: 'center',
titleAnchor: '0.5 0.5',
titleTransform: 'translate(50%, 0) rotate(-90)',
titleTransform: 'rotate(-90)',
labelAlign: 'horizontal',
labelSpacing: 4,
labelDirection: 'positive',
lineArrow: undefined,
gridLength: 565,
gridDirection: 'negative',
tickDirection: 'positive',
lineOpacity: 1,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ export const BugCategoryWithShape1 = () => {
rect.appendChild(
new Category({
style: {
x: 50,
y: 50,
width,
height,
gridCol: 10,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ export const BugCategoryWithShape2 = () => {
rect2.appendChild(
new Category({
style: {
x: 50,
y: 50,
titleText: 'title',
titleFontSize: 20,
width,
Expand Down
2 changes: 1 addition & 1 deletion __tests__/integration/components/bugs/category-marker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const BugCategoryMarker = () => {
group.appendChild(
new Category({
style: {
itemMarker: (d: any, i: number) => () => new Path({ style: { path: circle(0, 0, 6) } }),
itemMarker: (d: any, i: number) => () => new Path({ style: { d: circle(0, 0, 6) } }),
itemMarkerStroke: (_: any, index: number) => data[index].color,
data,

Expand Down
6 changes: 2 additions & 4 deletions __tests__/integration/components/checkbox/checkbox1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ export function Checkbox1() {
group.appendChild(
new Checkbox({
style: {
x: 10,
y: 10,
transform: 'translate(10, 10)',
labelText: 'Checkbox',
},
})
Expand All @@ -17,8 +16,7 @@ export function Checkbox1() {
const ck = group.appendChild(
new Checkbox({
style: {
x: 10,
y: 30,
transform: 'translate(10, 30)',
labelText: 'Checkbox',
checked: true,
},
Expand Down
8 changes: 4 additions & 4 deletions __tests__/integration/components/indicator/indicator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import { createGrid } from '../../utils/grid';
export const IndicatorDemo = () => {
const group = new Group({
style: {
x: 30,
y: 30,
transform: 'translate(30, 30)',
},
});

Expand Down Expand Up @@ -218,10 +217,11 @@ export const IndicatorDemo = () => {
const mi = createIndicator({ x: 250, y: 100, labelText: 0.5, position: 'bottom' });

group.addEventListener('mousemove', (e: any) => {
console.log(e.offset, e.canvas);
const { x, y } = e.offset;
const [dx, dy] = group.getLocalPosition();
mi.setLocalPosition(x - dx, y - dy);
mi.style.x = x - dx;
mi.style.y = y - dy;
mi.update();
});

return group;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const CategoryItem10 = () => {
marker: () =>
new Path({
style: {
path: shape(0, 0, 6),
d: shape(0, 0, 6),
},
}),
markerStroke: 'green',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,17 @@ export const CategoryItemMarker2 = () => {
gridCol: 10,
height: 40,
titleText: 'Legend Title',
// titleFill: '#1D2129',
// titleFillOpacity: 0.65,
// titleFontSize: 12,
// titleFontWeight: 'normal',
// titleSpacing: 4,
// showTitle: false,
width: 500,
itemMarker: (d: any, i: number) => () =>
new Path({
style: {
path: paths[i],
d: paths[i],
},
}),
itemMarkerStroke: 'red',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const CategoryItems11 = () => {
itemValueFill: 'green',
colPadding: 5,
itemMarker: (d: any, i: number) => () =>
new Path({ style: { path: [circle, triangle, diamond][i % 3](0, 0, 6) } }),
new Path({ style: { d: [circle, triangle, diamond][i % 3](0, 0, 6) } }),
itemMarkerStroke: (_: any, index: number) => colors[index % colors.length],
itemMarkerStrokeWidth: 2,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const CategoryItems12 = () => {
new CategoryItems({
style: {
data,
itemMarker: (d: any, i: number) => () => new Path({ style: { path: circle(0, 0, 6) } }),
itemMarker: (d: any, i: number) => () => new Path({ style: { d: circle(0, 0, 6) } }),
itemMarkerStroke: (_: any, index: number) => data[index].color,

width: 565,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const CategoryItems9 = () => {
group.appendChild(
new CategoryItems({
style: {
data: flowItemData,
data: flowItemData.slice(0, 5),
layout: 'flex',
itemLabelFill: 'red',
itemValueFill: 'green',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const CategoryLayout3 = () => {
itemMarker: () => () =>
new Path({
style: {
path: smooth(0, 0, 6),
d: smooth(0, 0, 6),
},
}),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const CategoryLayout7 = () => {
itemMarker: () => () =>
new Path({
style: {
path: smooth(0, 0, 6),
d: smooth(0, 0, 6),
},
}),
itemValueText: '',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ export const CategoryPosition2 = () => {
const g = group.appendChild(
new Group({
style: {
x: 50,
y: 50,
transform: 'translate(50, 50)',
},
})
);
Expand Down
3 changes: 1 addition & 2 deletions __tests__/integration/components/legend/continuous-1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ export const Continuous1 = () => {
handleMarkerSize: 30,
ribbonTrackFill: 'pink',
showLabel: false,
x: 0,
y,
transform: `translateY(${y})`,
...con,
},
})
Expand Down
3 changes: 1 addition & 2 deletions __tests__/integration/components/legend/continuous-2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ export const Continuous2 = () => {
ribbonTrackFill: 'pink',
showLabel: false,
type: 'size',
x: 0,
y,
transform: `translateY(${y})`,
...con,
},
})
Expand Down
3 changes: 1 addition & 2 deletions __tests__/integration/components/legend/continuous-3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ export const Continuous3 = () => {
ribbonTrackFill: 'pink',
showLabel: false,
type: 'size',
x: 0,
y,
transform: `translateY(${y})`,
...con,
},
})
Expand Down
3 changes: 1 addition & 2 deletions __tests__/integration/components/legend/continuous-4.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ export const Continuous4 = () => {
labelFontSize: 10,
labelSpacing: 10,
labelTickStroke: 'red',
x,
y,
transform: `translate(${x}, ${y})`,
...shape,
...con,
},
Expand Down
3 changes: 1 addition & 2 deletions __tests__/integration/components/legend/continuous-5.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ export const Continuous5 = () => {
labelSpacing: 10,
orientation: 'vertical',
showLabel: true,
x,
y,
transform: `translate(${x}, ${y})`,
...shape,
...con,
},
Expand Down
Loading

0 comments on commit 505dae5

Please sign in to comment.