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

Fix for 480 #484

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
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
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
- Dimension axis density on sorted values was wrongly calculated.
- Tooltip with 'seriesName' does not rewrite first series data.
- Handle as different category the empty string and the missing value.
- On chart resize, the font size is recalculated.
- On chart resize, the font size is recalculated.
- Fix invisible legend when there is no data on that channel.

### Added

Expand Down
2 changes: 1 addition & 1 deletion src/chart/options/channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
namespace Vizzu::Gen
{

enum class ChannelId { color, lightness, size, label, x, y, noop };
enum class ChannelId { color, lightness, size, noop, label, x, y };

class Channel
{
Expand Down
12 changes: 8 additions & 4 deletions src/chart/options/options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,13 @@ Options::MarkerInfoId Options::generateMarkerInfoId()

void Options::setAutoParameters()
{
if (auto &leg = *legend; leg.value.isAuto()) {
leg.weight = 1.0;
leg.value.setAuto(getAutoLegend());
if (auto &[val, weight] = *legend; val.isAuto()) {
weight = 1.0;
val.setAuto(getAutoLegend());
}
else if (weight > 0 && val && *val != ChannelId::noop
&& channels.at(toChannel(*val)).isEmpty()) {
legend = LegendType{};
}

if (auto &ori = *orientation; ori.value.isAuto()) {
Expand Down Expand Up @@ -323,7 +327,7 @@ bool Options::labelsShownFor(const Data::SeriesIndex &series) const
{
return channels.at(ChannelId::x).labelSeries() == series
|| channels.at(ChannelId::y).labelSeries() == series
|| (legend.get()
|| (legend.get() && *legend.get() != ChannelId::noop
&& channels.at(toChannel(*legend.get())).labelSeries()
== series);
}
Expand Down
5 changes: 3 additions & 2 deletions src/chart/options/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@ class Options
enum class LegendId : ChannelIdType {
color = static_cast<ChannelIdType>(ChannelId::color),
lightness = static_cast<ChannelIdType>(ChannelId::lightness),
size = static_cast<ChannelIdType>(ChannelId::size)
size = static_cast<ChannelIdType>(ChannelId::size),
noop = static_cast<ChannelIdType>(ChannelId::noop)
};

static_assert(Refl::enum_names<LegendId>.size() == 3);
static_assert(Refl::enum_names<LegendId>.size() == 4);
static_assert(std::ranges::all_of(Refl::enum_names<LegendId>,
[](std::string_view name)
{
Expand Down
2 changes: 1 addition & 1 deletion src/chart/rendering/drawchart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void DrawChart::drawLegend(Gfx::ICanvas &canvas,
[&legendObj, &canvas, &bounds](::Anim::InterpolateIndex,
const auto &legend)
{
if (legend.value)
if (legend.value && *legend.value != Gen::ChannelId::noop)
legendObj.draw(canvas,
bounds,
Gen::Options::toChannel(*legend.value),
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/test_cases/test_cases.json
Original file line number Diff line number Diff line change
Expand Up @@ -1943,7 +1943,7 @@
"refs": ["738524b"]
},
"ww_next_steps/next_steps_byOperations/remove/remove_05": {
"refs": ["d283ab6"]
"refs": ["a3ce0b4"]
},
"ww_next_steps/next_steps_byOperations/remove/remove_07": {
"refs": ["1f89123"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ const testSteps = [
size: null,
label: 'Year'
},
title: 'If Remove a Measure, then a Scatter plot is Better'
// legend: null
title: 'If Remove a Measure, then a Scatter plot is Better',
legend: 'noop'
}
}),
(chart) => {
Expand Down
3 changes: 3 additions & 0 deletions test/e2e/tests/fixes.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
"450": {
"refs": ["761380e"]
},
"480": {
"refs": ["4d27eb7"]
},
"32303048": {
"refs": ["b5d95ea"]
},
Expand Down
31 changes: 31 additions & 0 deletions test/e2e/tests/fixes/480.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
const testSteps = [
(chart) => {
const data = {
series: [
{ name: 'Foo', values: ['a', 'b', 'c', 'a', 'b', 'c'] },
{ name: 'Foo2', values: ['A', 'A', 'A', 'B', 'B', 'B'] },
{ name: 'Bar', values: [150000000, 32, 12, 3, 2, 10], unit: 'p' }
]
}
return chart.animate({ data })
},
(chart) =>
chart.animate({
config: {
size: 'count()',
label: 'count()',
noop: 'Foo2',
geometry: 'circle',
legend: 'color',
title: 'Pre title'
}
}),
(chart) =>
chart.animate({
config: {
legend: 'noop'
}
})
]

export default testSteps