Skip to content

Commit 302801d

Browse files
committed
main merge
2 parents a5b5681 + 22c390d commit 302801d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+4163
-2131
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,18 @@
22

33
## [Unreleased]
44

5+
### Added
6+
57
- animate() method returns an animation control object,
68
animation control methods are chainable.
79
- CSS properties can be used to style vizzu charts
810
E.g. `--vizzu-plot-marker-colorPalette: whatever` for `{style: {plot: {marker: {colorPalette: "whatever"}}}}`
911

12+
### Fixed
13+
14+
- Marker label fade-in/fade-out fixed, values are interpolated only if measure
15+
is not changed on label channel.
16+
1017
## [0.3.3] - 2021-10-17
1118

1219
### Fixed

ci/docker/vizzu-test-cloudbuild

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key
1515
ADD . /workspace/
1616
WORKDIR /workspace/test/integration
1717
RUN npm install
18-
RUN node vizzutest.js -r DISABLED -u /example/lib/vizzu.min.js
18+
RUN node test.js --vizzu /example/lib/vizzu.min.js --images DISABLED --hashes DISABLED --nologs

src/apps/weblib/js-api/vizzu.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,9 @@ export default class Vizzu {
225225
return this.anim;
226226
}
227227

228-
animStep(obj, animOptions) {
229-
if (obj) {
228+
animStep(animTarget, animOptions) {
229+
if (animTarget) {
230+
let obj = Object.assign({}, animTarget);
230231
if (obj.id) {
231232
this.restore(obj);
232233
} else {
@@ -243,7 +244,7 @@ export default class Vizzu {
243244
this._propPrefix
244245
);
245246
this.setStyle(propsToObject(props, style, this._propPrefix));
246-
this.setConfig(obj.config);
247+
this.setConfig(Object.assign({}, obj.config));
247248
}
248249
}
249250

@@ -270,6 +271,7 @@ export default class Vizzu {
270271
}
271272

272273
if (typeof animOptions === "object") {
274+
animOptions = Object.assign({}, animOptions);
273275
this.iterateObject(animOptions, (path, value) => {
274276
this.call(this.module._anim_setValue)(path, value);
275277
});

src/chart/generator/marker.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ void Marker::setSizeBy(bool horizontal, const Math::Range<double> range)
248248
Marker::Label::Label(const Data::MultiDim::SubSliceIndex &index,
249249
const Data::DataCube &data,
250250
const Data::DataTable &table)
251-
: hasValue(false), value(0.0)
251+
: value(0.0), continousId(-1)
252252
{
253253
indexStr = getIndexString(index, data, table);
254254
}
@@ -257,15 +257,16 @@ Marker::Label::Label(double value,
257257
const Data::SeriesIndex &continous,
258258
const Data::MultiDim::SubSliceIndex &index,
259259
const Data::DataCube &data,
260-
const Data::DataTable &table)
261-
: hasValue(true), value(value)
260+
const Data::DataTable &table) :
261+
value(value),
262+
continousId(continous.getColIndex())
262263
{
263-
unit = table.getInfo(continous.getColIndex()).getUnit();
264+
unit = table.getInfo(continousId).getUnit();
264265
indexStr = getIndexString(index, data, table);
265266
}
266267

267268
bool Marker::Label::operator==(const Marker::Label &other) const {
268-
return hasValue == other.hasValue
269+
return continousId == other.continousId
269270
&& value == other.value
270271
&& unit == other.unit
271272
&& indexStr == other.indexStr;

src/chart/generator/marker.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ class Marker
4444
CellInfo cellInfo;
4545

4646
struct Label {
47-
bool hasValue;
4847
double value;
48+
Data::ColumnIndex continousId;
4949
std::string unit;
5050
std::string indexStr;
51-
Label() : hasValue(false), value(0.0) {}
51+
Label() : value(0.0), continousId(-1) {}
5252
Label(const Data::MultiDim::SubSliceIndex &index,
5353
const Data::DataCube &data,
5454
const Data::DataTable &table);
@@ -57,6 +57,7 @@ class Marker
5757
const Data::DataCube &data,
5858
const Data::DataTable &table);
5959
bool operator==(const Label& other) const;
60+
bool hasValue() const { return continousId != (uint64_t)-1; }
6061
std::string getIndexString(const Data::MultiDim::SubSliceIndex &index,
6162
const Data::DataCube &data,
6263
const Data::DataTable &table) const;

src/chart/rendering/drawitem.cpp

Lines changed: 45 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -134,14 +134,15 @@ void drawItem::drawLabel()
134134
{
135135
if ((double)marker.enabled == 0) return;
136136

137-
BlendedDrawItem blended0(marker,
137+
BlendedDrawItem blended(marker,
138138
options,
139139
diagram.getStyle(),
140140
coordSys,
141141
diagram.getMarkers(),
142142
0);
143143

144-
drawLabel(blended0);
144+
drawLabel(blended, 0);
145+
drawLabel(blended, 1);
145146
}
146147

147148
bool drawItem::shouldDraw()
@@ -201,16 +202,16 @@ void drawItem::draw(
201202
}
202203
}
203204

204-
void drawItem::drawLabel(const DrawItem &drawItem)
205+
void drawItem::drawLabel(const DrawItem &drawItem, size_t index)
205206
{
206207
if ((double)drawItem.labelEnabled == 0) return;
207208

208-
auto color = getColor(drawItem, 1, true).second;
209-
210-
auto weight = marker.label.factor();
209+
auto weight = marker.label.values[index].weight;
211210
if (weight == 0.0) return;
212211

213-
auto text = getLabelText();
212+
auto color = getColor(drawItem, 1, true).second;
213+
214+
auto text = getLabelText(index);
214215
if (text.empty()) return;
215216

216217
auto &labelStyle = style.plot.marker.label;
@@ -231,52 +232,62 @@ void drawItem::drawLabel(const DrawItem &drawItem)
231232
centered, textColor, bgColor);
232233
}
233234

234-
std::string drawItem::getLabelText()
235+
std::string drawItem::getLabelText(size_t index) const
235236
{
236237
auto &labelStyle = style.plot.marker.label;
238+
auto &values = marker.label.values;
237239

238-
const auto &val0 = marker.label.values[0];
239-
const auto &val1 = marker.label.values[1];
240+
auto needsInterpolation = marker.label.count == 2
241+
&& (values[0].value.continousId
242+
== values[1].value.continousId);
240243

241-
auto value = marker.label.count == 1 ? val0.value.value :
242-
val0.value.value * val0.weight
243-
+ val1.value.value * val1.weight;
244+
auto value = needsInterpolation
245+
? marker.label.combine<double>(
246+
[&](const auto &value){ return value.value; })
247+
: values[index].value.value;
244248

245-
auto text = Text::SmartString::fromNumber(value,
246-
*labelStyle.numberFormat);
249+
std::string valueStr;
250+
if (values[index].value.hasValue())
251+
{
252+
valueStr = Text::SmartString::fromNumber(value,
253+
*labelStyle.numberFormat);
247254

248-
if (val0.value.hasValue
249-
&& !val0.value.unit.empty()
250-
&& *labelStyle.numberFormat != Text::NumberFormat::prefixed)
251-
text += " ";
255+
if(!values[index].value.unit.empty())
256+
{
257+
if (*labelStyle.numberFormat != Text::NumberFormat::prefixed)
258+
valueStr += " ";
259+
260+
valueStr += values[index].value.unit;
261+
}
262+
}
252263

253-
auto text0 = val0.value.hasValue ? text + val0.value.unit : std::string();
254-
auto idx0 = val0.value.indexStr;
264+
auto indexStr = values[index].value.indexStr;
255265

256266
// todo: interpolate Format
257267
typedef Styles::MarkerLabel::Format Format;
258268
switch((Format)*labelStyle.format)
259269
{
260270
default:
261-
case Format::measureFirst:
262-
if (!idx0.empty())
271+
case Format::measureFirst: {
272+
auto text = valueStr;
273+
if (!indexStr.empty())
263274
{
264-
if (!text0.empty()) text0 += ", ";
265-
text0 += idx0;
275+
if (!text.empty()) text += ", ";
276+
text += indexStr;
266277
}
267-
text = text0;
268-
break;
278+
return text;
279+
}
269280

270-
case Format::dimensionsFirst:
271-
if (!text0.empty())
281+
case Format::dimensionsFirst: {
282+
auto text = indexStr;
283+
if (!valueStr.empty())
272284
{
273-
if (!idx0.empty()) idx0 += ", ";
274-
idx0 += text0;
285+
if (!text.empty()) text += ", ";
286+
text += valueStr;
275287
}
276-
text = idx0;
277-
break;
288+
return text;
289+
}
278290
}
279-
return text;
280291
}
281292

282293
std::pair<Gfx::Color, Gfx::Color> drawItem::getColor(

src/chart/rendering/drawitem.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ class drawItem : private DrawingContext
3333
void draw(const DrawItem &drawItem,
3434
double factor,
3535
bool line);
36-
void drawLabel(const DrawItem &drawItem);
36+
void drawLabel(const DrawItem &drawItem, size_t index);
3737

3838
Gfx::Color getSelectedColor();
39-
std::string getLabelText();
39+
std::string getLabelText(size_t index) const;
4040
};
4141

4242
}

test/integration/man.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
const yargs = require("yargs");
2+
3+
const Manual = require("./modules/manual/manual.js");
4+
5+
6+
try {
7+
var argv = yargs
8+
.usage("Usage: [options]")
9+
10+
.help("h")
11+
.alias("h", "help")
12+
.version(false)
13+
14+
.alias("p", "port")
15+
.describe("p", "Change workspace host's port")
16+
.nargs("p", 1)
17+
.default("p", "8080")
18+
19+
.array("c")
20+
.alias("c", "configs")
21+
.nargs("c", 1)
22+
.describe("c",
23+
"Change the list of config file's path of the test cases" +
24+
"\n(relative or absolute path where the repo folder is the root)" +
25+
"\n")
26+
.default("c",
27+
["/test/integration/test_cases/test_cases.json"])
28+
.argv;
29+
30+
let manual = new Manual(argv.configs, argv.port);
31+
manual.run();
32+
} catch (err) {
33+
process.exitCode = 1;
34+
console.error(err);
35+
}

test/integration/manual/manual.js

Lines changed: 0 additions & 107 deletions
This file was deleted.

0 commit comments

Comments
 (0)