Skip to content

Commit 7c69697

Browse files
authored
Merge pull request #555 from vizzuhq/review
#549 review changes
2 parents 9405570 + 5486a6f commit 7c69697

23 files changed

+369
-303
lines changed

CHANGELOG.md

+17-3
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,26 @@
44

55
### Fixed
66

7-
- First marker alpha was different to other marker's alpha
8-
- Make some transactions clearer. (rectangle-line first marker)
7+
- Make some static charts clearer:
8+
- Area/line charts different markers are not connected.
9+
- Not existing or disabled markers have no effect.
10+
- Make some transactions clearer:
11+
- Rectangle - Line/Area first marker not fades, but shrinks.
12+
- The first marker's alpha was different to the other marker's alpha.
13+
- Marker connection rework: Introduce invalid, polar and self connection.
14+
- Marker connection animation step necessity and timing fixes.
15+
- Slipped animation steps (coordinateSystem - connection/orientation) fixes.
16+
- Filtered markers (and their connections):
17+
- Disappearing on hide animation phase.
18+
- Appearing on show animation phase.
919

1020
### Added
1121

12-
- New data handling implemented: Not generating big cube
22+
- New data handling implemented:
23+
- Only existing data generates the chart.
24+
- Reduced memory usage.
25+
- Bigger data capacity.
26+
- Canvas line drawing detail can be set (on C++ side).
1327

1428
## [0.11.4] - 2024-07-09
1529

src/apps/weblib/cinterface.cpp

+5-3
Original file line numberDiff line numberDiff line change
@@ -193,10 +193,12 @@ void vizzu_render(APIHandles::Chart chart,
193193
}
194194

195195
void vizzu_setLineResolution(APIHandles::Canvas canvas,
196-
double dMax,
197-
double hMax)
196+
double distanceMax,
197+
double curveHeightMax)
198198
{
199-
Interface::getInstance().setLineResolution(canvas, dMax, hMax);
199+
Interface::getInstance().setLineResolution(canvas,
200+
distanceMax,
201+
curveHeightMax);
200202
}
201203

202204
const char *style_getList() { return Interface::getStyleList(); }

src/apps/weblib/cinterface.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ extern void vizzu_render(APIHandles::Chart chart,
6969
double width,
7070
double height);
7171
extern void vizzu_setLineResolution(APIHandles::Canvas canvas,
72-
double dMax,
73-
double hMax);
72+
double distanceMax,
73+
double curveHeightMax);
7474

7575
extern const char *vizzu_errorMessage(
7676
APIHandles::Exception exceptionPtr,

src/apps/weblib/interface.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -404,12 +404,12 @@ void Interface::render(ObjectRegistryHandle chart,
404404
}
405405

406406
void Interface::setLineResolution(ObjectRegistryHandle canvas,
407-
double dMax,
408-
double hMax)
407+
double distanceMax,
408+
double curveHeightMax)
409409
{
410410
static_cast<Draw::Painter *>(
411411
objects.get<Gfx::ICanvas>(canvas)->getPainter())
412-
->setPathSamplerOptions({dMax, hMax});
412+
->setPathSamplerOptions({distanceMax, curveHeightMax});
413413
}
414414

415415
void Interface::pointerDown(ObjectRegistryHandle chart,

src/apps/weblib/interface.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ class Interface
5656
double width,
5757
double height);
5858
void setLineResolution(ObjectRegistryHandle canvas,
59-
double dMax,
60-
double hMax);
59+
double distanceMax,
60+
double curveHeightMax);
6161

6262
ObjectRegistryHandle storeAnim(ObjectRegistryHandle chart);
6363
void restoreAnim(ObjectRegistryHandle chart,

src/apps/weblib/ts-api/cvizzu.types.d.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ export interface CVizzu {
9191
_vizzu_pointerLeave(chart: CChartPtr, canvas: CCanvasPtr, pointerId: number): void
9292
_vizzu_wheel(chart: CChartPtr, canvas: CCanvasPtr, delta: number): void
9393
_vizzu_setLogging(enable: boolean): void
94-
_vizzu_update(chart: CChartPtr, time: number): CString
95-
_vizzu_setLineResolution(canvas: CCanvasPtr, dMax: number, hMax: number): void
94+
_vizzu_update(chart: CChartPtr, time: number): void
95+
_vizzu_setLineResolution(canvas: CCanvasPtr, distanceMax: number, curveHeightMax: number): void
9696
_vizzu_render(chart: CChartPtr, canvas: CCanvasPtr, width: number, height: number): void
9797

9898
_vizzu_errorMessage(exceptionPtr: CException, typeinfo: CTypeInfo): CString

src/base/anim/interpolated.h

+14-17
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,12 @@ template <typename Type> class Weighted
3434
return value == other.value && weight == other.weight;
3535
}
3636

37-
template <typename Comparator =
38-
std::conditional_t<std::floating_point<Type>,
39-
decltype(Math::Floating::less),
40-
std::less<Type>>>
4137
bool operator<(const Weighted<Type> &other) const
4238
{
43-
return Comparator{}(value, other.value);
39+
using Less = std::conditional_t<std::floating_point<Type>,
40+
decltype(Math::Floating::less),
41+
std::less<Type>>;
42+
return Less{}(value, other.value);
4443
}
4544

4645
[[nodiscard]] bool hasValue() const { return weight > 0.0; }
@@ -224,28 +223,26 @@ template <typename Type> class Interpolated
224223
return res;
225224
}
226225

227-
template <typename T = Type,
228-
typename Cmp = std::conditional_t<std::floating_point<T>,
229-
decltype(Math::Floating::less),
230-
std::less<T>>>
231-
[[nodiscard]] T min() const
226+
template <typename T = Type> [[nodiscard]] T min() const
232227
{
228+
using Less = std::conditional_t<std::floating_point<T>,
229+
decltype(Math::Floating::less),
230+
std::less<T>>;
233231
return !has_second ? this->values[0].value
234232
: std::min(this->values[0].value,
235233
this->values[1].value,
236-
Cmp{});
234+
Less{});
237235
}
238236

239-
template <typename T = Type,
240-
typename Cmp = std::conditional_t<std::floating_point<T>,
241-
decltype(Math::Floating::less),
242-
std::less<T>>>
243-
[[nodiscard]] T max() const
237+
template <typename T = Type> [[nodiscard]] T max() const
244238
{
239+
using Less = std::conditional_t<std::floating_point<T>,
240+
decltype(Math::Floating::less),
241+
std::less<T>>;
245242
return !has_second ? this->values[0].value
246243
: std::max(this->values[0].value,
247244
this->values[1].value,
248-
Cmp{});
245+
Less{});
249246
}
250247
};
251248

src/base/gfx/pathsampler.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,19 @@ void PathSampler::path(const Geom::Point &pConv0,
3232
auto height = 2 * area / (pConv1 - pConv0).abs();
3333

3434
auto needMore =
35-
height > options.hMax
35+
height > options.curveHeightMax
3636
|| ((pConv1 - pConv0).sqrAbs() < (pConv - pConv0).sqrAbs())
3737
|| ((pConv1 - pConv0).sqrAbs() < (pConv - pConv1).sqrAbs());
3838

3939
if (needMore) {
40-
if ((pConv - pConv0).sqrAbs() > options.dMax)
40+
if ((pConv - pConv0).sqrAbs() > options.distanceMax)
4141
path(pConv0, pConv, i0, i, recurseCnt + 1);
4242
}
4343

4444
addPoint(pConv);
4545

4646
if (needMore) {
47-
if ((pConv - pConv1).sqrAbs() > options.dMax)
47+
if ((pConv - pConv1).sqrAbs() > options.distanceMax)
4848
path(pConv, pConv1, i, i1, recurseCnt + 1);
4949
}
5050
}

src/base/gfx/pathsampler.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ class PathSampler
1313
public:
1414
struct Options
1515
{
16-
double dMax;
17-
double hMax;
16+
double distanceMax;
17+
double curveHeightMax;
1818
};
1919
explicit PathSampler(const Options &options) : options(options) {}
2020

src/base/math/floating.h

+1-35
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
#ifndef MATH_FLOATING
22
#define MATH_FLOATING
33

4-
#include <bit>
54
#include <compare>
65
#include <concepts>
7-
#include <cstdint>
86
#include <limits>
97

108
namespace Math::Floating
@@ -18,43 +16,11 @@ constexpr auto inline less = [](auto a, auto b)
1816
return std::is_lt(std::strong_order(a, b));
1917
};
2018

21-
template <std::floating_point F,
22-
std::size_t v =
23-
std::numeric_limits<F>::is_iec559
24-
&&std::numeric_limits<F>::radix
25-
== 2
26-
&& std::numeric_limits<unsigned char>::digits == 8
27-
? sizeof(F)
28-
: std::size_t{}>
29-
constexpr auto inline can_be_used_as_short_check =
30-
std::bool_constant<false>{};
31-
32-
template <std::floating_point F>
33-
constexpr auto inline can_be_used_as_short_check<F, 4> =
34-
std::integral_constant<std::uint32_t,
35-
std::bit_cast<std::uint32_t>(F{0.0}) == std::uint32_t{}
36-
&& std::bit_cast<std::uint32_t>(F{-0.0})
37-
+ std::bit_cast<std::uint32_t>(F{-0.0})
38-
== std::uint32_t{}>{};
39-
40-
template <std::floating_point F>
41-
constexpr auto inline can_be_used_as_short_check<F, 8> =
42-
std::integral_constant<std::uint64_t,
43-
std::bit_cast<std::uint64_t>(F{0.0}) == std::uint64_t{}
44-
&& std::bit_cast<std::uint64_t>(F{-0.0})
45-
+ std::bit_cast<std::uint64_t>(F{-0.0})
46-
== std::uint64_t{}>{};
47-
4819
constexpr auto inline is_zero = [](auto value)
4920
{
5021
using F = decltype(value);
5122
static_assert(std::floating_point<F>);
52-
if constexpr (auto v = can_be_used_as_short_check<F>; v()) {
53-
const auto val =
54-
std::bit_cast<typename decltype(v)::value_type>(value);
55-
return val + val == 0;
56-
}
57-
else if constexpr (std::numeric_limits<F>::is_iec559) {
23+
if constexpr (std::numeric_limits<F>::is_iec559) {
5824
return value == F{};
5925
}
6026
else {

src/chart/generator/buckets.cpp

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
2+
#include "buckets.h"
3+
4+
#include <numeric>
5+
6+
#include "dataframe/old/types.h"
7+
8+
#include "marker.h"
9+
10+
namespace Vizzu::Gen
11+
{
12+
13+
Buckets::Buckets(std::span<Marker> markers) : markers(markers.size())
14+
{
15+
std::iota(this->markers.begin(),
16+
this->markers.end(),
17+
markers.data());
18+
}
19+
20+
Buckets &Buckets::sort(MarkerIDGet id_get)
21+
{
22+
marker_id_get = id_get;
23+
std::ranges::stable_sort(markers,
24+
[id_get](Marker *lhs, Marker *rhs) -> bool
25+
{
26+
if (auto &&cmp = lhs->*id_get <=> rhs->*id_get;
27+
std::is_neq(cmp))
28+
return std::is_lt(cmp);
29+
return lhs < rhs;
30+
});
31+
return *this;
32+
}
33+
34+
Buckets::const_iterator &Buckets::const_iterator::operator++()
35+
{
36+
const auto *const real_end =
37+
parent->markers.data() + parent->markers.size();
38+
const auto *const curr_end = data.data() + data.size();
39+
data = {curr_end,
40+
curr_end == real_end
41+
? curr_end
42+
: std::partition_point(curr_end,
43+
real_end,
44+
[this,
45+
searched =
46+
(*curr_end->*parent->marker_id_get).seriesId](
47+
Marker *lhs) -> bool
48+
{
49+
return (lhs->*parent->marker_id_get).seriesId
50+
== searched;
51+
})};
52+
return *this;
53+
}
54+
55+
}

src/chart/generator/buckets.h

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#ifndef BUCKETS_H
2+
#define BUCKETS_H
3+
4+
#include <ranges>
5+
#include <span>
6+
#include <vector>
7+
8+
namespace Vizzu
9+
{
10+
11+
namespace Data
12+
{
13+
struct MarkerId;
14+
}
15+
16+
namespace Gen
17+
{
18+
class Marker;
19+
20+
struct Buckets
21+
{
22+
using MarkerIDGet = Data::MarkerId Marker::*;
23+
std::vector<Marker *> markers;
24+
MarkerIDGet marker_id_get{};
25+
26+
explicit Buckets(std::span<Marker> markers);
27+
28+
Buckets &sort(MarkerIDGet id_get);
29+
30+
[[nodiscard]] bool empty() const { return markers.empty(); }
31+
32+
struct const_iterator
33+
{
34+
std::span<Marker *const> data;
35+
const Buckets *parent;
36+
37+
[[nodiscard]] auto operator*() const
38+
{
39+
return std::ranges::views::transform(data,
40+
[this](Marker *marker)
41+
-> std::pair<Marker &, const Data::MarkerId &>
42+
{
43+
return {*marker, marker->*parent->marker_id_get};
44+
});
45+
}
46+
47+
[[nodiscard]] bool operator!=(const const_iterator &oth) const
48+
{
49+
return data.data() != oth.data.data();
50+
}
51+
52+
const_iterator &operator++();
53+
};
54+
55+
[[nodiscard]] const_iterator begin() const
56+
{
57+
return ++const_iterator{{markers.data(), markers.data()},
58+
this};
59+
}
60+
61+
[[nodiscard]] const_iterator end() const
62+
{
63+
const auto *const end{markers.data() + markers.size()};
64+
return {{end, end}, this};
65+
}
66+
};
67+
68+
}
69+
}
70+
71+
#endif // BUCKETS_H

src/chart/generator/marker.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ bool Marker::connectMarkers(bool first,
128128
next->prevMainMarker =
129129
MarkerIndexPosition{prev->idx, prev->pos};
130130
next->polarConnection = polarConnection && first;
131-
return !first || polarConnection;
131+
return true;
132132
}
133133
if (next && main) {
134134
next->prevMainMarker =

0 commit comments

Comments
 (0)