Skip to content

Commit bbbc523

Browse files
committed
review_1
1 parent c71aaf3 commit bbbc523

File tree

4 files changed

+29
-23
lines changed

4 files changed

+29
-23
lines changed

src/apps/weblib/typeschema-api/config.yaml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ definitions:
7878
- { type: string, enum: [auto] }
7979

8080
AxisChannel:
81+
$extends: Channel
8182
description: |
8283
AxisChannels are special channel settings for the positional channels.
8384
type: object
@@ -135,18 +136,14 @@ definitions:
135136
type: object
136137
properties:
137138
x:
138-
allOf:
139-
- $ref: Channel
140-
- $ref: AxisChannel
139+
$ref: AxisChannel
141140
description: |
142141
Parameters for the X-axis, determining the position of the markers on the
143142
x-axis - or their angle when using polar coordinates.
144143
Note: leaving x and y channels empty will result in a
145144
chart "without coordinates" like a Treemap or a Bubble Chart.
146145
y:
147-
allOf:
148-
- $ref: Channel
149-
- $ref: AxisChannel
146+
$ref: AxisChannel
150147
description: |
151148
Parameters for the Y-axis, determining the position of the markers on the
152149
y-axis - or their radius when using polar coordinates) .

src/chart/options/channels.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ bool Channels::anyAxisSet() const
1717

1818
bool Channels::isEmpty() const
1919
{
20-
return std::ranges::all_of(*this,
20+
return std::ranges::all_of(genProps,
2121
[](const auto &channel)
2222
{
2323
return channel.isEmpty();
@@ -28,7 +28,7 @@ Channels::IndexSet Channels::getDimensions() const
2828
{
2929
IndexSet dimensions;
3030

31-
for (const auto &channel : *this)
31+
for (const auto &channel : genProps)
3232
channel.collectDimensions(dimensions);
3333

3434
return dimensions;
@@ -38,7 +38,7 @@ Channels::IndexSet Channels::getMeasures() const
3838
{
3939
IndexSet series;
4040

41-
for (const auto &channel : *this)
41+
for (const auto &channel : genProps)
4242
if (auto &&mid = channel.measure()) series.insert(*mid);
4343

4444
return series;
@@ -57,12 +57,12 @@ Channels::IndexSet Channels::getDimensions(
5757

5858
void Channels::removeSeries(const Data::SeriesIndex &index)
5959
{
60-
for (auto &channel : *this) channel.removeSeries(index);
60+
for (auto &channel : genProps) channel.removeSeries(index);
6161
}
6262

6363
bool Channels::isSeriesUsed(const Data::SeriesIndex &index) const
6464
{
65-
return std::ranges::any_of(*this,
65+
return std::ranges::any_of(genProps,
6666
[&](const auto &channel)
6767
{
6868
return channel.isSeriesUsed(index);
@@ -71,23 +71,23 @@ bool Channels::isSeriesUsed(const Data::SeriesIndex &index) const
7171

7272
void Channels::reset()
7373
{
74-
for (auto &channel : *this) channel.reset();
74+
for (auto &channel : genProps) channel.reset();
7575
}
7676

7777
Channels Channels::shadow() const
7878
{
79-
Channels shadow = *this;
79+
Channels shadow{*this};
8080

81-
shadow[ChannelId::color].reset();
82-
shadow[ChannelId::lightness].reset();
83-
shadow[ChannelId::label].reset();
84-
shadow[ChannelId::noop].reset();
81+
shadow.genProps[ChannelId::color].reset();
82+
shadow.genProps[ChannelId::lightness].reset();
83+
shadow.genProps[ChannelId::label].reset();
84+
shadow.genProps[ChannelId::noop].reset();
8585

8686
for (auto &&attr : getDimensions({{ChannelId::color,
8787
ChannelId::lightness,
8888
ChannelId::label,
8989
ChannelId::noop}}))
90-
shadow[ChannelId::noop].addSeries(attr);
90+
shadow.genProps[ChannelId::noop].addSeries(attr);
9191

9292
return shadow;
9393
}

src/chart/options/channels.h

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@
1212
namespace Vizzu::Gen
1313
{
1414

15-
struct Channels : Refl::EnumArray<ChannelId, Channel>
15+
struct Channels
1616
{
1717
using IndexSet = std::set<Data::SeriesIndex>;
18-
EnumArray<AxisId, AxisChannelProperties> axisProps;
18+
Refl::EnumArray<ChannelId, Channel> genProps;
19+
Refl::EnumArray<AxisId, AxisChannelProperties> axisProps;
1920

2021
[[nodiscard]] bool anyAxisSet() const;
2122
[[nodiscard]] bool isEmpty() const;
@@ -25,7 +26,15 @@ struct Channels : Refl::EnumArray<ChannelId, Channel>
2526
[[nodiscard]] IndexSet getDimensions(
2627
const std::span<const ChannelId> &channelTypes) const;
2728

28-
using EnumArray::at;
29+
[[nodiscard]] constexpr Channel &at(ChannelId value)
30+
{
31+
return genProps.at(value);
32+
}
33+
34+
[[nodiscard]] constexpr const Channel &at(ChannelId value) const
35+
{
36+
return genProps.at(value);
37+
}
2938

3039
template <ChannelIdLike T>
3140
[[nodiscard]] const Channel &at(const T &id) const

src/chart/options/options.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,8 @@ class Options : public OptionProperties
185185
{{Channel::makeChannel(
186186
static_cast<ChannelId>(Ix))...}},
187187
{}};
188-
}(std::make_index_sequence<
189-
std::tuple_size_v<decltype(channels)::base_array>>{})};
188+
}(std::make_index_sequence<std::size(
189+
Refl::enum_values<ChannelId>())>())};
190190

191191
[[nodiscard]] Geom::Orientation getAutoOrientation() const;
192192
[[nodiscard]] std::optional<LegendId> getAutoLegend() const;

0 commit comments

Comments
 (0)