Skip to content

Commit

Permalink
constness + query only once the subIds at markergen.
Browse files Browse the repository at this point in the history
  • Loading branch information
schaumb committed Jul 11, 2024
1 parent 7b3f473 commit 824e5f1
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 29 deletions.
2 changes: 1 addition & 1 deletion src/apps/weblib/cinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ void data_addMeasure(APIHandles::Chart chart,
}

void data_addRecord(APIHandles::Chart chart,
const char **cells,
const char *const *cells,
std::uint32_t count)
{
return Interface::getInstance().addRecord(chart, cells, count);
Expand Down
2 changes: 1 addition & 1 deletion src/apps/weblib/cinterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ extern void data_addMeasure(APIHandles::Chart chart,
const double *values,
std::uint32_t count);
extern void data_addRecord(APIHandles::Chart chart,
const char **cells,
const char *const *cells,
std::uint32_t count);
const char *data_metaInfo(APIHandles::Chart chart);

Expand Down
2 changes: 1 addition & 1 deletion src/apps/weblib/interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ void Interface::addMeasure(ObjectRegistryHandle chart,
}

void Interface::addRecord(ObjectRegistryHandle chart,
const char **cells,
const char *const *cells,
std::uint32_t count)
{
getChart(chart)->getTable().pushRow({cells, count});
Expand Down
2 changes: 1 addition & 1 deletion src/apps/weblib/interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class Interface
const double *values,
std::uint32_t count);
void addRecord(ObjectRegistryHandle chart,
const char **cells,
const char *const *cells,
std::uint32_t count);
const char *dataMetaInfo(ObjectRegistryHandle chart);
void addEventListener(ObjectRegistryHandle chart,
Expand Down
24 changes: 9 additions & 15 deletions src/chart/generator/marker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ namespace Vizzu::Gen
Marker::Marker(const Options &options,
const Data::DataCube &data,
Axises &stats,
const Data::SeriesList &mainAxisList,
const Data::SeriesList &subAxisList,
const Data::MultiIndex &index,
MarkerPosition pos,
bool needMarkerInfo) :
Expand Down Expand Up @@ -49,21 +51,13 @@ Marker::Marker(const Options &options,
index,
&sizeId);

auto &&mainAxisDims = options.mainAxis().dimensionsWithLevel();

Data::MarkerId *subAxisId{};
if (auto &&subAxis = options.subAxis().dimensionsWithLevel();
options.geometry == ShapeType::area) {
Data::SeriesList subIds(subAxis.first);
if (subIds.split_by(mainAxisDims.first).empty())
subAxisId = &subId;
subId = data.getId({subIds, subAxis.second}, index);
}
else {
subId = data.getId(subAxis, index);
subAxisId = &subId;
}
mainId = data.getId(mainAxisDims, index);
subId = data.getId({subAxisList, options.subAxis().labelLevel},
index);
auto *subAxisId = subAxisList == options.subAxis().dimensions()
? &subId
: nullptr;
mainId = data.getId({mainAxisList, options.mainAxis().labelLevel},
index);

auto horizontal = options.isHorizontal();
auto lineOrCircle = options.geometry == ShapeType::line
Expand Down
2 changes: 2 additions & 0 deletions src/chart/generator/marker.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ class Marker
Marker(const Options &options,
const Data::DataCube &data,
Axises &stats,
const Data::SeriesList &mainAxisList,
const Data::SeriesList &subAxisList,
const Data::MultiIndex &index,
MarkerPosition pos,
bool needMarkerInfo);
Expand Down
17 changes: 9 additions & 8 deletions src/chart/generator/plotbuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,15 @@ Buckets PlotBuilder::generateMarkers(std::size_t &mainBucketSize)
{
Buckets mainBuckets;
Buckets subBuckets;
if (!dataCube.empty()) {
mainBuckets.resize(dataCube.combinedSizeOf(
plot->getOptions()->mainAxis().dimensions()));
mainBucketSize = mainBuckets.size();

Data::SeriesList subIds(
plot->getOptions()->subAxis().dimensions());
const auto &mainIds(plot->getOptions()->mainAxis().dimensions());
auto subIds(plot->getOptions()->subAxis().dimensions());
if (!dataCube.empty()) {
if (plot->getOptions()->geometry == ShapeType::area)
subIds.split_by(
plot->getOptions()->mainAxis().dimensions());
subIds.split_by(mainIds);

mainBuckets.resize(dataCube.combinedSizeOf(mainIds));
mainBucketSize = mainBuckets.size();
subBuckets.resize(dataCube.combinedSizeOf(subIds));

plot->markers.reserve(dataCube.combinedSizeOf({}).first);
Expand All @@ -94,6 +93,8 @@ Buckets PlotBuilder::generateMarkers(std::size_t &mainBucketSize)
auto &marker = plot->markers.emplace_back(*plot->getOptions(),
dataCube,
plot->axises,
mainIds,
subIds,
index,
plot->markers.size(),
needInfo);
Expand Down
2 changes: 1 addition & 1 deletion src/dataframe/old/datatable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ void DataTable::addColumn(std::string_view name,
{});
}

void DataTable::pushRow(const std::span<const char *> &cells)
void DataTable::pushRow(const std::span<const char *const> &cells)
{
df.add_record(cells);
}
Expand Down
2 changes: 1 addition & 1 deletion src/dataframe/old/datatable.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class DataTable
const std::span<const char *const> &categories,
const std::span<const std::uint32_t> &values);

void pushRow(const std::span<const char *> &cells);
void pushRow(const std::span<const char *const> &cells);

[[nodiscard]] std::string_view getUnit(
std::string_view const &colIx) const;
Expand Down

0 comments on commit 824e5f1

Please sign in to comment.