Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/refactor-marker-connections-2' i…
Browse files Browse the repository at this point in the history
…nto resolution_v2

# Conflicts:
#	test/e2e/test_cases/test_cases.json
#	test/e2e/tests/fixes.json
  • Loading branch information
schaumb committed Jul 15, 2024
2 parents 840c1ff + 824e5f1 commit 523e8e9
Show file tree
Hide file tree
Showing 21 changed files with 113 additions and 106 deletions.
10 changes: 8 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,19 @@

### Fixed

- Add default no rectangle spacing on heatmap and coxcomb.
- First marker alpha was different to other marker's alpha
- Make some transactions clearer. (rectangle-line first marker)

### Added

- New data handling implemented: Not generating big cube
- New data handling implemented: Not generating big cube

## [0.11.4] - 2024-07-09

### Fixed

- Add default no rectangle spacing on heatmap and coxcomb.
- Crash fix on special (meas-meas) area bar mekko charts.

## [0.11.3] - 2024-06-27

Expand Down
2 changes: 1 addition & 1 deletion src/apps/weblib/cinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ void data_addMeasure(APIHandles::Chart chart,
}

void data_addRecord(APIHandles::Chart chart,
const char **cells,
const char *const *cells,
std::uint32_t count)
{
return Interface::getInstance().addRecord(chart, cells, count);
Expand Down
2 changes: 1 addition & 1 deletion src/apps/weblib/cinterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ extern void data_addMeasure(APIHandles::Chart chart,
const double *values,
std::uint32_t count);
extern void data_addRecord(APIHandles::Chart chart,
const char **cells,
const char *const *cells,
std::uint32_t count);
const char *data_metaInfo(APIHandles::Chart chart);

Expand Down
2 changes: 1 addition & 1 deletion src/apps/weblib/interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ void Interface::addMeasure(ObjectRegistryHandle chart,
}

void Interface::addRecord(ObjectRegistryHandle chart,
const char **cells,
const char *const *cells,
std::uint32_t count)
{
getChart(chart)->getTable().pushRow({cells, count});
Expand Down
2 changes: 1 addition & 1 deletion src/apps/weblib/interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class Interface
const double *values,
std::uint32_t count);
void addRecord(ObjectRegistryHandle chart,
const char **cells,
const char *const *cells,
std::uint32_t count);
const char *dataMetaInfo(ObjectRegistryHandle chart);
void addEventListener(ObjectRegistryHandle chart,
Expand Down
35 changes: 13 additions & 22 deletions src/base/geom/quadrilateral.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,15 @@
namespace Geom
{

ConvexQuad::ConvexQuad(const Geom::Rect &rect)
ConvexQuad::ConvexQuad(const Rect &rect)
{
points[0] = rect.pos;
points[1] = rect.pos + Point{rect.size.x, 0.0};
points[2] = rect.pos + rect.size;
points[3] = rect.pos + Point{0.0, rect.size.y};
}

Rect ConvexQuad::boundary() const
{
return Geom::Rect::Boundary(points);
}
Rect ConvexQuad::boundary() const { return Rect::Boundary(points); }

ConvexQuad ConvexQuad::Square(Point p0, Point p2)
{
Expand All @@ -29,12 +26,14 @@ ConvexQuad ConvexQuad::Square(Point p0, Point p2)
return ConvexQuad({p0, p1, p2, p3});
}

ConvexQuad ConvexQuad::Isosceles(Geom::Point base0Middle,
Geom::Point base1Middle,
ConvexQuad ConvexQuad::Isosceles(Point base0Middle,
Point base1Middle,
double base0Length,
double base1Length)
{
auto dir = (base1Middle - base0Middle).normalized();
auto dir = base1Middle == base0Middle
? Point{0, 1}
: (base1Middle - base0Middle).normalized();

return ConvexQuad(
{base0Middle + dir.normal(false) * (base0Length / 2),
Expand All @@ -45,26 +44,18 @@ ConvexQuad ConvexQuad::Isosceles(Geom::Point base0Middle,

bool ConvexQuad::contains(const Point &p, double tolerance) const
{
auto boundaryArea =
Triangle(std::array<Point, 3>{points[0], points[1], p}).area()
+ Triangle(std::array<Point, 3>{points[1], points[2], p})
.area()
+ Triangle(std::array<Point, 3>{points[2], points[3], p})
.area()
+ Triangle(std::array<Point, 3>{points[3], points[0], p})
.area();
auto boundaryArea = Triangle{{points[0], points[1], p}}.area()
+ Triangle{{points[1], points[2], p}}.area()
+ Triangle{{points[2], points[3], p}}.area()
+ Triangle{{points[3], points[0], p}}.area();

return Math::AddTolerance(boundaryArea, tolerance) <= area();
}

double ConvexQuad::area() const
{
return Triangle(
std::array<Point, 3>{points[0], points[1], points[2]})
.area()
+ Triangle(
std::array<Point, 3>{points[2], points[3], points[0]})
.area();
return Triangle{{points[0], points[1], points[2]}}.area()
+ Triangle{{points[2], points[3], points[0]}}.area();
}

}
10 changes: 5 additions & 5 deletions src/base/geom/quadrilateral.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ class ConvexQuad

ConvexQuad() = default;
explicit ConvexQuad(const Points &points) : points(points) {}
explicit ConvexQuad(const Geom::Rect &rect);
static ConvexQuad Square(Point p0, Point p2);
static ConvexQuad Isosceles(Geom::Point base0Middle,
Geom::Point base1Middle,
explicit ConvexQuad(const Rect &rect);
[[nodiscard]] static ConvexQuad Square(Point p0, Point p2);
[[nodiscard]] static ConvexQuad Isosceles(Point base0Middle,
Point base1Middle,
double base0Length,
double base1Length);
[[nodiscard]] bool contains(const Point &p,
double tolerance = 0.0) const;
[[nodiscard]] double area() const;
[[nodiscard]] Geom::Rect boundary() const;
[[nodiscard]] Rect boundary() const;
};

}
Expand Down
7 changes: 0 additions & 7 deletions src/base/geom/triangle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,6 @@
namespace Geom
{

Triangle::Triangle(const Point &p0, const Point &p1, const Point &p2)
{
points[0] = p0;
points[1] = p1;
points[2] = p2;
}

double Triangle::area() const
{
auto A = points[2] - points[1];
Expand Down
5 changes: 0 additions & 5 deletions src/base/geom/triangle.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@ class Triangle
public:
std::array<Point, 3> points;

explicit Triangle(const std::array<Point, 3> &points) :
points(points)
{}
Triangle(const Point &p0, const Point &p1, const Point &p2);

[[nodiscard]] double area() const;
};

Expand Down
2 changes: 1 addition & 1 deletion src/base/gfx/pathsampler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ void PathSampler::path(const Geom::Point &pConv0,
auto i = (i0 + i1) / 2.0;
auto pConv = getPoint(i);

const Geom::Triangle triangle(pConv0, pConv, pConv1);
const Geom::Triangle triangle{{pConv0, pConv, pConv1}};
auto area = triangle.area();
auto height = 2 * area / (pConv1 - pConv0).abs();

Expand Down
15 changes: 9 additions & 6 deletions src/chart/animator/planner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,12 +289,15 @@ void Planner::calcNeeded()
animNeeded[SectionId::x] = needHorizontal();

animNeeded[SectionId::connection] =
anyMarker(+[](const Gen::Marker &source,
const Gen::Marker &target) -> bool
{
return source.prevMainMarker != target.prevMainMarker;
})
|| srcOpt->isHorizontal() != trgOpt->isHorizontal();
(isConnecting(srcOpt->geometry.get())
|| isConnecting(trgOpt->geometry.get()))
&& (anyMarker(+[](const Gen::Marker &source,
const Gen::Marker &target) -> bool
{
return source.prevMainMarker
!= target.prevMainMarker;
})
|| srcOpt->isHorizontal() != trgOpt->isHorizontal());
}

bool Planner::anyMarker(
Expand Down
24 changes: 9 additions & 15 deletions src/chart/generator/marker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ namespace Vizzu::Gen
Marker::Marker(const Options &options,
const Data::DataCube &data,
Axises &stats,
const Data::SeriesList &mainAxisList,
const Data::SeriesList &subAxisList,
const Data::MultiIndex &index,
MarkerPosition pos,
bool needMarkerInfo) :
Expand Down Expand Up @@ -49,21 +51,13 @@ Marker::Marker(const Options &options,
index,
&sizeId);

auto &&mainAxisDims = options.mainAxis().dimensionsWithLevel();

Data::MarkerId *subAxisId{};
if (auto &&subAxis = options.subAxis().dimensionsWithLevel();
options.geometry == ShapeType::area) {
Data::SeriesList subIds(subAxis.first);
if (subIds.split_by(mainAxisDims.first).empty())
subAxisId = &subId;
subId = data.getId({subIds, subAxis.second}, index);
}
else {
subId = data.getId(subAxis, index);
subAxisId = &subId;
}
mainId = data.getId(mainAxisDims, index);
subId = data.getId({subAxisList, options.subAxis().labelLevel},
index);
auto *subAxisId = subAxisList == options.subAxis().dimensions()
? &subId
: nullptr;
mainId = data.getId({mainAxisList, options.mainAxis().labelLevel},
index);

auto horizontal = options.isHorizontal();
auto lineOrCircle = options.geometry == ShapeType::line
Expand Down
2 changes: 2 additions & 0 deletions src/chart/generator/marker.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ class Marker
Marker(const Options &options,
const Data::DataCube &data,
Axises &stats,
const Data::SeriesList &mainAxisList,
const Data::SeriesList &subAxisList,
const Data::MultiIndex &index,
MarkerPosition pos,
bool needMarkerInfo);
Expand Down
46 changes: 31 additions & 15 deletions src/chart/generator/plotbuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,15 @@ Buckets PlotBuilder::generateMarkers(std::size_t &mainBucketSize)
{
Buckets mainBuckets;
Buckets subBuckets;
if (!dataCube.empty()) {
mainBuckets.resize(dataCube.combinedSizeOf(
plot->getOptions()->mainAxis().dimensions()));
mainBucketSize = mainBuckets.size();

Data::SeriesList subIds(
plot->getOptions()->subAxis().dimensions());
const auto &mainIds(plot->getOptions()->mainAxis().dimensions());
auto subIds(plot->getOptions()->subAxis().dimensions());
if (!dataCube.empty()) {
if (plot->getOptions()->geometry == ShapeType::area)
subIds.split_by(
plot->getOptions()->mainAxis().dimensions());
subIds.split_by(mainIds);

mainBuckets.resize(dataCube.combinedSizeOf(mainIds));
mainBucketSize = mainBuckets.size();
subBuckets.resize(dataCube.combinedSizeOf(subIds));

plot->markers.reserve(dataCube.combinedSizeOf({}).first);
Expand All @@ -94,6 +93,8 @@ Buckets PlotBuilder::generateMarkers(std::size_t &mainBucketSize)
auto &marker = plot->markers.emplace_back(*plot->getOptions(),
dataCube,
plot->axises,
mainIds,
subIds,
index,
plot->markers.size(),
needInfo);
Expand Down Expand Up @@ -207,16 +208,29 @@ bool PlotBuilder::linkMarkers(const Buckets &buckets, bool main) const
std::erase_if(sorted,
std::not_fn(std::mem_fn(&BucketInfo::hasElement)));

std::vector<double> dimOffset(sorted.size());
std::vector dimOffset(sorted.size(),
std::numeric_limits<double>::lowest());

auto channelId = main ? plot->getOptions()->mainAxisType()
: plot->getOptions()->subAxisType();
auto subChannelId = main ? plot->getOptions()->subAxisType()
: plot->getOptions()->mainAxisType();
auto &&axis = plot->getOptions()->getChannels().at(channelId);
auto &&subAxis =
plot->getOptions()->getChannels().at(subChannelId);

auto horizontal = plot->getOptions()->isHorizontal();
double Geom::Point::*const coord =
horizontal == main ? &Geom::Point::x : &Geom::Point::y;

if (axis.isDimension()) {
auto isAggregatable = axis.isDimension()
|| (main && subAxis.isMeasure()
&& plot->getOptions()->geometry.get()
== ShapeType::rectangle);

if (isAggregatable) {
double pre_neg{};
double pre_pos{};
for (std::size_t ix{}, max = sorted.size(); ix < max; ++ix) {
auto &o = dimOffset[ix];
for (const auto &bucket : buckets) {
Expand All @@ -225,11 +239,13 @@ bool PlotBuilder::linkMarkers(const Buckets &buckets, bool main) const
continue;
o = std::max(o, marker->size.*coord);
}
if (o == std::numeric_limits<double>::lowest()) o = 0.0;

if (o < 0)
std::swap(o += pre_neg, pre_neg);
else
std::swap(o += pre_pos, pre_pos);
}
std::exclusive_scan(dimOffset.begin(),
dimOffset.end(),
dimOffset.begin(),
0.0);
}

bool hasConnection{};
Expand All @@ -255,7 +271,7 @@ bool PlotBuilder::linkMarkers(const Buckets &buckets, bool main) const

if (act)
prevPos = act->position.*coord +=
axis.isDimension() ? dimOffset[i] : prevPos;
isAggregatable ? dimOffset[i] : prevPos;

hasConnection |=
Marker::connectMarkers(iNext == 0 && act != next,
Expand Down
2 changes: 1 addition & 1 deletion src/chart/main/version.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "version.h"

const App::Version Vizzu::Main::version(0, 11, 3);
const App::Version Vizzu::Main::version(0, 11, 4);

const char *const Vizzu::Main::siteUrl = "https://vizzu.io/";
14 changes: 9 additions & 5 deletions src/chart/rendering/markers/connectingmarker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ ConnectingMarker::ConnectingMarker(const DrawingContext &ctx,
pc.value) {
auto &&newPolar =
(polar && Math::FuzzyBool{pc.weight}).more();
linear = linear || newPolar;
linear = linear || polar.more()
|| Math::FuzzyBool{pc.weight}.more();
connected = connected && newPolar && horizontal;
enabled = enabled && newPolar && horizontal;
}
Expand Down Expand Up @@ -81,10 +82,13 @@ ConnectingMarker::ConnectingMarker(const DrawingContext &ctx,
auto prevSpacing = prev->spacing * prev->size / 2;
auto prevPos = prev->position;

if (polar != false) {
if (horizontal.more() != false) {
if (prevPos.x >= 1) prevPos.x -= 1;
}
if (polar != false
&& ctx.getOptions()
.orientation.get_or_first(lineIndex)
.value
== Gen::Orientation::horizontal
&& prev != &marker && prevPos.x >= 1) {
prevPos.x -= 1;
}

points[3] = prevPos - prevSpacing;
Expand Down
5 changes: 4 additions & 1 deletion src/dataframe/impl/dataframe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,10 @@ void dataframe::finalize() &
std::string dataframe::as_string() const &
{
const auto *vec = get_if<state_type::modifying>(&state_data);
if (!vec || vec->empty())
if (!vec
|| (vec->empty()
&& (!get_dimensions().empty()
|| !get_measures().empty())))
error(error_type::internal_error, "as str");

std::string res;
Expand Down
Loading

0 comments on commit 523e8e9

Please sign in to comment.