cx 24.10.6 → 24.10.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/charts.js +22 -7
- package/dist/manifest.js +691 -691
- package/dist/ui.js +44 -7
- package/package.json +1 -1
- package/src/charts/axis/TimeAxis.js +15 -6
- package/src/charts/helpers/PointReducer.js +5 -1
- package/src/ui/Instance.js +614 -610
- package/src/ui/layout/ContentPlaceholder.d.ts +19 -18
- package/src/ui/layout/ContentPlaceholder.js +105 -80
- package/src/ui/layout/ContentPlaceholder.spec.js +579 -368
package/dist/ui.js
CHANGED
|
@@ -1786,6 +1786,10 @@ var Instance = /*#__PURE__*/ (function () {
|
|
|
1786
1786
|
else {
|
|
1787
1787
|
this.renderList = this.renderList.insertLeft();
|
|
1788
1788
|
context.pushNamedValue("content", this.widget.putInto, this);
|
|
1789
|
+
if (!context.contentList) context.contentList = {};
|
|
1790
|
+
var list = context.contentList[this.widget.putInto];
|
|
1791
|
+
if (!list) list = context.contentList[this.widget.putInto] = [];
|
|
1792
|
+
list.push(this);
|
|
1789
1793
|
}
|
|
1790
1794
|
}
|
|
1791
1795
|
this.shouldUpdate = false;
|
|
@@ -3892,12 +3896,23 @@ var ContentPlaceholder = /*#__PURE__*/ (function (_PureContainer) {
|
|
|
3892
3896
|
var _this = this;
|
|
3893
3897
|
instance.content = null;
|
|
3894
3898
|
var data = instance.data;
|
|
3895
|
-
|
|
3896
|
-
|
|
3897
|
-
|
|
3899
|
+
if (this.allowMultiple) {
|
|
3900
|
+
var contentList = context.contentList && context.contentList[data.name];
|
|
3901
|
+
if (isNonEmptyArray(contentList) && !this.scoped)
|
|
3902
|
+
for (var i = 0; i < contentList.length; i++) this.setContent(context, instance, contentList[i]);
|
|
3903
|
+
|
|
3904
|
+
// in multi mode register a callback to allow for more entries to be added
|
|
3898
3905
|
context.pushNamedValue("contentPlaceholder", data.name, function (content) {
|
|
3899
3906
|
_this.setContent(context, instance, content);
|
|
3900
3907
|
});
|
|
3908
|
+
} else {
|
|
3909
|
+
var content = context.content && context.content[data.name];
|
|
3910
|
+
if (content && !this.scoped) this.setContent(context, instance, content);
|
|
3911
|
+
else
|
|
3912
|
+
context.pushNamedValue("contentPlaceholder", data.name, function (content) {
|
|
3913
|
+
_this.setContent(context, instance, content);
|
|
3914
|
+
});
|
|
3915
|
+
}
|
|
3901
3916
|
if (this.scoped)
|
|
3902
3917
|
instance.unregisterContentPlaceholder = function () {
|
|
3903
3918
|
context.popNamedValue("contentPlaceholder", data.name);
|
|
@@ -3906,21 +3921,41 @@ var ContentPlaceholder = /*#__PURE__*/ (function (_PureContainer) {
|
|
|
3906
3921
|
};
|
|
3907
3922
|
_proto.prepare = function prepare(context, instance) {
|
|
3908
3923
|
var content = instance.content;
|
|
3909
|
-
if (
|
|
3924
|
+
if (this.allowMultiple) {
|
|
3925
|
+
var contentId = "";
|
|
3926
|
+
var shouldUpdate = false;
|
|
3927
|
+
if (content) {
|
|
3928
|
+
for (var i = 0; i < content.length; i++) {
|
|
3929
|
+
var c = content[i];
|
|
3930
|
+
contentId += c.id + "+";
|
|
3931
|
+
shouldUpdate = shouldUpdate || c.shouldUpdate;
|
|
3932
|
+
}
|
|
3933
|
+
}
|
|
3934
|
+
if (instance.cache("content", contentId) || shouldUpdate) instance.markShouldUpdate(context);
|
|
3935
|
+
} else if (instance.cache("content", content) || (content && content.shouldUpdate))
|
|
3936
|
+
instance.markShouldUpdate(context);
|
|
3910
3937
|
};
|
|
3911
3938
|
_proto.setContent = function setContent(context, instance, content) {
|
|
3912
|
-
|
|
3939
|
+
if (this.allowMultiple) {
|
|
3940
|
+
if (instance.content == null) instance.content = [];
|
|
3941
|
+
instance.content.push(content);
|
|
3942
|
+
} else instance.content = content;
|
|
3913
3943
|
content.contentPlaceholder = instance;
|
|
3914
3944
|
};
|
|
3915
3945
|
_proto.render = function render(context, instance, key) {
|
|
3916
3946
|
var content = instance.content;
|
|
3917
|
-
if (content) return
|
|
3918
|
-
|
|
3947
|
+
if (!content) return _PureContainer.prototype.render.call(this, context, instance, key);
|
|
3948
|
+
if (this.allowMultiple)
|
|
3949
|
+
return content.map(function (x) {
|
|
3950
|
+
return x.contentVDOM;
|
|
3951
|
+
});
|
|
3952
|
+
return content.contentVDOM;
|
|
3919
3953
|
};
|
|
3920
3954
|
return ContentPlaceholder;
|
|
3921
3955
|
})(PureContainer);
|
|
3922
3956
|
ContentPlaceholder.prototype.name = "body";
|
|
3923
3957
|
ContentPlaceholder.prototype.scoped = false;
|
|
3958
|
+
ContentPlaceholder.prototype.allowMultiple = false;
|
|
3924
3959
|
Widget.alias("content-placeholder", ContentPlaceholder);
|
|
3925
3960
|
var ContentPlaceholderScope = /*#__PURE__*/ (function (_PureContainer2) {
|
|
3926
3961
|
function ContentPlaceholderScope() {
|
|
@@ -3936,6 +3971,7 @@ var ContentPlaceholderScope = /*#__PURE__*/ (function (_PureContainer2) {
|
|
|
3936
3971
|
this.name.forEach(function (name) {
|
|
3937
3972
|
context.pushNamedValue("contentPlaceholder", name, null);
|
|
3938
3973
|
context.pushNamedValue("content", name, null);
|
|
3974
|
+
context.pushNamedValue("contentList", name, []);
|
|
3939
3975
|
});
|
|
3940
3976
|
_PureContainer2.prototype.explore.call(this, context, instance);
|
|
3941
3977
|
};
|
|
@@ -3943,6 +3979,7 @@ var ContentPlaceholderScope = /*#__PURE__*/ (function (_PureContainer2) {
|
|
|
3943
3979
|
this.name.forEach(function (name) {
|
|
3944
3980
|
context.popNamedValue("contentPlaceholder", name);
|
|
3945
3981
|
context.popNamedValue("content", name);
|
|
3982
|
+
context.popNamedValue("contentList", name);
|
|
3946
3983
|
});
|
|
3947
3984
|
};
|
|
3948
3985
|
return ContentPlaceholderScope;
|
package/package.json
CHANGED
|
@@ -320,7 +320,7 @@ class TimeScale {
|
|
|
320
320
|
return date.getTimezoneOffset() * 60 * 1000;
|
|
321
321
|
}
|
|
322
322
|
|
|
323
|
-
getScale(tickSize, measure) {
|
|
323
|
+
getScale(tickSize, measure, minRange = 1000) {
|
|
324
324
|
let { min, max, upperDeadZone, lowerDeadZone } = this;
|
|
325
325
|
|
|
326
326
|
let smin = min;
|
|
@@ -368,6 +368,12 @@ class TimeScale {
|
|
|
368
368
|
if (this.maxValue == max) smax = this.maxValuePadded;
|
|
369
369
|
}
|
|
370
370
|
|
|
371
|
+
if (smax - smin < minRange) {
|
|
372
|
+
let delta = (minRange - (smax - smin)) / 2;
|
|
373
|
+
smin -= delta;
|
|
374
|
+
smax += delta;
|
|
375
|
+
}
|
|
376
|
+
|
|
371
377
|
//padding should be activated only if using min/max obtained from the data
|
|
372
378
|
let minPadding = this.minValue === min ? Math.max(0, smin - this.minValuePadded) : 0;
|
|
373
379
|
let maxPadding = this.maxValue === max ? Math.max(0, this.maxValuePadded - smax) : 0;
|
|
@@ -420,7 +426,7 @@ class TimeScale {
|
|
|
420
426
|
}
|
|
421
427
|
|
|
422
428
|
findTickSize(minPxDist) {
|
|
423
|
-
return this.tickSizes.find(({ size }) => size * Math.abs(this.scale.factor) >= minPxDist);
|
|
429
|
+
return this.tickSizes.find(({ size, noLabels }) => !noLabels && size * Math.abs(this.scale.factor) >= minPxDist);
|
|
424
430
|
}
|
|
425
431
|
|
|
426
432
|
getTickSizes() {
|
|
@@ -430,6 +436,8 @@ class TimeScale {
|
|
|
430
436
|
calculateTicks() {
|
|
431
437
|
let minReached = false;
|
|
432
438
|
|
|
439
|
+
let minRange = 1000;
|
|
440
|
+
|
|
433
441
|
for (let unit in miliSeconds) {
|
|
434
442
|
if (!minReached) {
|
|
435
443
|
if (unit == this.minTickUnit) minReached = true;
|
|
@@ -458,7 +466,7 @@ class TimeScale {
|
|
|
458
466
|
for (let d = 0; d < divs.length; d++) {
|
|
459
467
|
//if (useSnapToTicks && d < Math.min(divs.length - 1, this.snapToTicks)) continue;
|
|
460
468
|
let tickSize = divs[d] * unitSize;
|
|
461
|
-
let scale = this.getScale(null, unit);
|
|
469
|
+
let scale = this.getScale(null, unit, tickSize);
|
|
462
470
|
let format = this.format ?? this.getFormat(unit, scale);
|
|
463
471
|
let minLabelDistance = this.minLabelDistanceFormatOverride[format] ?? this.minLabelDistance;
|
|
464
472
|
let labelDistance = tickSize * Math.abs(scale.factor);
|
|
@@ -468,6 +476,7 @@ class TimeScale {
|
|
|
468
476
|
bestLabelDistance = labelDistance;
|
|
469
477
|
bestFormat = format;
|
|
470
478
|
bestMinLabelDistance = minLabelDistance;
|
|
479
|
+
minRange = tickSize;
|
|
471
480
|
}
|
|
472
481
|
}
|
|
473
482
|
}
|
|
@@ -516,10 +525,10 @@ class TimeScale {
|
|
|
516
525
|
}
|
|
517
526
|
}
|
|
518
527
|
if (bestMinorTickSize != Infinity) {
|
|
519
|
-
this.tickSizes.unshift({ size: bestMinorTickSize, measure: lowerTickUnit });
|
|
528
|
+
this.tickSizes.unshift({ size: bestMinorTickSize, measure: lowerTickUnit, noLabels: true });
|
|
520
529
|
if (this.tickSizes.length > 1) {
|
|
521
530
|
let labelStep = this.tickSizes[1].size;
|
|
522
|
-
let lowerScale = this.getScale(null, lowerTickUnit);
|
|
531
|
+
let lowerScale = this.getScale(null, lowerTickUnit, minRange);
|
|
523
532
|
if (lowerScale.max - lowerScale.min >= labelStep) this.scale = lowerScale;
|
|
524
533
|
}
|
|
525
534
|
}
|
|
@@ -527,7 +536,7 @@ class TimeScale {
|
|
|
527
536
|
|
|
528
537
|
if (isNumber(this.snapToTicks) && this.snapToTicks >= 0) {
|
|
529
538
|
let tickSize = this.tickSizes[Math.min(this.tickSizes.length - 1, this.snapToTicks)];
|
|
530
|
-
this.scale = this.getScale(tickSize.size, tickSize.measure);
|
|
539
|
+
this.scale = this.getScale(tickSize.size, tickSize.measure, minRange);
|
|
531
540
|
}
|
|
532
541
|
}
|
|
533
542
|
|
|
@@ -13,8 +13,12 @@ export class PointReducer extends PureContainer {
|
|
|
13
13
|
if (this.onInitAccumulator) instance.invoke("onInitAccumulator", accumulator, instance);
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
+
let pointFilter = null;
|
|
17
|
+
if (this.onCreatePointFilter) pointFilter = instance.invoke("onCreatePointFilter", instance);
|
|
18
|
+
|
|
16
19
|
instance.pointReducer = (x, y, name, data, array, index) => {
|
|
17
|
-
|
|
20
|
+
if (!pointFilter || pointFilter(x, y, name, data, array, index))
|
|
21
|
+
onMap(accumulator, x, y, name, data, array, index);
|
|
18
22
|
if (parentPointReducer) parentPointReducer(x, y, name, data, array, index);
|
|
19
23
|
};
|
|
20
24
|
instance.write = () => {
|