Skip to content

Commit a84c801

Browse files
committed
mainAxis strech means percent too
1 parent 45f1d44 commit a84c801

File tree

3 files changed

+32
-22
lines changed

3 files changed

+32
-22
lines changed

src/chart/generator/plotbuilder.cpp

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -463,17 +463,28 @@ void PlotBuilder::calcLegendAndLabel(const Data::DataTable &dataTable)
463463
.at(ChannelId::label)
464464
.measure()) {
465465

466+
auto mainAxisType = plot->getOptions()->mainAxisType();
466467
auto subAxisType = plot->getOptions()->subAxisType();
467468
auto markerLabelsUnitPercent =
468469
plot->getStyle().plot.marker.label.unit
469470
== Styles::MarkerLabel::Unit::percent
470-
&& plot->getOptions()
471-
->getChannels()
472-
.axisPropsAt(subAxisType)
473-
.align
474-
== Base::Align::Type::stretch
475-
&& plot->getOptions()->labelSeries(subAxisType) == *meas
476-
&& !plot->getOptions()->isSplit(subAxisType);
471+
&& ((plot->getOptions()
472+
->getChannels()
473+
.axisPropsAt(mainAxisType)
474+
.align
475+
== Base::Align::Type::stretch
476+
&& plot->getOptions()->labelSeries(mainAxisType)
477+
== *meas
478+
&& !plot->getOptions()->isSplit(mainAxisType))
479+
|| (plot->getOptions()
480+
->getChannels()
481+
.axisPropsAt(subAxisType)
482+
.align
483+
== Base::Align::Type::stretch
484+
&& plot->getOptions()->labelSeries(subAxisType)
485+
== *meas
486+
&& !plot->getOptions()->isSplit(subAxisType)));
487+
477488
plot->axises.label = {
478489
::Anim::String{std::string{
479490
markerLabelsUnitPercent
@@ -501,8 +512,7 @@ void PlotBuilder::calcAxis(const Data::DataTable &dataTable,
501512
const auto &meas = *scale.measure();
502513
if (isAutoTitle) axis.title = dataCube.getName(meas);
503514

504-
if (type == plot->getOptions()->subAxisType()
505-
&& axisProps.align == Base::Align::Type::stretch)
515+
if (axisProps.align == Base::Align::Type::stretch)
506516
axis.measure = {{0, 100},
507517
meas.getColIndex(),
508518
"%",
@@ -568,20 +578,13 @@ void PlotBuilder::addAlignment(const Buckets &buckets,
568578
axisRange.max - halfSize};
569579
}
570580

571-
auto subAxisType = plot->getOptions()->subAxisType();
572-
573-
auto &&subAxisLabel =
574-
plot->getOptions()->labelSeries(subAxisType);
581+
auto &&axisLabel = plot->getOptions()->labelSeries(axisIndex);
575582
auto markerLabelsUnitPercent =
576583
plot->getStyle().plot.marker.label.unit
577584
== Styles::MarkerLabel::Unit::percent
578-
&& plot->getOptions()
579-
->getChannels()
580-
.axisPropsAt(subAxisType)
581-
.align
582-
== Base::Align::Type::stretch
583-
&& subAxisLabel.has_value()
584-
&& subAxisLabel
585+
&& axisProps.align == Base::Align::Type::stretch
586+
&& axisLabel.has_value()
587+
&& axisLabel
585588
== plot->getOptions()
586589
->getChannels()
587590
.at(ChannelId::label)

test/e2e/tests/style_tests.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1022,7 +1022,7 @@
10221022
"refs": ["b326287"]
10231023
},
10241024
"plot/markerLabelUnit": {
1025-
"refs": ["ae0f5f5"]
1025+
"refs": ["3a02ec4"]
10261026
}
10271027
}
10281028
}

test/e2e/tests/style_tests/plot/markerLabelUnit.mjs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,19 @@ const testSteps = [
9696
color: ['Foo3'],
9797
label: ['Bar2']
9898
}
99-
}),
99+
}, 0),
100100
(chart) =>
101101
chart.animate({
102102
style: {
103103
'plot.marker.label.unit': 'percent'
104104
}
105+
}),
106+
(chart) =>
107+
chart.animate({
108+
config: {
109+
y: { labelLevel: 0 },
110+
orientation: 'vertical'
111+
}
105112
})
106113
]
107114

0 commit comments

Comments
 (0)