Skip to content

Commit

Permalink
Merge pull request #585 from vizzuhq/remove-align_max
Browse files Browse the repository at this point in the history
Remove 'align: max'
  • Loading branch information
schaumb authored Oct 2, 2024
2 parents a91de27 + 4500980 commit 6c27ac4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 20 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
- Remove unwanted line connections from line-circle + orientation changed anim.
- Move axis to the center on align: center charts.

### 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

0 comments on commit 6c27ac4

Please sign in to comment.