Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#549 review changes #555

Merged
merged 9 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 17 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,26 @@

### Fixed

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

### Added

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

## [0.11.4] - 2024-07-09

Expand Down
8 changes: 5 additions & 3 deletions src/apps/weblib/cinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,12 @@ void vizzu_render(APIHandles::Chart chart,
}

void vizzu_setLineResolution(APIHandles::Canvas canvas,
double dMax,
double hMax)
double distanceMax,
double curveHeightMax)
{
Interface::getInstance().setLineResolution(canvas, dMax, hMax);
Interface::getInstance().setLineResolution(canvas,
distanceMax,
curveHeightMax);
}

const char *style_getList() { return Interface::getStyleList(); }
Expand Down
4 changes: 2 additions & 2 deletions src/apps/weblib/cinterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ extern void vizzu_render(APIHandles::Chart chart,
double width,
double height);
extern void vizzu_setLineResolution(APIHandles::Canvas canvas,
double dMax,
double hMax);
double distanceMax,
double curveHeightMax);

extern const char *vizzu_errorMessage(
APIHandles::Exception exceptionPtr,
Expand Down
6 changes: 3 additions & 3 deletions src/apps/weblib/interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -404,12 +404,12 @@ void Interface::render(ObjectRegistryHandle chart,
}

void Interface::setLineResolution(ObjectRegistryHandle canvas,
double dMax,
double hMax)
double distanceMax,
double curveHeightMax)
{
static_cast<Draw::Painter *>(
objects.get<Gfx::ICanvas>(canvas)->getPainter())
->setPathSamplerOptions({dMax, hMax});
->setPathSamplerOptions({distanceMax, curveHeightMax});
}

void Interface::pointerDown(ObjectRegistryHandle chart,
Expand Down
4 changes: 2 additions & 2 deletions src/apps/weblib/interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ class Interface
double width,
double height);
void setLineResolution(ObjectRegistryHandle canvas,
double dMax,
double hMax);
double distanceMax,
double curveHeightMax);

ObjectRegistryHandle storeAnim(ObjectRegistryHandle chart);
void restoreAnim(ObjectRegistryHandle chart,
Expand Down
4 changes: 2 additions & 2 deletions src/apps/weblib/ts-api/cvizzu.types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ export interface CVizzu {
_vizzu_pointerLeave(chart: CChartPtr, canvas: CCanvasPtr, pointerId: number): void
_vizzu_wheel(chart: CChartPtr, canvas: CCanvasPtr, delta: number): void
_vizzu_setLogging(enable: boolean): void
_vizzu_update(chart: CChartPtr, time: number): CString
_vizzu_setLineResolution(canvas: CCanvasPtr, dMax: number, hMax: number): void
_vizzu_update(chart: CChartPtr, time: number): void
_vizzu_setLineResolution(canvas: CCanvasPtr, distanceMax: number, curveHeightMax: number): void
_vizzu_render(chart: CChartPtr, canvas: CCanvasPtr, width: number, height: number): void

_vizzu_errorMessage(exceptionPtr: CException, typeinfo: CTypeInfo): CString
Expand Down
31 changes: 14 additions & 17 deletions src/base/anim/interpolated.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,12 @@ template <typename Type> class Weighted
return value == other.value && weight == other.weight;
}

template <typename Comparator =
std::conditional_t<std::floating_point<Type>,
decltype(Math::Floating::less),
std::less<Type>>>
bool operator<(const Weighted<Type> &other) const
{
return Comparator{}(value, other.value);
using Less = std::conditional_t<std::floating_point<Type>,
decltype(Math::Floating::less),
std::less<Type>>;
return Less{}(value, other.value);
}

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

template <typename T = Type,
typename Cmp = std::conditional_t<std::floating_point<T>,
decltype(Math::Floating::less),
std::less<T>>>
[[nodiscard]] T min() const
template <typename T = Type> [[nodiscard]] T min() const
{
using Less = std::conditional_t<std::floating_point<T>,
decltype(Math::Floating::less),
std::less<T>>;
return !has_second ? this->values[0].value
: std::min(this->values[0].value,
this->values[1].value,
Cmp{});
Less{});
}

template <typename T = Type,
typename Cmp = std::conditional_t<std::floating_point<T>,
decltype(Math::Floating::less),
std::less<T>>>
[[nodiscard]] T max() const
template <typename T = Type> [[nodiscard]] T max() const
{
using Less = std::conditional_t<std::floating_point<T>,
decltype(Math::Floating::less),
std::less<T>>;
return !has_second ? this->values[0].value
: std::max(this->values[0].value,
this->values[1].value,
Cmp{});
Less{});
}
};

Expand Down
6 changes: 3 additions & 3 deletions src/base/gfx/pathsampler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,19 @@ void PathSampler::path(const Geom::Point &pConv0,
auto height = 2 * area / (pConv1 - pConv0).abs();

auto needMore =
height > options.hMax
height > options.curveHeightMax
|| ((pConv1 - pConv0).sqrAbs() < (pConv - pConv0).sqrAbs())
|| ((pConv1 - pConv0).sqrAbs() < (pConv - pConv1).sqrAbs());

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

addPoint(pConv);

if (needMore) {
if ((pConv - pConv1).sqrAbs() > options.dMax)
if ((pConv - pConv1).sqrAbs() > options.distanceMax)
path(pConv, pConv1, i, i1, recurseCnt + 1);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/base/gfx/pathsampler.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ class PathSampler
public:
struct Options
{
double dMax;
double hMax;
double distanceMax;
double curveHeightMax;
};
explicit PathSampler(const Options &options) : options(options) {}

Expand Down
36 changes: 1 addition & 35 deletions src/base/math/floating.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
#ifndef MATH_FLOATING
#define MATH_FLOATING

#include <bit>
#include <compare>
#include <concepts>
#include <cstdint>
#include <limits>

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

template <std::floating_point F,
std::size_t v =
std::numeric_limits<F>::is_iec559
&&std::numeric_limits<F>::radix
== 2
&& std::numeric_limits<unsigned char>::digits == 8
? sizeof(F)
: std::size_t{}>
constexpr auto inline can_be_used_as_short_check =
std::bool_constant<false>{};

template <std::floating_point F>
constexpr auto inline can_be_used_as_short_check<F, 4> =
std::integral_constant<std::uint32_t,
std::bit_cast<std::uint32_t>(F{0.0}) == std::uint32_t{}
&& std::bit_cast<std::uint32_t>(F{-0.0})
+ std::bit_cast<std::uint32_t>(F{-0.0})
== std::uint32_t{}>{};

template <std::floating_point F>
constexpr auto inline can_be_used_as_short_check<F, 8> =
std::integral_constant<std::uint64_t,
std::bit_cast<std::uint64_t>(F{0.0}) == std::uint64_t{}
&& std::bit_cast<std::uint64_t>(F{-0.0})
+ std::bit_cast<std::uint64_t>(F{-0.0})
== std::uint64_t{}>{};

constexpr auto inline is_zero = [](auto value)
{
using F = decltype(value);
static_assert(std::floating_point<F>);
if constexpr (auto v = can_be_used_as_short_check<F>; v()) {
const auto val =
std::bit_cast<typename decltype(v)::value_type>(value);
return val + val == 0;
}
else if constexpr (std::numeric_limits<F>::is_iec559) {
if constexpr (std::numeric_limits<F>::is_iec559) {
return value == F{};
}
else {
Expand Down
55 changes: 55 additions & 0 deletions src/chart/generator/buckets.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@

#include "buckets.h"

#include <numeric>

#include "dataframe/old/types.h"

#include "marker.h"

namespace Vizzu::Gen
{

Buckets::Buckets(std::span<Marker> markers) : markers(markers.size())
{
std::iota(this->markers.begin(),
this->markers.end(),
markers.data());
}

Buckets &Buckets::sort(MarkerIDGet id_get)
{
marker_id_get = id_get;
std::ranges::stable_sort(markers,
[id_get](Marker *lhs, Marker *rhs) -> bool
{
if (auto &&cmp = lhs->*id_get <=> rhs->*id_get;
std::is_neq(cmp))
return std::is_lt(cmp);
return lhs < rhs;
});
return *this;
}

Buckets::const_iterator &Buckets::const_iterator::operator++()
{
const auto *const real_end =
parent->markers.data() + parent->markers.size();
const auto *const curr_end = data.data() + data.size();
data = {curr_end,
curr_end == real_end
? curr_end
: std::partition_point(curr_end,
real_end,
[this,
searched =
(*curr_end->*parent->marker_id_get).seriesId](
Marker *lhs) -> bool
{
return (lhs->*parent->marker_id_get).seriesId
== searched;
})};
return *this;
}

}
71 changes: 71 additions & 0 deletions src/chart/generator/buckets.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#ifndef BUCKETS_H
#define BUCKETS_H

#include <ranges>
#include <span>
#include <vector>

namespace Vizzu
{

namespace Data
{
struct MarkerId;
}

namespace Gen
{
class Marker;

struct Buckets
{
using MarkerIDGet = Data::MarkerId Marker::*;
std::vector<Marker *> markers;
MarkerIDGet marker_id_get{};

explicit Buckets(std::span<Marker> markers);

Buckets &sort(MarkerIDGet id_get);

[[nodiscard]] bool empty() const { return markers.empty(); }

struct const_iterator
{
std::span<Marker *const> data;
const Buckets *parent;

[[nodiscard]] auto operator*() const
{
return std::ranges::views::transform(data,
[this](Marker *marker)
-> std::pair<Marker &, const Data::MarkerId &>
{
return {*marker, marker->*parent->marker_id_get};
});
}

[[nodiscard]] bool operator!=(const const_iterator &oth) const
{
return data.data() != oth.data.data();
}

const_iterator &operator++();
};

[[nodiscard]] const_iterator begin() const
{
return ++const_iterator{{markers.data(), markers.data()},
this};
}

[[nodiscard]] const_iterator end() const
{
const auto *const end{markers.data() + markers.size()};
return {{end, end}, this};
}
};

}
}

#endif // BUCKETS_H
2 changes: 1 addition & 1 deletion src/chart/generator/marker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ bool Marker::connectMarkers(bool first,
next->prevMainMarker =
MarkerIndexPosition{prev->idx, prev->pos};
next->polarConnection = polarConnection && first;
return !first || polarConnection;
return true;
}
if (next && main) {
next->prevMainMarker =
Expand Down
Loading