Skip to content

Commit fcdfb5d

Browse files
authored
Merge pull request #307 from vizzuhq/bugfix
Tooltip interpolation exception fix
2 parents 7cd9800 + 1d4ef89 commit fcdfb5d

File tree

4 files changed

+10
-8
lines changed

4 files changed

+10
-8
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
finished, the library is aborted due to an exception.
1414
- At times, the chosen marker would disappear from the selections during
1515
rapid mouse actions, leading to an exception being triggered.
16+
- Sometimes, during mouse actions, when the tooltip animation disappeared, the
17+
marker information was null. With a new mouse action, when other tooltip
18+
appeared, the marker transformation went from null to null, which caused an
19+
exception.
1620

1721
## [0.8.0] - 2023-07-12
1822

src/chart/generator/plot.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@ Plot::MarkersInfo interpolate(const Plot::MarkersInfo &op1,
2323
iter1++, iter2++) {
2424
if (iter1->first != iter2->first)
2525
throw std::logic_error("invalid map operation");
26-
result.insert(std::make_pair(iter1->first,
27-
interpolate(iter1->second, iter2->second, factor)));
26+
if (iter1->second.get() || iter2->second.get()) {
27+
result.insert(std::make_pair(iter1->first,
28+
interpolate(iter1->second, iter2->second, factor)));
29+
}
2830
}
2931
return result;
3032
}

src/chart/rendering/drawmarkerinfo.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -202,11 +202,10 @@ DrawMarkerInfo::DrawMarkerInfo(const Layout &layout,
202202
plot(plot),
203203
style(plot.getStyle().tooltip)
204204
{
205-
auto coordSys = Draw::CoordinateSystem(layout.plotArea,
205+
coordSystem.emplace(layout.plotArea,
206206
plot.getOptions()->angle,
207207
plot.getOptions()->coordSystem,
208208
plot.keepAspectRatio);
209-
coordSystem = &coordSys;
210209
for (const auto &info : plot.getMarkersInfo()) {
211210
if (info.second.count == 0) continue;
212211
auto weight1 = info.second.values[0].weight;
@@ -224,9 +223,6 @@ DrawMarkerInfo::DrawMarkerInfo(const Layout &layout,
224223
fadeOutMarkerInfo(cnt1, weight1);
225224
else if (cnt1 && cnt2)
226225
moveMarkerInfo(cnt1, weight1, cnt2, weight2);
227-
else
228-
throw std::logic_error(
229-
"invalid marker info combination");
230226
}
231227
}
232228
}

src/chart/rendering/drawmarkerinfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class DrawMarkerInfo
4848
const Layout &layout;
4949
Gfx::ICanvas &canvas;
5050
const Gen::Plot &plot;
51-
Draw::CoordinateSystem *coordSystem{};
51+
std::optional<Draw::CoordinateSystem> coordSystem;
5252
const Styles::Tooltip &style;
5353

5454
void fadeInMarkerInfo(Content &cnt, double weight);

0 commit comments

Comments
 (0)