Skip to content

Commit f7400af

Browse files
committed
add test + self-review
1 parent bf4a2e1 commit f7400af

File tree

4 files changed

+129
-5
lines changed

4 files changed

+129
-5
lines changed

src/chart/animator/keyframe.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,11 @@ void Keyframe::prepareActual()
6161
{
6262
if (Gen::Plot::dimensionMatch(*source, *target)) {
6363
if (Gen::Plot::hasMarkerChange(*source, *target))
64-
copyTarget();
64+
copySourceTarget();
6565
Gen::Plot::mergeMarkersAndCellInfo(*source, *target);
6666
}
6767
else {
68-
copyTarget();
68+
copySourceTarget();
6969
target->prependMarkers(*source);
7070
source->appendMarkers(*targetCopy);
7171
}
@@ -80,7 +80,7 @@ void Keyframe::prepareActualMarkersInfo()
8080
{
8181
const auto &origTMI = target->getMarkersInfo();
8282
auto &smi = source->getMarkersInfo();
83-
if (!smi.empty()) copyTarget();
83+
if (!smi.empty()) copySourceTarget();
8484

8585
for (auto &tmi = target->getMarkersInfo(); auto &&item : smi)
8686
tmi.insert(std::pair{item.first, Gen::Plot::MarkerInfo{}});
@@ -89,14 +89,20 @@ void Keyframe::prepareActualMarkersInfo()
8989
smi.insert(std::pair{item.first, Gen::Plot::MarkerInfo{}});
9090
}
9191

92-
void Keyframe::copyTarget()
92+
void Keyframe::copySourceTarget()
9393
{
9494
if (!targetCopy) {
9595
targetCopy = target;
9696
target = std::make_shared<Gen::Plot>(*targetCopy);
9797
target->getStyle().setup();
9898
target->detachOptions();
9999
}
100+
if (!sourceCopy) {
101+
sourceCopy = source;
102+
source = std::make_shared<Gen::Plot>(*sourceCopy);
103+
source->getStyle().setup();
104+
source->detachOptions();
105+
}
100106
}
101107

102108
}

src/chart/animator/keyframe.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,14 @@ class Keyframe : public Planner
2828
Gen::PlotPtr source;
2929
Gen::PlotPtr target;
3030
Gen::PlotPtr actual;
31+
Gen::PlotPtr sourceCopy;
3132
Gen::PlotPtr targetCopy;
3233

3334
void init(const Gen::PlotPtr &plot,
3435
const Data::DataTable &dataTable);
3536
void prepareActual();
3637
void prepareActualMarkersInfo();
37-
void copyTarget();
38+
void copySourceTarget();
3839
};
3940

4041
}

test/e2e/tests/fixes.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@
7575
},
7676
"55278793": {
7777
"refs": ["3932754"]
78+
},
79+
"keyframes": {
80+
"refs": ["cdb3779"]
7881
}
7982
}
8083
}

test/e2e/tests/fixes/keyframes.mjs

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
import data from '../../test_data/music_data.mjs'
2+
3+
const testSteps = [
4+
(chart) => {
5+
chart.feature('tooltip', true)
6+
return chart.animate({ data })
7+
},
8+
(chart) =>
9+
chart.animate([
10+
{
11+
"target": {
12+
"data": {
13+
"filter": (input) => input['Genres'] === 'Pop'
14+
},
15+
"config": {
16+
"channels": {
17+
"x": {
18+
"set": [
19+
{ "name": "Genres" }
20+
]
21+
},
22+
"y": {
23+
"set": [
24+
{ "name": "Popularity" },
25+
{ "name": "Kinds" }
26+
]
27+
},
28+
"color": {
29+
"set": [
30+
{ "name": "Kinds" }
31+
]
32+
},
33+
"label": {
34+
"set": [
35+
{ "name": "Popularity" }
36+
]
37+
}
38+
}
39+
}
40+
}
41+
},
42+
{
43+
"target": {
44+
"data": {
45+
"filter": (input) => input['Genres'] === 'Pop'
46+
},
47+
"config": {
48+
"channels": {
49+
"x": {
50+
"set": [
51+
{ "name": "Genres" }
52+
]
53+
},
54+
"y": {
55+
"set": [
56+
{ "name": "Popularity" }
57+
]
58+
},
59+
"color": {
60+
"set": [
61+
{ "name": "Kinds" }
62+
]
63+
},
64+
"label": {
65+
"set": [
66+
{ "name": "Popularity" }
67+
]
68+
}
69+
},
70+
"geometry": "circle"
71+
}
72+
}
73+
},
74+
{
75+
"target": {
76+
"data": {
77+
"filter": null
78+
},
79+
"config": {
80+
"channels": {
81+
"x": {
82+
"set": []
83+
},
84+
"y": {
85+
"set": [
86+
{ "name": "Popularity" },
87+
{ "name": "Kinds" },
88+
{ "name": "Genres" }
89+
]
90+
},
91+
"color": {
92+
"set": [
93+
{ "name": "Kinds" }
94+
]
95+
},
96+
"lightness": {
97+
"set": [
98+
{ "name": "Genres" }
99+
]
100+
},
101+
"label": {
102+
"set": [
103+
{ "name": "Genres" },
104+
{ "name": "Popularity" }
105+
]
106+
}
107+
},
108+
"geometry": "rectangle"
109+
}
110+
}
111+
}]),
112+
]
113+
114+
export default testSteps

0 commit comments

Comments
 (0)