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

Remove 'align: max' #585

Merged
merged 2 commits into from
Oct 2, 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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@
- Fix all polar connection interpolation (except fading).
- Remove unwanted line connections from line-circle + orientation changed anim.

### Changed

- Removed the 'align: max' property from the API. That function can be achieved
by setting the axis range to: {min: '100%', max: '0%'}.


## [0.13.0] - 2024-09-13

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion src/apps/weblib/typeschema-api/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ definitions:
on where the measure is. In case both axes have measures on them, this is determined
by the `orientation` of the chart.
type: string
enum: [none, min, center, max, stretch]
enum: [none, min, center, stretch]
split:
description: |
If set to true, markers will be split by the dimension(s) along the axis.
Expand Down
25 changes: 6 additions & 19 deletions src/chart/options/align.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,17 @@ namespace Vizzu::Base

struct Align : private Math::Range<double>
{
public:
enum class Type : std::uint8_t {
none,
min,
center,
max,
stretch
};

Align(Type type, const Range<double> &range) :
Range<double>(range),
type(type)
{}

[[nodiscard]] Range<double> getAligned(
const Range<double> &range) const
enum class Type : std::uint8_t { none, min, center, stretch };

Align(Type type, const Range &range) : Range(range), type(type) {}

[[nodiscard]] Range getAligned(const Range &range) const
{
switch (type) {
case Type::none: return range;
case Type::min: return range + min - range.getMin();
case Type::center: return range - range.middle() + middle();
case Type::max: return range + max - range.getMax();
case Type::stretch:
return static_cast<const Range<double> &>(*this);
case Type::stretch: return static_cast<const Range &>(*this);
}
throw std::logic_error("invalid align type");
}
Expand Down