Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/main' into remove-a…
Browse files Browse the repository at this point in the history
…lign_min

# Conflicts:
#	CHANGELOG.md
  • Loading branch information
schaumb committed Oct 16, 2024
2 parents 838db45 + 941a7e3 commit bff9def
Show file tree
Hide file tree
Showing 43 changed files with 1,022 additions and 949 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@

## [Unreleased]

### Changed
### Fixed

- Removed 'min' align property from the API which equivalent with the 'none'.
- Markers are the same even if new record added.

### Changed

- Changed MarkerId to be a string instead of a number.


## [0.14.0] - 2024-10-03

Expand Down
7 changes: 4 additions & 3 deletions src/apps/weblib/jscriptcanvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,10 @@ void JScriptCanvas::resetStates()
Geom::Size Gfx::ICanvas::textBoundary(const Gfx::Font &font,
const std::string &text)
{
thread_local std::string fontCache;
fontCache = font.toCSS();
Geom::Size res;
::textBoundary(fontCache.c_str(), text.c_str(), &res.x, &res.y);
::textBoundary(font.toCSS().c_str(),
text.c_str(),
&res.x,
&res.y);
return res;
}
2 changes: 1 addition & 1 deletion src/apps/weblib/ts-api/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ export interface Marker extends Element {
categories: Data.Record
values: Data.Record
/** Unique index of the marker. */
index: number
index: string
}

/** Label element of a marker element. */
Expand Down
8 changes: 4 additions & 4 deletions src/apps/weblib/ts-api/plugins/tooltip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ export class Tooltip implements Plugin {
private _vizzu?: Vizzu
private _id = 0
private _animating = false
private _lastMarkerId: number | null = null
private _overedMarkerId: number | null = null
private _lastMarkerId: string | null = null
private _overedMarkerId: string | null = null
private _lastMove = new Date().getTime()

get hooks(): PluginHooks {
Expand Down Expand Up @@ -83,7 +83,7 @@ export class Tooltip implements Plugin {
}
}

_getMarkerId(target: Element | null): number | null {
_getMarkerId(target: Element | null): string | null {
if (target && this._isMarker(target)) {
return target.index
} else if (target && this._isMarkerLabel(target)) {
Expand All @@ -101,7 +101,7 @@ export class Tooltip implements Plugin {
return target.tagName === 'plot-marker-label'
}

_in(id: number, markerId: number): void {
_in(id: number, markerId: string): void {
if (this._id === id) {
if (!this._animating) {
this._lastMarkerId = markerId
Expand Down
8 changes: 4 additions & 4 deletions src/apps/weblib/typeschema-api/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,8 @@ definitions:
type: boolean
tooltip:
description: |
Index of the marker, the tooltip should be turned on. This parameter is not needed
to set manually, tooltip will be taken care of autamatically when `tooltip` feature
is enabled.
type: number
Unique identifier of the marker, the tooltip should be turned on. This parameter is
not needed to set manually, tooltip will be taken care of automatically when
`tooltip` feature is enabled.
type: string
nullable: true
12 changes: 11 additions & 1 deletion src/base/conv/auto_json.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,22 @@ struct JSON
&& !std::is_same_v<std::remove_cvref_t<T>, std::nullptr_t>
&& !std::is_same_v<std::remove_cvref_t<T>, std::nullopt_t>
&& !Optional<T> && !StringConvertable<T>
&& !SerializableRange<T> && !Tuple<T>)
&& !SerializableRange<T> && !Tuple<T>
&& !Type::is_reference_wrapper_v<T>)
void any(const T &val) const
{
staticObj(val);
}

template <class T>
requires(!JSONSerializable<T> && !SerializableRange<T>
&& !StringConvertable<T>
&& Type::is_reference_wrapper_v<T>)
void any(const T &val) const
{
any(val.get());
}

explicit JSON(std::string &json) : json(json) {}

std::string &json;
Expand Down
12 changes: 8 additions & 4 deletions src/base/conv/numtostr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,24 @@ std::string NumberToString::convert(double number)
("%." + std::to_string(fractionDigitCount) + "f").c_str(),
number));

auto decimalPoint =
std::min(number_view.find('.'), number_view.size());
auto decimalPoint = std::min({number_view.find(','),
number_view.find('.'),
number_view.size()});
if (decimalPoint != number_view.size()) {
if (!fillFractionWithZero) {
number_view = number_view.substr(0,
number_view.find_last_not_of('0') + 1);
}
if (number_view.ends_with('.')) {
if (number_view.ends_with(',')
|| number_view.ends_with('.')) {
number_view.remove_suffix(1);
}
}

if (number_view.starts_with('-')
&& number_view.find_last_not_of("0.") == 0) {
&& number_view.find_last_not_of(std::string_view{
std::initializer_list<char>{'0', ',', '.', '\0'}})
== 0) {
number_view.remove_prefix(1);
++begin;
--decimalPoint;
Expand Down
2 changes: 1 addition & 1 deletion src/base/conv/parse.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ template <typename To> To parse(const std::string &string)
else if constexpr (Parsable<To>) {
return To::fromString(string);
}
else if constexpr (Type::isoptional<To>::value) {
else if constexpr (Type::is_optional_v<To>) {
if (string == "null") return std::nullopt;
return parse<typename To::value_type>(string);
}
Expand Down
4 changes: 2 additions & 2 deletions src/base/conv/tostring.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ concept ToStringMember =

template <typename From>
requires(ToStringMember<From> || std::is_enum_v<From>
|| Type::isoptional<From>::value
|| Type::is_optional_v<From>
|| std::is_constructible_v<std::string, From>
|| std::is_arithmetic_v<From>)
std::string toString(const From &value)
{
if constexpr (std::is_enum_v<From>) {
return Refl::enum_name<std::string>(value);
}
else if constexpr (Type::isoptional<From>::value) {
else if constexpr (Type::is_optional_v<From>) {
if (!value) return "null";
return toString(*value);
}
Expand Down
5 changes: 0 additions & 5 deletions src/base/gfx/canvas.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#ifndef GFX_CANVAS
#define GFX_CANVAS

#include <memory>
#include <string>

#include "base/geom/affinetransform.h"
Expand All @@ -10,15 +9,11 @@
#include "base/geom/point.h"
#include "base/geom/rect.h"
#include "base/gfx/color.h"
#include "base/gfx/colortransform.h"
#include "base/gfx/font.h"
#include "base/gfx/lineargradient.h"

namespace Gfx
{

struct ICanvas;

struct ICanvas
{
virtual ~ICanvas() = default;
Expand Down
7 changes: 7 additions & 0 deletions src/base/refl/auto_enum.h
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ struct EnumVariant : std::variant<Args...>
{
using base_variant = std::variant<Args...>;
using base_variant::base_variant;
using enum_type = E;

[[nodiscard]] constexpr operator E() const noexcept // NOLINT
{
Expand Down Expand Up @@ -287,6 +288,12 @@ constexpr decltype(auto) get_if(EnumVariant<decltype(E), Args...> *e)
return std::get_if<static_cast<std::size_t>(E)>(e);
}

template <auto E, class Variant>
requires std::same_as<decltype(E), typename Variant::enum_type>
using variant_alternative_t =
std::variant_alternative_t<static_cast<std::size_t>(E),
typename Variant::base_variant>;

}

#endif
8 changes: 6 additions & 2 deletions src/base/refl/auto_struct.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,10 @@ template <class T,
struct loophole_type_list;

template <typename T, std::size_t... B, std::size_t... Ix>
requires(requires {
T{loophole_ubiq<T, B, true>{}...,
loophole_ubiq<T, sizeof...(B) + Ix>{}...};
})
struct loophole_type_list<T,
std::index_sequence<B...>,
std::index_sequence<Ix...>> :
Expand All @@ -226,8 +230,8 @@ struct loophole_type_list<T,
};

template <class T>
using aggregate_types_t = typename Loophole::loophole_type_list<
std::remove_cvref_t<T>>::type;
using aggregate_types_t =
typename loophole_type_list<std::remove_cvref_t<T>>::type;
}

template <class T>
Expand Down
5 changes: 2 additions & 3 deletions src/base/style/paramregistry.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,8 @@ template <typename Root> class ParamRegistry
using FromString = void(Root &, const std::string &);
using ToString = std::string(const Root &);
template <class T>
requires(Type::isoptional<
std::remove_cvref_t<std::invoke_result_t<T &&,
Root &>>>::value)
requires(Type::is_optional_v<std::remove_cvref_t<
std::invoke_result_t<T &&, Root &>>>)
constexpr
__attribute__((always_inline)) explicit Accessor(T &&t) :
toString(
Expand Down
2 changes: 1 addition & 1 deletion src/base/text/smartstring.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <string>
#include <vector>

#include "base/text/numberscale.h"
#include "numberscale.h"

namespace Text
{
Expand Down
25 changes: 19 additions & 6 deletions src/base/type/traits.h
Original file line number Diff line number Diff line change
@@ -1,22 +1,35 @@
#ifndef TYPE_TRAITS
#define TYPE_TRAITS

#include <istream>
#include <functional>
#include <optional>
#include <ostream>
#include <string>
#include <type_traits>

namespace Type
{

template <typename T, typename Enable = void>
struct isoptional : std::false_type
template <typename, typename = void>
struct is_optional : std::false_type
{};

template <typename T>
struct isoptional<std::optional<T>> : std::true_type
struct is_optional<std::optional<T>> : std::true_type
{};

template <typename T> concept is_optional_v = is_optional<T>::value;

template <typename, typename = void>
struct is_reference_wrapper : std::false_type
{};

template <typename T>
struct is_reference_wrapper<std::reference_wrapper<T>> :
std::true_type
{};

template <typename T>
concept is_reference_wrapper_v = is_reference_wrapper<T>::value;

}

#endif
2 changes: 1 addition & 1 deletion src/chart/animator/styles.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ template <typename T, typename = void> class StyleMorph;

template <class T>
class StyleMorph<T,
std::void_t<std::enable_if_t<Type::isoptional<T>::value>,
std::void_t<std::enable_if_t<Type::is_optional_v<T>>,
decltype(interpolate(*std::declval<const T &>(),
*std::declval<const T &>(),
double{}))>> : public ::Anim::IElement
Expand Down
5 changes: 1 addition & 4 deletions src/chart/generator/marker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ Marker::Marker(const Options &options,
const Data::SeriesList &mainAxisList,
const Data::SeriesList &subAxisList,
const Data::MultiIndex &index,
MarkerPosition pos,
bool needMarkerInfo) :
enabled(true),
cellInfo(enabled || needMarkerInfo
Expand All @@ -36,10 +35,8 @@ Marker::Marker(const Options &options,
.at(ChannelId::size)
.dimensionsWithLevel(),
index)),
idx(index.oldAggr),
pos(pos)
idx(index.marker_id)
{
prevMainMarker.values[0].value.idx = ~MarkerIndex{};
const auto &channels = options.getChannels();
auto color = getValueForChannel(channels,
ChannelId::color,
Expand Down
5 changes: 2 additions & 3 deletions src/chart/generator/marker.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ class Marker
const Data::SeriesList &mainAxisList,
const Data::SeriesList &subAxisList,
const Data::MultiIndex &index,
MarkerPosition pos,
bool needMarkerInfo);

::Anim::Interpolated<ColorBase> colorBase;
Expand Down Expand Up @@ -62,12 +61,12 @@ class Marker
Id sizeId;

MarkerIndex idx;
MarkerPosition pos;
MarkerPosition pos{};

struct MarkerIndexPosition
{
MarkerIndex idx;
MarkerPosition pos;
MarkerPosition pos{};

friend bool operator==(const MarkerIndexPosition &lhs,
const MarkerIndexPosition &rhs)
Expand Down
4 changes: 2 additions & 2 deletions src/chart/generator/plot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ void Plot::mergeMarkersAndCellInfo(Plot &source, Plot &target)
auto &smarker = smarkers[ix];
if (auto &[idx, prePos] =
smarker.prevMainMarker.values[0].value;
idx != ~Marker::MarkerIndex{}) {
!idx.empty()) {
if (prePos < source_reindex.size()
&& source_reindex[prePos].idx == idx)
prePos = source_reindex[prePos].pos;
Expand All @@ -187,7 +187,7 @@ void Plot::mergeMarkersAndCellInfo(Plot &source, Plot &target)
auto &tmarker = tmarkers[ix];
if (auto &[idx, prePos] =
tmarker.prevMainMarker.values[0].value;
idx != ~Marker::MarkerIndex{}) {
!idx.empty()) {
if (prePos < target_reindex.size()
&& target_reindex[prePos].idx == idx)
prePos = target_reindex[prePos].pos;
Expand Down
Loading

0 comments on commit bff9def

Please sign in to comment.