Skip to content

Commit 82978e4

Browse files
authored
Merge pull request #85 from vizzuhq/simon-0.4.7
Simon 0.4.7
2 parents 881021a + 84a7a32 commit 82978e4

File tree

6 files changed

+57
-10
lines changed

6 files changed

+57
-10
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## [Unreleased]
44

5+
### Fixed
6+
7+
- Runtime problem fixed for stacked charts.
8+
59
## [0.4.6] - 2022-03-12
610

711
### Fixed

src/chart/generator/diagram.cpp

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ void Diagram::generateMarkers(const Data::DataCube &dataCube,
123123
mainBuckets[marker.mainId.seriesId][marker.mainId.itemId] = itemIndex;
124124
subBuckets[marker.subId.seriesId][marker.subId.itemId] = itemIndex;
125125
}
126+
clearEmptyBuckets(mainBuckets, true);
127+
clearEmptyBuckets(subBuckets, false);
126128
linkMarkers(mainBuckets, true);
127129
linkMarkers(subBuckets, false);
128130
}
@@ -140,7 +142,8 @@ void Diagram::generateMarkersInfo()
140142
}
141143
}
142144

143-
void Diagram::linkMarkers(const Buckets &buckets, bool main)
145+
std::vector<std::pair<uint64_t, double>>
146+
Diagram::sortedBuckets(const Buckets &buckets, bool main)
144147
{
145148
size_t maxBucketSize = 0;
146149
for (const auto &pair : buckets)
@@ -174,9 +177,38 @@ void Diagram::linkMarkers(const Buckets &buckets, bool main)
174177
}
175178
if (main && options->reverse.get())
176179
{
177-
std::reverse(sorted.begin(), sorted.end());
180+
std::reverse(sorted.begin(), sorted.end());
178181
}
179182

183+
return sorted;
184+
}
185+
186+
void Diagram::clearEmptyBuckets(const Buckets &buckets, bool main)
187+
{
188+
for (const auto &pair : buckets)
189+
{
190+
const auto &bucket = pair.second;
191+
192+
bool enabled = false;
193+
194+
for (const auto &id : bucket)
195+
{
196+
auto &marker = markers[id.second];
197+
enabled |= (bool)marker.enabled;
198+
}
199+
200+
if (!enabled) for (const auto &id : bucket)
201+
{
202+
auto &marker = markers[id.second];
203+
marker.resetSize((bool)options->horizontal.get() == !main);
204+
}
205+
}
206+
}
207+
208+
void Diagram::linkMarkers(const Buckets &buckets, bool main)
209+
{
210+
auto sorted = sortedBuckets(buckets, main);
211+
180212
for (const auto &pair : buckets)
181213
{
182214
const auto &bucket = pair.second;

src/chart/generator/diagram.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ class Diagram
103103
void normalizeSizes();
104104
void normalizeColors();
105105
void recalcStackedLineChart();
106+
std::vector<std::pair<uint64_t, double>>
107+
sortedBuckets(const Buckets &buckets, bool main);
108+
void clearEmptyBuckets(const Buckets &buckets, bool main);
106109
};
107110

108111
typedef std::shared_ptr<Diagram> DiagramPtr;

src/chart/generator/marker.cpp

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,13 @@ void Marker::setNextMarker(uint64_t itemId,
127127
}
128128
}
129129

130+
void Marker::resetSize(bool horizontal)
131+
{
132+
double Point::*coord = horizontal ? &Point::x : &Point::y;
133+
size.*coord = 0;
134+
position.*coord = 0;
135+
}
136+
130137
void Marker::setIdOffset(size_t offset)
131138
{
132139
if ((bool)prevMainMarkerIdx) (*prevMainMarkerIdx).value += offset;
@@ -193,21 +200,21 @@ double Marker::getValueForScale(const Scales &scales,
193200

194201
auto &stat = stats.scales[type];
195202

196-
if (continuous)
203+
if (scale.isPseudoDiscrete())
197204
{
198-
singlevalue = (double)data.valueAt(index, *continuous);
199-
200205
if (scale.stackable())
201-
value = (double)data.aggregateAt(index, sumBy, *continuous);
206+
value = 1.0;
202207
else
203-
value = singlevalue;
208+
value = (double)id.itemId;
204209
}
205210
else
206211
{
212+
singlevalue = (double)data.valueAt(index, *continuous);
213+
207214
if (scale.stackable())
208-
value = 1.0;
215+
value = (double)data.aggregateAt(index, sumBy, *continuous);
209216
else
210-
value = (double)id.itemId;
217+
value = singlevalue;
211218
}
212219

213220
if (enabled) {

src/chart/generator/marker.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ class Marker
8888

8989
void setNextMarker(uint64_t itemId, Marker *marker,
9090
bool horizontal, bool main);
91+
void resetSize(bool horizontal);
9192

9293
Geom::Rect toRectangle() const;
9394
void fromRectangle(const Geom::Rect &rect);

src/chart/main/version.cpp

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

3-
const App::Version Vizzu::Main::version(0, 4, 6);
3+
const App::Version Vizzu::Main::version(0, 4, 7);
44

55
const char *Vizzu::Main::siteUrl = "https://lib.vizzuhq.com/";

0 commit comments

Comments
 (0)