@ixfx/components 0.4.1 → 0.4.3
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/bundle/index.d.ts +238 -119
- package/bundle/index.d.ts.map +1 -1
- package/bundle/index.js +423 -245
- package/bundle/index.js.map +1 -1
- package/dist/button.d.ts +1 -1
- package/dist/button.d.ts.map +1 -1
- package/dist/checkbox.d.ts.map +1 -1
- package/dist/checkbox.js.map +1 -1
- package/dist/crumbs.d.ts +1 -1
- package/dist/crumbs.d.ts.map +1 -1
- package/dist/crumbs.js +1 -1
- package/dist/crumbs.js.map +1 -1
- package/dist/data-display.js.map +1 -1
- package/dist/{icon-epZd-JIO.d.ts → icon-Bd5BiU4b.d.ts} +2 -2
- package/dist/{icon-epZd-JIO.d.ts.map → icon-Bd5BiU4b.d.ts.map} +1 -1
- package/dist/icons.d.ts +1 -1
- package/dist/incr-search.d.ts +1 -1
- package/dist/{index-BMjri2-S.d.ts → index-9fGVAg1d.d.ts} +2 -2
- package/dist/{index-BMjri2-S.d.ts.map → index-9fGVAg1d.d.ts.map} +1 -1
- package/dist/index-CowKi2mo.d.ts.map +1 -1
- package/dist/{index-CWpNcQKE.d.ts → index-_RTQSKHi.d.ts} +2 -2
- package/dist/{index-CWpNcQKE.d.ts.map → index-_RTQSKHi.d.ts.map} +1 -1
- package/dist/{index-JuEVfmr-.d.ts → index-s_IhSnwc.d.ts} +2 -2
- package/dist/{index-JuEVfmr-.d.ts.map → index-s_IhSnwc.d.ts.map} +1 -1
- package/dist/index.d.ts +13 -15
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/{labelled-input-base-Cz6qE6Dk.d.ts → labelled-input-base-ORb1rGq6.d.ts} +2 -2
- package/dist/{labelled-input-base-Cz6qE6Dk.d.ts.map → labelled-input-base-ORb1rGq6.d.ts.map} +1 -1
- package/dist/labelled-radial-input.d.ts +2 -2
- package/dist/labelled-radial-input.d.ts.map +1 -1
- package/dist/labelled-range-input.d.ts +1 -1
- package/dist/menu.d.ts +1 -1
- package/dist/miller.d.ts +1 -1
- package/dist/panel.d.ts.map +1 -1
- package/dist/panel.js.map +1 -1
- package/dist/plots.d.ts +1 -1
- package/dist/plots.js +1 -1
- package/dist/split-layout.js.map +1 -1
- package/dist/swipe.d.ts.map +1 -1
- package/dist/swipe.js.map +1 -1
- package/dist/timeline-2OFtN4Ta.js.map +1 -1
- package/dist/{tree-CJWpMUvD.js → tree-D84RUgFC.js} +2 -2
- package/dist/tree-D84RUgFC.js.map +1 -0
- package/dist/{tree-component-BcO26Xvt.d.ts → tree-component-BaCSPWg1.d.ts} +1 -6
- package/dist/tree-component-BaCSPWg1.d.ts.map +1 -0
- package/dist/tree.d.ts +1 -1
- package/dist/tree.d.ts.map +1 -1
- package/dist/tree.js +1 -1
- package/dist/{xy-axis-McdUpcYr.d.ts → xy-axis-BeWRMmbo.d.ts} +199 -73
- package/dist/xy-axis-BeWRMmbo.d.ts.map +1 -0
- package/dist/{xy-axis-CK64haaK.js → xy-axis-no0OL_O1.js} +254 -76
- package/dist/xy-axis-no0OL_O1.js.map +1 -0
- package/dist/xy-pad.d.ts.map +1 -1
- package/dist/xy-pad.js.map +1 -1
- package/package.json +2 -2
- package/dist/tree-CJWpMUvD.js.map +0 -1
- package/dist/tree-component-BcO26Xvt.d.ts.map +0 -1
- package/dist/xy-axis-CK64haaK.js.map +0 -1
- package/dist/xy-axis-McdUpcYr.d.ts.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as safeCustomElement, t as __decorate } from "./decorate-DdjvVHS-.js";
|
|
2
|
-
import { a as radiansNormalise, c as isEmpty$1, d as isPlaceholder, f as isPoint, i as piPi$1, l as isNaN
|
|
2
|
+
import { a as radiansNormalise, c as isEmpty$1, d as isPlaceholder, f as isPoint, i as piPi$1, l as isNaN, m as pointTest, n as average$1, o as guard$2, p as isPoint3d, r as averager, s as guardNonZeroPoint, t as colour_exports, u as isNull } from "./colour-C3MQIjFJ-vRCdr8W-.js";
|
|
3
3
|
import { C as resultThrow, S as percentTest, _ as functionTest, c as round, f as wrap, l as scale, o as quantiseEvery, r as dotProduct, s as rangeStream, t as clamp, v as integerTest, w as stringTest, x as numberTest } from "./dist-CA13FvMn.js";
|
|
4
4
|
import { LitElement, css, html, svg } from "lit";
|
|
5
5
|
import { property, state } from "lit/decorators.js";
|
|
@@ -5920,7 +5920,7 @@ var point_exports = /* @__PURE__ */ __exportAll$2({
|
|
|
5920
5920
|
invert: () => invert,
|
|
5921
5921
|
isEmpty: () => isEmpty$1,
|
|
5922
5922
|
isEqual: () => isEqual,
|
|
5923
|
-
isNaN: () => isNaN
|
|
5923
|
+
isNaN: () => isNaN,
|
|
5924
5924
|
isNull: () => isNull,
|
|
5925
5925
|
isPlaceholder: () => isPlaceholder,
|
|
5926
5926
|
isPoint: () => isPoint,
|
|
@@ -6559,42 +6559,107 @@ function applyAgeModification(base, ageFraction, ageStyle) {
|
|
|
6559
6559
|
}
|
|
6560
6560
|
//#endregion
|
|
6561
6561
|
//#region src/plots/data.ts
|
|
6562
|
+
/**
|
|
6563
|
+
* A data series
|
|
6564
|
+
*/
|
|
6562
6565
|
var PlotDataSeries = class {
|
|
6563
6566
|
#rangeStream;
|
|
6567
|
+
#rangeAuto;
|
|
6568
|
+
#rangeManual;
|
|
6564
6569
|
#options;
|
|
6570
|
+
/**
|
|
6571
|
+
* Constructor.
|
|
6572
|
+
*
|
|
6573
|
+
* Default options:
|
|
6574
|
+
* - `capacityLimit`: 100
|
|
6575
|
+
* - `persistentScaling`: true
|
|
6576
|
+
* - `fixedRange`: null
|
|
6577
|
+
* @param options
|
|
6578
|
+
*/
|
|
6565
6579
|
constructor(options = {}) {
|
|
6566
6580
|
this.values = [];
|
|
6567
6581
|
this.#rangeStream = rangeStream();
|
|
6568
|
-
this
|
|
6582
|
+
this.#rangeAuto = {
|
|
6569
6583
|
min: 0,
|
|
6570
6584
|
max: 0
|
|
6571
6585
|
};
|
|
6586
|
+
this.#rangeManual = null;
|
|
6572
6587
|
this.#options = {
|
|
6573
6588
|
capacityLimit: 100,
|
|
6574
6589
|
persistentScaling: true,
|
|
6590
|
+
fixedRange: null,
|
|
6575
6591
|
...options
|
|
6576
6592
|
};
|
|
6593
|
+
if (this.#options.fixedRange !== null) this.#rangeManual = this.#options.fixedRange;
|
|
6594
|
+
}
|
|
6595
|
+
/**
|
|
6596
|
+
* Sets a manual range, this disabled auto-scaling.
|
|
6597
|
+
* Use {@link unsetRange} to re-enable auto-scaling.
|
|
6598
|
+
* @param min
|
|
6599
|
+
* @param max
|
|
6600
|
+
*/
|
|
6601
|
+
setRange(min, max) {
|
|
6602
|
+
this.#rangeManual = {
|
|
6603
|
+
min,
|
|
6604
|
+
max
|
|
6605
|
+
};
|
|
6606
|
+
}
|
|
6607
|
+
/**
|
|
6608
|
+
* Disable the manual range
|
|
6609
|
+
*/
|
|
6610
|
+
unsetRange() {
|
|
6611
|
+
this.#rangeManual = null;
|
|
6612
|
+
this.#recompute();
|
|
6613
|
+
}
|
|
6614
|
+
get isAutoRange() {
|
|
6615
|
+
return this.#rangeManual === null;
|
|
6577
6616
|
}
|
|
6578
|
-
|
|
6579
|
-
|
|
6580
|
-
|
|
6617
|
+
/**
|
|
6618
|
+
* Adds a single value
|
|
6619
|
+
* @param valueOrValues Value to add
|
|
6620
|
+
*/
|
|
6621
|
+
add(valueOrValues) {
|
|
6622
|
+
if (typeof valueOrValues === `number`) {
|
|
6623
|
+
this.values.push(valueOrValues);
|
|
6624
|
+
if (this.isAutoRange) this.#rangeAuto = this.#rangeStream.seen(valueOrValues);
|
|
6625
|
+
} else {
|
|
6626
|
+
this.values.push(...valueOrValues);
|
|
6627
|
+
if (this.isAutoRange) for (const v of valueOrValues) this.#rangeAuto = this.#rangeStream.seen(v);
|
|
6628
|
+
}
|
|
6581
6629
|
if (this.values.length > this.#options.capacityLimit) {
|
|
6582
|
-
this.values.
|
|
6583
|
-
if (!this.#options.persistentScaling) this.#recompute();
|
|
6630
|
+
this.values = this.values.slice(this.values.length - this.#options.capacityLimit);
|
|
6631
|
+
if (!this.#options.persistentScaling && this.isAutoRange) this.#recompute();
|
|
6584
6632
|
}
|
|
6585
6633
|
}
|
|
6586
6634
|
#recompute() {
|
|
6587
6635
|
if (!this.#options.persistentScaling) this.#rangeStream = rangeStream();
|
|
6588
|
-
for (let i = 0; i < this.values.length; i++) this
|
|
6636
|
+
for (let i = 0; i < this.values.length; i++) this.#rangeAuto = this.#rangeStream.seen(this.values[i]);
|
|
6589
6637
|
}
|
|
6638
|
+
/**
|
|
6639
|
+
* Sets the entire data series at once, replacing any existing data. If the number of values exceeds the `capacityLimit`, only the most recent values up to the limit are kept.
|
|
6640
|
+
* @param values
|
|
6641
|
+
*/
|
|
6590
6642
|
set(values) {
|
|
6591
6643
|
if (values.length > this.#options.capacityLimit) values = values.slice(values.length - this.#options.capacityLimit);
|
|
6592
6644
|
this.values = values;
|
|
6593
6645
|
this.#recompute();
|
|
6594
6646
|
}
|
|
6647
|
+
/**
|
|
6648
|
+
* Returns the manual range if this is in effect, or the automatic
|
|
6649
|
+
*/
|
|
6650
|
+
get range() {
|
|
6651
|
+
if (this.#rangeManual) return this.#rangeManual;
|
|
6652
|
+
return this.#rangeAuto;
|
|
6653
|
+
}
|
|
6654
|
+
/**
|
|
6655
|
+
* Clear all data and reset range. If `persistentScaling` is _false_, also resets scaling to initial state.
|
|
6656
|
+
* @returns _true_ if there was data to clear
|
|
6657
|
+
*/
|
|
6595
6658
|
clear() {
|
|
6659
|
+
const empty = this.values.length === 0;
|
|
6596
6660
|
this.values = [];
|
|
6597
6661
|
if (!this.#options.persistentScaling) this.#recompute();
|
|
6662
|
+
return !empty;
|
|
6598
6663
|
}
|
|
6599
6664
|
};
|
|
6600
6665
|
//#endregion
|
|
@@ -6692,44 +6757,104 @@ let PlotMultiAxis = class PlotMultiAxis extends LitElement {
|
|
|
6692
6757
|
#seriesOrder;
|
|
6693
6758
|
#seriesSet;
|
|
6694
6759
|
#pendingStyles;
|
|
6695
|
-
|
|
6696
|
-
|
|
6697
|
-
|
|
6698
|
-
|
|
6699
|
-
|
|
6700
|
-
|
|
6760
|
+
/**
|
|
6761
|
+
* Adds a single data point
|
|
6762
|
+
* @param name Series name
|
|
6763
|
+
* @param value Value
|
|
6764
|
+
* @param witholdRedraw If _false_ (default) plot is automatically redrawn
|
|
6765
|
+
*/
|
|
6766
|
+
addData(name, value, witholdRedraw = false) {
|
|
6767
|
+
return this.#addToSeries(name, value, witholdRedraw);
|
|
6701
6768
|
}
|
|
6769
|
+
setData(name, values, witholdRedraw = false) {
|
|
6770
|
+
const [el, created] = this.#ensurePlot(name);
|
|
6771
|
+
if (!this.#seriesSet.has(name)) {
|
|
6772
|
+
this.#seriesSet.add(name);
|
|
6773
|
+
this.#seriesOrder.push(name);
|
|
6774
|
+
}
|
|
6775
|
+
el.set(values, witholdRedraw);
|
|
6776
|
+
if (created) this.requestUpdate();
|
|
6777
|
+
return el;
|
|
6778
|
+
}
|
|
6779
|
+
setObjects(data, witholdRedraw = false) {
|
|
6780
|
+
const entries = Object.entries(data);
|
|
6781
|
+
for (const [name, vals] of entries) this.setData(name, vals, true);
|
|
6782
|
+
if (witholdRedraw) return;
|
|
6783
|
+
this.redraw();
|
|
6784
|
+
}
|
|
6785
|
+
/**
|
|
6786
|
+
* Calls redraw() on all subplots.
|
|
6787
|
+
*/
|
|
6788
|
+
redraw() {
|
|
6789
|
+
for (const el of this.#instances.values()) el.redraw();
|
|
6790
|
+
}
|
|
6791
|
+
/**
|
|
6792
|
+
* Adds a record of data points to the plot. Each key in the record corresponds to a series name, and its value is added as a data point to that series. If a series does not exist for a given key, it will be created.
|
|
6793
|
+
* @param data Data to add
|
|
6794
|
+
* @param witholdRedraw If _false_ (default) plot is automatically redrawn after adding the data. If _true_, plot is not redrawn automatically, and you need to call `redraw()` manually to update the plot after adding the data.
|
|
6795
|
+
*/
|
|
6796
|
+
addObject(data, witholdRedraw = false) {
|
|
6797
|
+
const entries = Object.entries(data);
|
|
6798
|
+
for (const [name, val] of entries) this.#addToSeries(name, val, true);
|
|
6799
|
+
if (witholdRedraw) return;
|
|
6800
|
+
this.redraw();
|
|
6801
|
+
}
|
|
6802
|
+
/**
|
|
6803
|
+
* Styles a series by setting CSS variables on the subplot.
|
|
6804
|
+
* @param name Name of series
|
|
6805
|
+
* @param styles Styles to apply
|
|
6806
|
+
*/
|
|
6702
6807
|
styleSeries(name, styles) {
|
|
6703
|
-
const
|
|
6704
|
-
for (const [key, val] of Object.entries(styles))
|
|
6808
|
+
const normalised = {};
|
|
6809
|
+
for (const [key, val] of Object.entries(styles)) normalised[key.startsWith(`--`) ? key : `--${key}`] = val;
|
|
6705
6810
|
const el = this.#instances.get(name);
|
|
6706
6811
|
if (!el) {
|
|
6707
|
-
this.#pendingStyles.set(name,
|
|
6812
|
+
this.#pendingStyles.set(name, normalised);
|
|
6708
6813
|
return;
|
|
6709
6814
|
}
|
|
6710
|
-
for (const [key, val] of Object.entries(
|
|
6815
|
+
for (const [key, val] of Object.entries(normalised)) el.style.setProperty(key, val);
|
|
6711
6816
|
}
|
|
6817
|
+
/**
|
|
6818
|
+
* Clears data from all sub-plots
|
|
6819
|
+
* @returns _True_ if there was data to clear
|
|
6820
|
+
*/
|
|
6712
6821
|
clear() {
|
|
6713
|
-
|
|
6822
|
+
let cleared = false;
|
|
6823
|
+
for (const el of this.#instances.values()) cleared = cleared || el.clear();
|
|
6824
|
+
return cleared;
|
|
6714
6825
|
}
|
|
6826
|
+
/**
|
|
6827
|
+
* Clears data from a given series
|
|
6828
|
+
* @param name Series name
|
|
6829
|
+
* @returns _True_ if series was found and had data
|
|
6830
|
+
*/
|
|
6715
6831
|
clearSeries(name) {
|
|
6716
6832
|
const el = this.#instances.get(name);
|
|
6717
|
-
if (el)
|
|
6833
|
+
if (el) {
|
|
6834
|
+
el.clear();
|
|
6835
|
+
return true;
|
|
6836
|
+
}
|
|
6837
|
+
return false;
|
|
6718
6838
|
}
|
|
6839
|
+
/**
|
|
6840
|
+
* Returns a copy of the series names
|
|
6841
|
+
*/
|
|
6719
6842
|
get series() {
|
|
6720
6843
|
return [...this.#seriesOrder];
|
|
6721
6844
|
}
|
|
6722
|
-
#addToSeries(name,
|
|
6723
|
-
const el = this.#ensurePlot(name);
|
|
6845
|
+
#addToSeries(name, valueOrValues, withholdRedraw = false) {
|
|
6846
|
+
const [el, created] = this.#ensurePlot(name);
|
|
6724
6847
|
if (!this.#seriesSet.has(name)) {
|
|
6725
6848
|
this.#seriesSet.add(name);
|
|
6726
6849
|
this.#seriesOrder.push(name);
|
|
6727
6850
|
}
|
|
6728
|
-
el.add(
|
|
6851
|
+
el.add(valueOrValues, withholdRedraw);
|
|
6852
|
+
if (created) this.requestUpdate();
|
|
6853
|
+
return el;
|
|
6729
6854
|
}
|
|
6730
6855
|
#ensurePlot(name) {
|
|
6731
6856
|
let el = this.#instances.get(name);
|
|
6732
|
-
if (el) return el;
|
|
6857
|
+
if (el) return [el, false];
|
|
6733
6858
|
el = document.createElement(`ixfx-plot-single-axis`);
|
|
6734
6859
|
el.tooltips = false;
|
|
6735
6860
|
this.#instances.set(name, el);
|
|
@@ -6758,7 +6883,7 @@ let PlotMultiAxis = class PlotMultiAxis extends LitElement {
|
|
|
6758
6883
|
el.addEventListener(`plot-pointer-leave`, () => {
|
|
6759
6884
|
this.#onSubPlotPointerLeave();
|
|
6760
6885
|
});
|
|
6761
|
-
return el;
|
|
6886
|
+
return [el, true];
|
|
6762
6887
|
}
|
|
6763
6888
|
#onSubPlotPointerMove(clientX, clientY, index) {
|
|
6764
6889
|
if (index < 0) {
|
|
@@ -6793,7 +6918,7 @@ let PlotMultiAxis = class PlotMultiAxis extends LitElement {
|
|
|
6793
6918
|
part="container"
|
|
6794
6919
|
style=${gridStyle}
|
|
6795
6920
|
>
|
|
6796
|
-
${repeat(this.#seriesOrder, (name) => name, (name) => this.#ensurePlot(name))}
|
|
6921
|
+
${repeat(this.#seriesOrder, (name) => name, (name) => this.#ensurePlot(name)[0])}
|
|
6797
6922
|
</div>
|
|
6798
6923
|
`;
|
|
6799
6924
|
}
|
|
@@ -6859,10 +6984,10 @@ PlotMultiAxis = __decorate([safeCustomElement(`ixfx-plot-multi-axis`)], PlotMult
|
|
|
6859
6984
|
let PlotHistogram = class PlotHistogram extends LitElement {
|
|
6860
6985
|
constructor(..._args) {
|
|
6861
6986
|
super(..._args);
|
|
6862
|
-
this.orientation =
|
|
6987
|
+
this.orientation = `horizontal`;
|
|
6863
6988
|
this.resolution = .1;
|
|
6864
6989
|
this.capacity = 100;
|
|
6865
|
-
this.title =
|
|
6990
|
+
this.title = ``;
|
|
6866
6991
|
this.paused = false;
|
|
6867
6992
|
this._width = 100;
|
|
6868
6993
|
this._height = 40;
|
|
@@ -6876,7 +7001,7 @@ let PlotHistogram = class PlotHistogram extends LitElement {
|
|
|
6876
7001
|
#hasProgrammaticData;
|
|
6877
7002
|
#parseDeclarativeData(text) {
|
|
6878
7003
|
if (!text) return [];
|
|
6879
|
-
return text.trim().split(/[,\s;]+/).map((t) => Number.parseFloat(t)).filter((n) => !isNaN(n));
|
|
7004
|
+
return text.trim().split(/[,\s;]+/).map((t) => Number.parseFloat(t)).filter((n) => !Number.isNaN(n));
|
|
6880
7005
|
}
|
|
6881
7006
|
add(v) {
|
|
6882
7007
|
this.#hasProgrammaticData = true;
|
|
@@ -6903,12 +7028,12 @@ let PlotHistogram = class PlotHistogram extends LitElement {
|
|
|
6903
7028
|
this._height = e.contentRect.height;
|
|
6904
7029
|
}).observe(this);
|
|
6905
7030
|
if (!this.#hasProgrammaticData) {
|
|
6906
|
-
const data = this.#parseDeclarativeData(this.textContent ??
|
|
7031
|
+
const data = this.#parseDeclarativeData(this.textContent ?? ``);
|
|
6907
7032
|
if (data.length > 0) this.#series.set(data);
|
|
6908
7033
|
}
|
|
6909
7034
|
}
|
|
6910
7035
|
updated(changed) {
|
|
6911
|
-
if (changed.has(
|
|
7036
|
+
if (changed.has(`capacity`)) {
|
|
6912
7037
|
const old = [...this.#series.values];
|
|
6913
7038
|
this.#series = new PlotDataSeries({
|
|
6914
7039
|
capacityLimit: this.capacity,
|
|
@@ -6921,19 +7046,19 @@ let PlotHistogram = class PlotHistogram extends LitElement {
|
|
|
6921
7046
|
return getComputedStyle(this).getPropertyValue(name).trim();
|
|
6922
7047
|
}
|
|
6923
7048
|
#getGapPx() {
|
|
6924
|
-
const val = this.#readCssVar(
|
|
6925
|
-
if (val ===
|
|
6926
|
-
const parsed = parseFloat(val);
|
|
6927
|
-
return isFinite(parsed) ? Math.max(0, parsed) : 1;
|
|
7049
|
+
const val = this.#readCssVar(`--plot-histogram-gap`);
|
|
7050
|
+
if (val === ``) return 1;
|
|
7051
|
+
const parsed = Number.parseFloat(val);
|
|
7052
|
+
return Number.isFinite(parsed) ? Math.max(0, parsed) : 1;
|
|
6928
7053
|
}
|
|
6929
7054
|
#getBarLengthOverride() {
|
|
6930
|
-
const val = this.#readCssVar(
|
|
6931
|
-
if (val ===
|
|
6932
|
-
const parsed = parseFloat(val);
|
|
6933
|
-
return isFinite(parsed) ? Math.max(0, Math.min(1, parsed)) : null;
|
|
7055
|
+
const val = this.#readCssVar(`--plot-histogram-bar-length`);
|
|
7056
|
+
if (val === `` || val === `auto`) return null;
|
|
7057
|
+
const parsed = Number.parseFloat(val);
|
|
7058
|
+
return Number.isFinite(parsed) ? Math.max(0, Math.min(1, parsed)) : null;
|
|
6934
7059
|
}
|
|
6935
7060
|
#emitClick(i, valueMin, valueMax, relativeValue) {
|
|
6936
|
-
this.dispatchEvent(new CustomEvent(
|
|
7061
|
+
this.dispatchEvent(new CustomEvent(`plot-bucket-click`, {
|
|
6937
7062
|
detail: {
|
|
6938
7063
|
bucketIndex: i,
|
|
6939
7064
|
valueMin,
|
|
@@ -6948,7 +7073,7 @@ let PlotHistogram = class PlotHistogram extends LitElement {
|
|
|
6948
7073
|
const { values, range } = this.#series;
|
|
6949
7074
|
const w = this._width;
|
|
6950
7075
|
const h = this._height;
|
|
6951
|
-
const isHorizontal = this.orientation ===
|
|
7076
|
+
const isHorizontal = this.orientation === `horizontal`;
|
|
6952
7077
|
const padding = Math.min(4, (isHorizontal ? h : w) * .05);
|
|
6953
7078
|
const dataMin = this.min ?? range.min;
|
|
6954
7079
|
const dataSpan = (this.max ?? range.max) - dataMin || 1;
|
|
@@ -6958,7 +7083,7 @@ let PlotHistogram = class PlotHistogram extends LitElement {
|
|
|
6958
7083
|
const bucketSize = availableMain / bucketCount;
|
|
6959
7084
|
const gap = this.#getGapPx();
|
|
6960
7085
|
const barLengthOverride = this.#getBarLengthOverride();
|
|
6961
|
-
const buckets =
|
|
7086
|
+
const buckets = Array.from({ length: bucketCount }).fill(0);
|
|
6962
7087
|
for (const v of values) {
|
|
6963
7088
|
const normalized = (v - dataMin) / dataSpan;
|
|
6964
7089
|
const index = Math.min(bucketCount - 1, Math.max(0, Math.floor(normalized * bucketCount)));
|
|
@@ -6992,7 +7117,7 @@ let PlotHistogram = class PlotHistogram extends LitElement {
|
|
|
6992
7117
|
}
|
|
6993
7118
|
})}
|
|
6994
7119
|
${this.title ? svg`<text x=${padding + 2} y=${padding + Math.min(10, h * .6)}
|
|
6995
|
-
class="overlay-text" fill=${
|
|
7120
|
+
class="overlay-text" fill=${`var(--plot-text, var(--surface-2-text, #fff))`}
|
|
6996
7121
|
style="opacity: 0.6">${this.title}</text>` : svg``}
|
|
6997
7122
|
</svg>
|
|
6998
7123
|
`;
|
|
@@ -7033,7 +7158,7 @@ let PlotHistogram = class PlotHistogram extends LitElement {
|
|
|
7033
7158
|
`;
|
|
7034
7159
|
}
|
|
7035
7160
|
};
|
|
7036
|
-
__decorate([property({ attribute:
|
|
7161
|
+
__decorate([property({ attribute: `orientation` })], PlotHistogram.prototype, "orientation", void 0);
|
|
7037
7162
|
__decorate([property({ type: Number })], PlotHistogram.prototype, "resolution", void 0);
|
|
7038
7163
|
__decorate([property({ type: Number })], PlotHistogram.prototype, "min", void 0);
|
|
7039
7164
|
__decorate([property({ type: Number })], PlotHistogram.prototype, "max", void 0);
|
|
@@ -7045,7 +7170,7 @@ __decorate([property({
|
|
|
7045
7170
|
})], PlotHistogram.prototype, "paused", void 0);
|
|
7046
7171
|
__decorate([state()], PlotHistogram.prototype, "_width", void 0);
|
|
7047
7172
|
__decorate([state()], PlotHistogram.prototype, "_height", void 0);
|
|
7048
|
-
PlotHistogram = __decorate([safeCustomElement(
|
|
7173
|
+
PlotHistogram = __decorate([safeCustomElement(`ixfx-plot-histogram`)], PlotHistogram);
|
|
7049
7174
|
//#endregion
|
|
7050
7175
|
//#region src/plots/single-axis.ts
|
|
7051
7176
|
function buildLinePath(points) {
|
|
@@ -7144,6 +7269,8 @@ let PlotSingleAxis = class PlotSingleAxis extends LitElement {
|
|
|
7144
7269
|
this.precise = false;
|
|
7145
7270
|
this.tooltips = true;
|
|
7146
7271
|
this.capacity = 100;
|
|
7272
|
+
this.rangeMin = NaN;
|
|
7273
|
+
this.rangeMax = NaN;
|
|
7147
7274
|
this.persistentScale = true;
|
|
7148
7275
|
this.paused = false;
|
|
7149
7276
|
this.clickPauses = false;
|
|
@@ -7155,14 +7282,11 @@ let PlotSingleAxis = class PlotSingleAxis extends LitElement {
|
|
|
7155
7282
|
this.colorValueMap = null;
|
|
7156
7283
|
this._width = 100;
|
|
7157
7284
|
this._height = 40;
|
|
7158
|
-
this.#series = new PlotDataSeries(
|
|
7159
|
-
capacityLimit: 100,
|
|
7160
|
-
persistentScaling: true
|
|
7161
|
-
});
|
|
7285
|
+
this.#series = new PlotDataSeries();
|
|
7162
7286
|
this.#hasProgrammaticData = false;
|
|
7163
|
-
this.valueFormat = (v) => v ? v.toFixed(2) : ``;
|
|
7164
7287
|
this.#lastClientX = null;
|
|
7165
7288
|
this.#lastClientY = null;
|
|
7289
|
+
this.valueFormat = (v) => v ? v.toFixed(2) : ``;
|
|
7166
7290
|
this.#onPointerMove = (e) => {
|
|
7167
7291
|
this.#lastClientX = e.clientX;
|
|
7168
7292
|
this.#lastClientY = e.clientY;
|
|
@@ -7203,41 +7327,59 @@ let PlotSingleAxis = class PlotSingleAxis extends LitElement {
|
|
|
7203
7327
|
}
|
|
7204
7328
|
#series;
|
|
7205
7329
|
#hasProgrammaticData;
|
|
7330
|
+
#lastClientX;
|
|
7331
|
+
#lastClientY;
|
|
7206
7332
|
#parseDeclarativeData(text) {
|
|
7207
7333
|
if (!text) return [];
|
|
7208
|
-
return text.trim().split(/[,\s;]+/).map((t) => Number.parseFloat(t)).filter((n) => !isNaN(n));
|
|
7209
|
-
}
|
|
7210
|
-
get values() {
|
|
7211
|
-
return this.#series.values;
|
|
7212
|
-
}
|
|
7213
|
-
get dataCount() {
|
|
7214
|
-
return this.#series.values.length;
|
|
7215
|
-
}
|
|
7216
|
-
getValueAt(index) {
|
|
7217
|
-
return this.#series.values[index];
|
|
7218
|
-
}
|
|
7219
|
-
getIndexFromClientX(clientX) {
|
|
7220
|
-
return this.#getIndexFromX(clientX, this.getBoundingClientRect());
|
|
7334
|
+
return text.trim().split(/[,\s;]+/).map((t) => Number.parseFloat(t)).filter((n) => !Number.isNaN(n));
|
|
7221
7335
|
}
|
|
7222
|
-
|
|
7223
|
-
|
|
7224
|
-
|
|
7336
|
+
/**
|
|
7337
|
+
* Adds a value to the data series.
|
|
7338
|
+
*
|
|
7339
|
+
* Pass `withholdRedraw = true` to prevent automatic redraw after adding the value. In this case, call `redraw()` manually after adding all values to update the plot.
|
|
7340
|
+
*
|
|
7341
|
+
* Use {@link set} to replace the entire data series at once.
|
|
7342
|
+
* @param valueOrValues Single value, or several values
|
|
7343
|
+
* @param withholdRedraw If _false_ (default) plot is automatically redrawn
|
|
7344
|
+
*/
|
|
7345
|
+
add(valueOrValues, withholdRedraw = false) {
|
|
7225
7346
|
this.#hasProgrammaticData = true;
|
|
7226
|
-
this.#series.add(
|
|
7347
|
+
this.#series.add(valueOrValues);
|
|
7227
7348
|
if (this.paused) return;
|
|
7349
|
+
if (withholdRedraw) return;
|
|
7350
|
+
this.redraw();
|
|
7351
|
+
}
|
|
7352
|
+
/**
|
|
7353
|
+
* Redraws the plot.
|
|
7354
|
+
* Normally not needed, unless add() is called with withholdRedraw = true, or styleSeries() is used to update series styles.
|
|
7355
|
+
*/
|
|
7356
|
+
redraw() {
|
|
7228
7357
|
this.requestUpdate();
|
|
7229
7358
|
this.#updateTooltipAtLastPos();
|
|
7230
7359
|
}
|
|
7231
|
-
|
|
7360
|
+
/**
|
|
7361
|
+
* Sets the entire data for a series at once, replacing contents.
|
|
7362
|
+
*
|
|
7363
|
+
* Use add() to add values one by one.
|
|
7364
|
+
*
|
|
7365
|
+
* Pass `withholdRedraw = true` to prevent automatic redraw after setting the values. In this case, call `redraw()` manually after setting the values to update the plot.
|
|
7366
|
+
* @param values Values
|
|
7367
|
+
* @param withholdRedraw If _false_ (default) plot is automatically redrawn
|
|
7368
|
+
*/
|
|
7369
|
+
set(values, withholdRedraw = false) {
|
|
7232
7370
|
this.#hasProgrammaticData = true;
|
|
7233
7371
|
this.#series.set(values);
|
|
7234
7372
|
if (this.paused) return;
|
|
7235
|
-
|
|
7236
|
-
this
|
|
7373
|
+
if (withholdRedraw) return;
|
|
7374
|
+
this.redraw();
|
|
7237
7375
|
}
|
|
7376
|
+
/**
|
|
7377
|
+
* Clears all data and redraws
|
|
7378
|
+
*/
|
|
7238
7379
|
clear() {
|
|
7239
|
-
this.#series.clear();
|
|
7380
|
+
const result = this.#series.clear();
|
|
7240
7381
|
this.requestUpdate();
|
|
7382
|
+
return result;
|
|
7241
7383
|
}
|
|
7242
7384
|
firstUpdated(_changed) {
|
|
7243
7385
|
this._width = this.clientWidth || 100;
|
|
@@ -7253,11 +7395,16 @@ let PlotSingleAxis = class PlotSingleAxis extends LitElement {
|
|
|
7253
7395
|
}
|
|
7254
7396
|
}
|
|
7255
7397
|
updated(changed) {
|
|
7256
|
-
if (changed.has(`capacity`) || changed.has(`persistentScale`)) {
|
|
7398
|
+
if (changed.has(`capacity`) || changed.has(`persistentScale`) || changed.has(`rangeMin`) || changed.has(`rangeMax`)) {
|
|
7257
7399
|
const old = [...this.#series.values];
|
|
7400
|
+
const fixedRange = !Number.isNaN(this.rangeMin) && !Number.isNaN(this.rangeMax) ? {
|
|
7401
|
+
min: this.rangeMin,
|
|
7402
|
+
max: this.rangeMax
|
|
7403
|
+
} : null;
|
|
7258
7404
|
this.#series = new PlotDataSeries({
|
|
7259
7405
|
capacityLimit: this.capacity,
|
|
7260
|
-
persistentScaling: this.persistentScale
|
|
7406
|
+
persistentScaling: this.persistentScale,
|
|
7407
|
+
fixedRange
|
|
7261
7408
|
});
|
|
7262
7409
|
if (old.length > 0) this.#series.set(old);
|
|
7263
7410
|
}
|
|
@@ -7294,7 +7441,7 @@ let PlotSingleAxis = class PlotSingleAxis extends LitElement {
|
|
|
7294
7441
|
const widthPerPoint = n > 0 ? plotW / n : plotW;
|
|
7295
7442
|
const scaleX = (i) => padding + (i + .5) * widthPerPoint;
|
|
7296
7443
|
return values.map((value, index) => {
|
|
7297
|
-
const sv = scaleValue(value, min, max);
|
|
7444
|
+
const sv = clamp(scaleValue(value, min, max));
|
|
7298
7445
|
const ageFraction = n > 1 ? index / (n - 1) : 1;
|
|
7299
7446
|
return {
|
|
7300
7447
|
x: scaleX(index),
|
|
@@ -7306,6 +7453,35 @@ let PlotSingleAxis = class PlotSingleAxis extends LitElement {
|
|
|
7306
7453
|
};
|
|
7307
7454
|
});
|
|
7308
7455
|
}
|
|
7456
|
+
get series() {
|
|
7457
|
+
return this.#series;
|
|
7458
|
+
}
|
|
7459
|
+
/**
|
|
7460
|
+
* Get all values in the data series as a readonly array.
|
|
7461
|
+
*/
|
|
7462
|
+
get values() {
|
|
7463
|
+
return this.#series.values;
|
|
7464
|
+
}
|
|
7465
|
+
/**
|
|
7466
|
+
* Get length of data series
|
|
7467
|
+
*/
|
|
7468
|
+
get dataLength() {
|
|
7469
|
+
return this.#series.values.length;
|
|
7470
|
+
}
|
|
7471
|
+
/**
|
|
7472
|
+
* Get value at specific index of data series
|
|
7473
|
+
* @param index
|
|
7474
|
+
*/
|
|
7475
|
+
getValueAt(index) {
|
|
7476
|
+
return this.#series.values[index];
|
|
7477
|
+
}
|
|
7478
|
+
/**
|
|
7479
|
+
* Get value index based on client X position
|
|
7480
|
+
* @param clientX
|
|
7481
|
+
*/
|
|
7482
|
+
getIndexFromClientX(clientX) {
|
|
7483
|
+
return this.#getIndexFromX(clientX, this.getBoundingClientRect());
|
|
7484
|
+
}
|
|
7309
7485
|
#renderByStyle(points, crs, strokeW, radius, barW, bottom, top, mid) {
|
|
7310
7486
|
const lineCr = crs.at(-1) ?? {
|
|
7311
7487
|
fill: `currentColor`,
|
|
@@ -7416,6 +7592,8 @@ __decorate([property()], PlotSingleAxis.prototype, "title", void 0);
|
|
|
7416
7592
|
__decorate([property({ type: Boolean })], PlotSingleAxis.prototype, "precise", void 0);
|
|
7417
7593
|
__decorate([property({ type: Boolean })], PlotSingleAxis.prototype, "tooltips", void 0);
|
|
7418
7594
|
__decorate([property({ type: Number })], PlotSingleAxis.prototype, "capacity", void 0);
|
|
7595
|
+
__decorate([property({ type: Number })], PlotSingleAxis.prototype, "rangeMin", void 0);
|
|
7596
|
+
__decorate([property({ type: Number })], PlotSingleAxis.prototype, "rangeMax", void 0);
|
|
7419
7597
|
__decorate([property({
|
|
7420
7598
|
type: Boolean,
|
|
7421
7599
|
attribute: `persistent-scale`
|
|
@@ -7712,4 +7890,4 @@ PlotXyAxis = __decorate([safeCustomElement(`ixfx-plot-xy-axis`)], PlotXyAxis);
|
|
|
7712
7890
|
//#endregion
|
|
7713
7891
|
export { isEqualValueDefault as _, PlotDataSeries as a, parseColourScaleAttr as c, QueueMutable as d, isPrimitive as f, isEqualDefault as g, defaultComparer as h, PlotMultiAxis as i, readBaseColour as l, __exportAll$1 as m, PlotSingleAxis as n, applyAgeModification as o, toStringAbbreviate as p, PlotHistogram as r, computeColour as s, PlotXyAxis as t, last$2 as u, isEqualValueIgnoreOrder as v };
|
|
7714
7892
|
|
|
7715
|
-
//# sourceMappingURL=xy-axis-
|
|
7893
|
+
//# sourceMappingURL=xy-axis-no0OL_O1.js.map
|