Skip to content

Commit 4ee6fb4

Browse files
authored
Merge pull request #566 from vizzuhq/dimfix
Fix dimension columns aggregation with non-existent values
2 parents 115668e + 846bf5d commit 4ee6fb4

File tree

16 files changed

+36
-28
lines changed

16 files changed

+36
-28
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
- Area charts with data series started with zero: tooltip fixed.
88
- Series whose contained ',' and aggregated were not working properly.
9+
- Dimension columns with non-existent values aggregation was undefined.
910

1011
## [0.12.0] - 2024-07-29
1112

src/apps/qutils/canvas.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
#include <QLinearGradient>
77
#include <QScreen>
88

9+
// NOLINTBEGIN(misc-include-cleaner,readability-avoid-nested-conditional-operator)
10+
911
QColor toQColor(const Gfx::Color &color)
1012
{
1113
return {color.getRedByte(),
@@ -276,4 +278,6 @@ QFont BaseCanvas::fromGfxFont(const Gfx::Font &newFont, QFont font)
276278
? QFont::StyleOblique
277279
: QFont::StyleNormal);
278280
return font;
279-
}
281+
}
282+
283+
// NOLINTEND(misc-include-cleaner,readability-avoid-nested-conditional-operator)

src/base/geom/circle.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
#include <cmath>
55
#include <numbers>
66
#include <optional>
7-
#include <stdexcept>
87

8+
#include "base/geom/point.h"
99
#include "base/math/floating.h"
1010
#include "base/math/tolerance.h"
1111

src/base/geom/quadrilateral.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
#include "quadrilateral.h"
22

3-
#include "base/math/tolerance.h"
3+
#include <algorithm>
4+
5+
#include "base/math/floating.h"
46

57
#include "point.h"
6-
#include "rect.h"
78
#include "triangle.h"
89

910
namespace Geom

src/base/gfx/pathsampler.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
#include "pathsampler.h"
22

3+
#include <cmath>
34
#include <cstddef>
45

56
#include "base/geom/point.h"
67
#include "base/geom/triangle.h"
8+
#include "base/math/floating.h"
79

810
namespace Gfx
911
{

src/chart/rendering/markers/abstractmarker.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
#include "abstractmarker.h"
22

3+
#include <array>
4+
#include <cstddef>
5+
#include <utility>
6+
37
#include "base/anim/interpolated.h"
48
#include "base/geom/line.h"
59
#include "chart/generator/marker.h"

src/chart/rendering/renderedchart.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
#include "renderedchart.h"
22

33
#include <algorithm>
4+
#include <limits>
45
#include <ranges>
56
#include <variant>
67

78
#include "base/geom/point.h"
89
#include "base/geom/transformedrect.h"
910
#include "base/math/floating.h"
10-
#include "base/math/fuzzybool.h"
1111
#include "base/util/eventdispatcher.h"
1212
#include "chart/generator/marker.h" // NOLINT(misc-include-cleaner)
1313
#include "chart/options/shapetype.h"

src/dataframe/impl/data_source.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -238,14 +238,11 @@ cell_reference data_source::get_data(std::size_t record_id,
238238
using enum series_type;
239239
case dimension: {
240240
const auto &dims = unsafe_get<dimension>(series).second;
241-
if (record_id >= dims.values.size()) return nullptr;
242241
return dims.get(record_id);
243242
}
244243
case measure: {
245244
const auto &meas = unsafe_get<measure>(series).second;
246-
if (record_id >= meas.values.size()) return nan;
247-
248-
return meas.values[record_id];
245+
return meas.get(record_id);
249246
}
250247
case unknown:
251248
default: error(error_type::series_not_found, column);
@@ -627,9 +624,9 @@ void data_source::dimension_t::add_more_data(
627624
const std::string *data_source::dimension_t::get(
628625
std::size_t index) const
629626
{
630-
return values[index] == nav
631-
? nullptr
632-
: std::addressof(categories[values[index]]);
627+
return index < values.size() && values[index] != nav
628+
? std::addressof(categories[values[index]])
629+
: nullptr;
633630
}
634631

635632
void data_source::dimension_t::set(std::size_t index,

src/dataframe/interface.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,6 @@ struct custom_aggregator
6363
return name <=> oth.name;
6464
}
6565

66-
auto operator!=(const custom_aggregator &oth) const
67-
{
68-
return name != oth.name;
69-
}
70-
7166
auto operator==(const custom_aggregator &oth) const
7267
{
7368
return name == oth.name;

src/dataframe/old/datatable.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,8 @@
1616
#include "base/conv/auto_json.h"
1717
#include "base/conv/numtostr.h"
1818
#include "base/refl/auto_enum.h"
19-
#include "base/text/funcstring.h"
2019
#include "chart/options/options.h"
2120
#include "chart/options/shapetype.h"
22-
#include "dataframe/impl/aggregators.h"
2321
#include "dataframe/impl/data_source.h"
2422
#include "dataframe/interface.h"
2523

0 commit comments

Comments
 (0)