Skip to content

Commit

Permalink
Merge pull request #543 from vizzuhq/fix-bubblechart
Browse files Browse the repository at this point in the history
Change Bubblechart behaviour on failure + fix negative base markers
  • Loading branch information
schaumb authored Jun 27, 2024
2 parents b5c7171 + 268a179 commit 22eed21
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@

### Fixed


- Change bubblechart behavior on failure.
- Fix reference markers on bubblechart with negative values.
- From now lightness channel goes from light (low value) to dark (high value) colors.


## [0.11.2] - 2024-06-18

### Fixed
Expand Down
5 changes: 1 addition & 4 deletions src/base/io/log.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
#ifndef IO_LOG
#define IO_LOG

#include <functional>
#include <memory>
#include <string>
#include <type_traits>

#include "base/conv/tostring.h"

Expand All @@ -29,7 +26,7 @@ class Log

bool enabled = true;
bool timestamp = true;
Log::LogFunc logFunc = [](std::string const &s)
LogFunc logFunc = [](const std::string &s)
{
puts(s.c_str());
};
Expand Down
23 changes: 14 additions & 9 deletions src/chart/speclayout/bubblechart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,13 @@ void BubbleChart::generate()
auto firstMarkerSize = baseMarker->size();
baseMarker->emplaceCircle(Geom::Point{0, 0}, firstMarkerSize);

auto currMarker = baseMarker + 1;
while (currMarker != markers.end() && currMarker->negative)
currMarker++->emplaceCircle(Geom::Point{0, 0}, 0);
if (currMarker == markers.end()) return;
auto nextBaseMarker = baseMarker + 1;
while (
nextBaseMarker != markers.end() && nextBaseMarker->negative)
nextBaseMarker++->emplaceCircle(Geom::Point{0, 0}, 0);
if (nextBaseMarker == markers.end()) return;

auto currMarker = nextBaseMarker;
auto markerSize = currMarker->size();
currMarker->emplaceCircle(
Geom::Point{firstMarkerSize + markerSize, 0},
Expand All @@ -59,22 +61,25 @@ void BubbleChart::generate()
if (markerSize == 0.0) break;

if (auto &&candidate1 = getTouchingCircle(markerSize,
baseMarker[1],
*nextBaseMarker,
*preMarker);
candidate1
&& !candidate1->overlaps(baseMarker->circle(), 0.00001)) {
currMarker->emplaceCircle(*candidate1);
++baseMarker;
baseMarker = nextBaseMarker++;
while (nextBaseMarker->negative) ++nextBaseMarker;
}
else if (auto &&candidate0 = getTouchingCircle(markerSize,
*baseMarker,
*preMarker);
candidate0
&& !candidate0->overlaps(baseMarker[1].circle(),
&& !candidate0->overlaps(nextBaseMarker->circle(),
0.00001))
currMarker->emplaceCircle(*candidate0);
else
throw std::logic_error("Cannot generate bubble chart");
else {
// TODO bubblechart generation failed. It need a fix.
break;
}
preMarker = currMarker;
}

Expand Down

0 comments on commit 22eed21

Please sign in to comment.