From 81522038ecf42986bd75768853f8adf767c9c8a5 Mon Sep 17 00:00:00 2001 From: Bela Schaum Date: Wed, 22 May 2024 21:38:02 +0200 Subject: [PATCH 1/3] fix empty datacube calculation --- src/dataframe/old/datatable.cpp | 11 ++++++----- src/dataframe/old/datatable.h | 1 + 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/dataframe/old/datatable.cpp b/src/dataframe/old/datatable.cpp index 85852fddb..74011104c 100644 --- a/src/dataframe/old/datatable.cpp +++ b/src/dataframe/old/datatable.cpp @@ -120,7 +120,7 @@ SeriesIndex::SeriesIndex(std::string const &str, DataCube::iterator_t DataCube::begin() const { - if (df->get_record_count() == 0) return {}; + if (!has_element) return {}; iterator_t res{this, {}, {{}, std::vector(dim_reindex.size())}}; @@ -201,13 +201,14 @@ DataCube::DataCube(const DataTable &table, } df->finalize(); + has_element = true; for (std::size_t ix{}; const auto &dim : dimensions) { auto &&dimName = dim.getColIndex(); auto &&cats = table.getDf().get_categories(dimName); - dim_reindex.push_back(DimensionInfo{dimName, - cats, - cats.size() + df->has_na(dimName), - ix++}); + auto &&size = cats.size() + df->has_na(dimName); + dim_reindex.push_back( + DimensionInfo{dimName, cats, size, ix++}); + has_element &= size > 0; } auto stackInhibitingShape = diff --git a/src/dataframe/old/datatable.h b/src/dataframe/old/datatable.h index 89084ab2b..87c328e8f 100644 --- a/src/dataframe/old/datatable.h +++ b/src/dataframe/old/datatable.h @@ -84,6 +84,7 @@ class DataCube } }; Type::UniqueList dim_reindex; + bool has_element{}; std::map> From eceb8e5bed58a5bbe89e72de6c45eaadbf2c7337 Mon Sep 17 00:00:00 2001 From: Bela Schaum Date: Wed, 22 May 2024 22:03:38 +0200 Subject: [PATCH 2/3] Add testcase --- test/e2e/tests/fixes.json | 3 +++ test/e2e/tests/fixes/530.mjs | 45 ++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 test/e2e/tests/fixes/530.mjs diff --git a/test/e2e/tests/fixes.json b/test/e2e/tests/fixes.json index 0ad58453f..f0dd1c4d8 100644 --- a/test/e2e/tests/fixes.json +++ b/test/e2e/tests/fixes.json @@ -28,6 +28,9 @@ "450": { "refs": ["761380e"] }, + "530": { + "refs": ["1ad4684"] + }, "32303048": { "refs": ["b5d95ea"] }, diff --git a/test/e2e/tests/fixes/530.mjs b/test/e2e/tests/fixes/530.mjs new file mode 100644 index 000000000..0fa592595 --- /dev/null +++ b/test/e2e/tests/fixes/530.mjs @@ -0,0 +1,45 @@ +const testSteps = [ + (chart) => chart.animate({ + data: { + series: [ + { + name: 'Year', + type: 'dimension', + values: ['2005', 'Total'] + }, + { + name: 'Result', + type: 'dimension', + values: ['Won', 'Lost'] + } + ] + } + }), + (chart) => chart.animate({ + data: { + filter: (record) => { + return record.Year !== 'Total' + } + }, + config: { + x: 'Year' + } + }), + + (chart) => chart.animate( + { + data: { + filter: (record) => { + return ( + record.Year === 'Total' + ) + } + }, + config: { + y: 'Result' + } + } + ) +] + +export default testSteps From cead275f1a80eb0006a3b63b76dea08e50130b12 Mon Sep 17 00:00:00 2001 From: Bela Schaum Date: Wed, 22 May 2024 22:09:31 +0200 Subject: [PATCH 3/3] reformat --- test/e2e/tests/fixes/530.mjs | 79 ++++++++++++++++++------------------ 1 file changed, 39 insertions(+), 40 deletions(-) diff --git a/test/e2e/tests/fixes/530.mjs b/test/e2e/tests/fixes/530.mjs index 0fa592595..9bf7fc85a 100644 --- a/test/e2e/tests/fixes/530.mjs +++ b/test/e2e/tests/fixes/530.mjs @@ -1,45 +1,44 @@ const testSteps = [ - (chart) => chart.animate({ - data: { - series: [ - { - name: 'Year', - type: 'dimension', - values: ['2005', 'Total'] - }, - { - name: 'Result', - type: 'dimension', - values: ['Won', 'Lost'] - } - ] - } - }), - (chart) => chart.animate({ - data: { - filter: (record) => { - return record.Year !== 'Total' - } - }, - config: { - x: 'Year' - } - }), + (chart) => + chart.animate({ + data: { + series: [ + { + name: 'Year', + type: 'dimension', + values: ['2005', 'Total'] + }, + { + name: 'Result', + type: 'dimension', + values: ['Won', 'Lost'] + } + ] + } + }), + (chart) => + chart.animate({ + data: { + filter: (record) => { + return record.Year !== 'Total' + } + }, + config: { + x: 'Year' + } + }), - (chart) => chart.animate( - { - data: { - filter: (record) => { - return ( - record.Year === 'Total' - ) - } - }, - config: { - y: 'Result' - } - } - ) + (chart) => + chart.animate({ + data: { + filter: (record) => { + return record.Year === 'Total' + } + }, + config: { + y: 'Result' + } + }) ] export default testSteps