From 8b622b3c0b46fb4d3bdfdf980f99275709a636ca Mon Sep 17 00:00:00 2001 From: Bela Schaum Date: Tue, 1 Oct 2024 16:12:50 +0200 Subject: [PATCH 1/6] More axisId --- src/chart/animator/planner.cpp | 14 +++++++------- src/chart/animator/planner.h | 2 +- src/chart/options/channel.cpp | 5 +++++ src/chart/options/channel.h | 3 +++ src/chart/options/channels.h | 11 ++++++++++- src/chart/options/options.cpp | 4 ++-- src/chart/options/options.h | 10 +++++----- 7 files changed, 33 insertions(+), 16 deletions(-) diff --git a/src/chart/animator/planner.cpp b/src/chart/animator/planner.cpp index 7efd5edef..9aa646b88 100644 --- a/src/chart/animator/planner.cpp +++ b/src/chart/animator/planner.cpp @@ -383,7 +383,7 @@ bool Planner::needColor() const } size_t Planner::dimensionCount(const Gen::Plot *plot, - Gen::ChannelId type) + Gen::AxisId type) { return plot->getOptions() ->getChannels() @@ -401,15 +401,15 @@ bool Planner::verticalBeforeHorizontal() const || !srcOpt->getChannels().anyAxisSet() || !trgOpt->getChannels().anyAxisSet()) { if (srcOpt->getChannels().anyAxisSet()) - return srcOpt->subAxisType() == Gen::ChannelId::y; + return srcOpt->subAxisType() == Gen::AxisId::y; if (trgOpt->getChannels().anyAxisSet()) - return trgOpt->mainAxisType() == Gen::ChannelId::y; + return trgOpt->mainAxisType() == Gen::AxisId::y; } - auto srcXcnt = dimensionCount(source, Gen::ChannelId::x); - auto srcYcnt = dimensionCount(source, Gen::ChannelId::y); - auto trgXcnt = dimensionCount(target, Gen::ChannelId::x); - auto trgYcnt = dimensionCount(target, Gen::ChannelId::y); + auto srcXcnt = dimensionCount(source, Gen::AxisId::x); + auto srcYcnt = dimensionCount(source, Gen::AxisId::y); + auto trgXcnt = dimensionCount(target, Gen::AxisId::x); + auto trgYcnt = dimensionCount(target, Gen::AxisId::y); if ((trgYcnt != srcYcnt) || (trgXcnt != srcXcnt)) { return (trgYcnt > srcYcnt) || (trgXcnt < srcXcnt); diff --git a/src/chart/animator/planner.h b/src/chart/animator/planner.h index b0cae3561..28bb4d61b 100644 --- a/src/chart/animator/planner.h +++ b/src/chart/animator/planner.h @@ -50,7 +50,7 @@ class Planner : public ::Anim::Group [[nodiscard]] bool positionMorphNeeded() const; [[nodiscard]] bool verticalBeforeHorizontal() const; static size_t dimensionCount(const Gen::Plot *plot, - Gen::ChannelId type); + Gen::AxisId type); [[nodiscard]] bool isAnyLegend(Gen::ChannelId type) const; diff --git a/src/chart/options/channel.cpp b/src/chart/options/channel.cpp index a04859865..46cc995ab 100644 --- a/src/chart/options/channel.cpp +++ b/src/chart/options/channel.cpp @@ -29,6 +29,11 @@ ChannelId asChannel(AxisId type) return static_cast(static_cast(type)); } +bool operator==(const AxisId &axis, const ChannelId &channel) +{ + return asChannel(axis) == channel; +} + Channel Channel::makeChannel(Type id) { switch (id) { diff --git a/src/chart/options/channel.h b/src/chart/options/channel.h index eb8f5e573..d4aa75b27 100644 --- a/src/chart/options/channel.h +++ b/src/chart/options/channel.h @@ -93,6 +93,9 @@ class Channel std::optional asAxis(ChannelId type); ChannelId asChannel(AxisId type); +[[nodiscard]] bool operator==(const AxisId &axis, + const ChannelId &channel); + } #endif diff --git a/src/chart/options/channels.h b/src/chart/options/channels.h index 57c929839..d5fa83a13 100644 --- a/src/chart/options/channels.h +++ b/src/chart/options/channels.h @@ -31,7 +31,16 @@ class Channels const std::span &channelTypes) const; [[nodiscard]] const Channel &at(const ChannelId &id) const; - Channel &at(const ChannelId &id); + [[nodiscard]] Channel &at(const ChannelId &id); + + [[nodiscard]] const Channel &at(const AxisId &id) const + { + return at(asChannel(id)); + } + [[nodiscard]] Channel &at(const AxisId &id) + { + return at(asChannel(id)); + } void removeSeries(const Data::SeriesIndex &index); diff --git a/src/chart/options/options.cpp b/src/chart/options/options.cpp index 546b8650c..c07bf5f14 100644 --- a/src/chart/options/options.cpp +++ b/src/chart/options/options.cpp @@ -81,7 +81,7 @@ ChannelId Options::stackChannelType() const if (channels.anyAxisSet()) { switch (geometry.get()) { case ShapeType::area: - case ShapeType::rectangle: return subAxisType(); + case ShapeType::rectangle: return asChannel(subAxisType()); default: case ShapeType::circle: case ShapeType::line: return ChannelId::size; @@ -93,7 +93,7 @@ ChannelId Options::stackChannelType() const std::optional Options::secondaryStackType() const { if (channels.anyAxisSet() && geometry == ShapeType::line) - return subAxisType(); + return asChannel(subAxisType()); return std::nullopt; } diff --git a/src/chart/options/options.h b/src/chart/options/options.h index 9982a07fe..abe910f01 100644 --- a/src/chart/options/options.h +++ b/src/chart/options/options.h @@ -66,9 +66,9 @@ class Options void reset(); - [[nodiscard]] ChannelId mainAxisType() const + [[nodiscard]] AxisId mainAxisType() const { - return isHorizontal() ? ChannelId::x : ChannelId::y; + return isHorizontal() ? AxisId::x : AxisId::y; } [[nodiscard]] bool isHorizontal() const @@ -79,9 +79,9 @@ class Options == Gen::Orientation::horizontal; } - [[nodiscard]] ChannelId subAxisType() const + [[nodiscard]] AxisId subAxisType() const { - return isHorizontal() ? ChannelId::y : ChannelId::x; + return isHorizontal() ? AxisId::y : AxisId::x; } [[nodiscard]] const Channel &mainAxis() const @@ -116,7 +116,7 @@ class Options [[nodiscard]] bool isSplit() const { return split - && (stackChannelType() != subAxisType() || isStacked()); + && (subAxisType() != stackChannelType() || isStacked()); } Heading title{std::nullopt}; From d13424e752da2789f755e823124dfc3d615eb751 Mon Sep 17 00:00:00 2001 From: Bela Schaum Date: Tue, 1 Oct 2024 17:32:00 +0200 Subject: [PATCH 2/6] Fix center axis --- src/chart/generator/plotbuilder.cpp | 19 +++++++++++++------ .../circle/08_d-w_cir_2c.mjs | 1 - .../circle_V1/08_d-w_cir_V1_2c.mjs | 3 +-- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/chart/generator/plotbuilder.cpp b/src/chart/generator/plotbuilder.cpp index 98c260901..2b1de357e 100644 --- a/src/chart/generator/plotbuilder.cpp +++ b/src/chart/generator/plotbuilder.cpp @@ -477,16 +477,23 @@ void PlotBuilder::addAlignment(const Buckets &subBuckets) const { if (static_cast(plot->getOptions()->split)) return; - if (std::signbit( - plot->axises.at(plot->getOptions()->subAxisType()) - .measure.range.getMin()) - || std::signbit( - plot->axises.at(plot->getOptions()->subAxisType()) - .measure.range.getMax())) + auto &subAxisRange = + plot->axises.at(plot->getOptions()->subAxisType()) + .measure.range; + if (std::signbit(subAxisRange.getMin()) + || std::signbit(subAxisRange.getMax())) return; if (plot->getOptions()->align == Base::Align::Type::none) return; + if (plot->getOptions()->align == Base::Align::Type::center) { + auto &&halfSize = subAxisRange.size() / 2.0; + if (!Math::Floating::is_zero(halfSize)) + subAxisRange = Math::Range::Raw( + subAxisRange.getMin() - halfSize, + subAxisRange.getMax() - halfSize); + } + auto &&vectical = !plot->getOptions()->isHorizontal(); const Base::Align align{plot->getOptions()->align, Math::Range(0.0, 1.0)}; diff --git a/test/e2e/test_cases/ww_noFade/wNoFade_cases/2_des_pol-without/circle/08_d-w_cir_2c.mjs b/test/e2e/test_cases/ww_noFade/wNoFade_cases/2_des_pol-without/circle/08_d-w_cir_2c.mjs index 14434d78c..5b18a57a7 100755 --- a/test/e2e/test_cases/ww_noFade/wNoFade_cases/2_des_pol-without/circle/08_d-w_cir_2c.mjs +++ b/test/e2e/test_cases/ww_noFade/wNoFade_cases/2_des_pol-without/circle/08_d-w_cir_2c.mjs @@ -43,7 +43,6 @@ const testSteps = [ size: { set: ['Year', 'Country'] } }, title: 'Stack Discs', - align: 'center' } }), diff --git a/test/e2e/test_cases/ww_noFade/wNoFade_cases/2_des_pol-without/circle_V1/08_d-w_cir_V1_2c.mjs b/test/e2e/test_cases/ww_noFade/wNoFade_cases/2_des_pol-without/circle_V1/08_d-w_cir_V1_2c.mjs index 431819f10..285d75774 100755 --- a/test/e2e/test_cases/ww_noFade/wNoFade_cases/2_des_pol-without/circle_V1/08_d-w_cir_V1_2c.mjs +++ b/test/e2e/test_cases/ww_noFade/wNoFade_cases/2_des_pol-without/circle_V1/08_d-w_cir_V1_2c.mjs @@ -42,8 +42,7 @@ const testSteps = [ noop: null, size: { set: ['Year', 'Country'] } }, - title: 'Stack Discs', - align: 'center' + title: 'Stack Discs' } }), From adc3ff81dc97872a34e24c8f6b3f7ff7eb938334 Mon Sep 17 00:00:00 2001 From: Bela Schaum Date: Tue, 1 Oct 2024 17:34:22 +0200 Subject: [PATCH 3/6] polarConnection only in rect - line geom --- test/e2e/test_cases/test_cases.json | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/test/e2e/test_cases/test_cases.json b/test/e2e/test_cases/test_cases.json index 6a6c9b478..ddf197684 100644 --- a/test/e2e/test_cases/test_cases.json +++ b/test/e2e/test_cases/test_cases.json @@ -113,7 +113,7 @@ "refs": ["69db5d4"] }, "basic_animations/someOtherTests/merge_split_area_stream_2dis_1con": { - "refs": ["b1e67de"] + "refs": ["e331f23"] }, "basic_animations/someOtherTests/total_time_area_bar": { "refs": ["d908ab5"] @@ -506,7 +506,7 @@ "refs": ["08e742c"] }, "web_content/analytical_operations/compare/stream_stacked": { - "refs": ["8200148"] + "refs": ["845f43a"] }, "web_content/analytical_operations/compare/waterfall": { "refs": ["6c43732"] @@ -620,10 +620,10 @@ "refs": ["dcff220"] }, "web_content/analytical_operations/filter/stream_1": { - "refs": ["2710f78"] + "refs": ["4f827d6"] }, "web_content/analytical_operations/filter/stream_2": { - "refs": ["75719ee"] + "refs": ["9793ec1"] }, "web_content/analytical_operations/misc/donut_to_coxcomb": { "refs": ["76f76c6"] @@ -770,7 +770,7 @@ "refs": ["4e1f1e8"] }, "web_content/analytical_operations/sum/stream_stacked": { - "refs": ["9f4e0b4"] + "refs": ["9d0aeee"] }, "web_content/analytical_operations/sum/treemap": { "refs": ["d8a8b1c"] @@ -800,7 +800,7 @@ "refs": ["bf2c4b9"] }, "web_content_removed/animated/merge_split_area_stream_3dis_1con": { - "refs": ["305f396"] + "refs": ["c9c9175"] }, "web_content_removed/animated/merge_split_bar": { "refs": ["cf60e63"] @@ -923,10 +923,10 @@ "refs": ["4bebc47"] }, "web_content/presets/graph/stream": { - "refs": ["1be4e97"] + "refs": ["83e8724"] }, "web_content/presets/graph/stream_vertical": { - "refs": ["cc443a6"] + "refs": ["15b5f83"] }, "web_content/presets/graph/violin": { "refs": ["683b150"] @@ -1037,7 +1037,7 @@ "refs": ["c1a8d39"] }, "web_content/static/graph/stream_stacked": { - "refs": ["843591b"] + "refs": ["3ab1f0c"] }, "web_content/static/chart/waterfall": { "refs": ["2aeab23"] @@ -3065,10 +3065,10 @@ "refs": ["52a2da9"] }, "ww_samples_for_presets/cartesian_coo_sys/32_C_A_stream_graph": { - "refs": ["9d218d6"] + "refs": ["dd86c4e"] }, "ww_samples_for_presets/cartesian_coo_sys/33_C_A_stream_graph_vert": { - "refs": ["14a0296"] + "refs": ["bd982e1"] }, "ww_samples_for_presets/cartesian_coo_sys/34_C_A_violin_graph": { "refs": ["0cddf74"] From a6436791123a22f6cd129f3d11eb0b268a143053 Mon Sep 17 00:00:00 2001 From: Bela Schaum Date: Tue, 1 Oct 2024 18:59:29 +0200 Subject: [PATCH 4/6] fix test format --- .../wNoFade_cases/2_des_pol-without/circle/08_d-w_cir_2c.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/e2e/test_cases/ww_noFade/wNoFade_cases/2_des_pol-without/circle/08_d-w_cir_2c.mjs b/test/e2e/test_cases/ww_noFade/wNoFade_cases/2_des_pol-without/circle/08_d-w_cir_2c.mjs index 5b18a57a7..9d2b2637e 100755 --- a/test/e2e/test_cases/ww_noFade/wNoFade_cases/2_des_pol-without/circle/08_d-w_cir_2c.mjs +++ b/test/e2e/test_cases/ww_noFade/wNoFade_cases/2_des_pol-without/circle/08_d-w_cir_2c.mjs @@ -42,7 +42,7 @@ const testSteps = [ noop: null, size: { set: ['Year', 'Country'] } }, - title: 'Stack Discs', + title: 'Stack Discs' } }), From 15852e819f64920b901ad5e12599b9638fac9dc2 Mon Sep 17 00:00:00 2001 From: Bela Schaum Date: Tue, 1 Oct 2024 19:38:21 +0200 Subject: [PATCH 5/6] Fix 2 changed testcases --- test/e2e/test_cases/test_cases.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/e2e/test_cases/test_cases.json b/test/e2e/test_cases/test_cases.json index ddf197684..e48843225 100644 --- a/test/e2e/test_cases/test_cases.json +++ b/test/e2e/test_cases/test_cases.json @@ -2738,7 +2738,7 @@ "refs": ["9efe1ec"] }, "ww_noFade/wNoFade_cases/2_des_pol-without/circle/08_d-w_cir_2c": { - "refs": ["ac16890"] + "refs": ["940bc39"] }, "ww_noFade/wNoFade_cases/2_des_pol-without/circle_V1/03_d-w_cir_V1": { "refs": ["327ca16"] @@ -2765,7 +2765,7 @@ "refs": ["30f4ada"] }, "ww_noFade/wNoFade_cases/2_des_pol-without/circle_V1/08_d-w_cir_V1_2c": { - "refs": ["1a81ceb"] + "refs": ["cc6ba1d"] }, "ww_noFade/wNoFade_cases/2_des_pol-without/line-rectangle/02_d-d_lin": { "refs": ["64361fc"] From c1b7514c915cba44152028015f2ad964f493d4f7 Mon Sep 17 00:00:00 2001 From: Bela Schaum Date: Tue, 1 Oct 2024 19:39:57 +0200 Subject: [PATCH 6/6] add changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f493fc473..f7b33819e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ - Fix line-rectangle polar connection linearity. - Fix all polar connection interpolation (except fading). - Remove unwanted line connections from line-circle + orientation changed anim. +- Move axis to the center on align: center charts. ## [0.13.0] - 2024-09-13