@ixfx/components 0.2.3 → 0.2.5

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.
Files changed (291) hide show
  1. package/LICENSE +1 -1
  2. package/bundle/chunk-pbuEa-1d.js +13 -0
  3. package/bundle/index.d.ts +4702 -569
  4. package/bundle/index.d.ts.map +1 -1
  5. package/bundle/index.js +34929 -2800
  6. package/bundle/index.js.map +1 -1
  7. package/bundle/style.css +133 -0
  8. package/dist/ac-text.d.ts +97 -0
  9. package/dist/ac-text.d.ts.map +1 -0
  10. package/dist/ac-text.js +484 -0
  11. package/dist/ac-text.js.map +1 -0
  12. package/dist/button-DgKUzE5o.js +121 -0
  13. package/dist/button-DgKUzE5o.js.map +1 -0
  14. package/dist/button.d.ts +21 -0
  15. package/dist/button.d.ts.map +1 -0
  16. package/dist/button.js +3 -0
  17. package/dist/checkbox.d.ts +34 -0
  18. package/dist/checkbox.d.ts.map +1 -0
  19. package/dist/checkbox.js +251 -0
  20. package/dist/checkbox.js.map +1 -0
  21. package/dist/chunk-pbuEa-1d.js +13 -0
  22. package/dist/colour-C3MQIjFJ-BJV-QC-3.js +4138 -0
  23. package/dist/colour-C3MQIjFJ-BJV-QC-3.js.map +1 -0
  24. package/dist/colour-picker-Bw-AZoWx.js +922 -0
  25. package/dist/colour-picker-Bw-AZoWx.js.map +1 -0
  26. package/dist/colour-picker.d.ts +2 -0
  27. package/dist/colour-picker.js +2 -0
  28. package/dist/crumbs.d.ts +92 -0
  29. package/dist/crumbs.d.ts.map +1 -0
  30. package/dist/crumbs.js +789 -0
  31. package/dist/crumbs.js.map +1 -0
  32. package/dist/data-display.d.ts +24 -12
  33. package/dist/data-display.d.ts.map +1 -1
  34. package/dist/data-display.js +96 -105
  35. package/dist/data-display.js.map +1 -1
  36. package/dist/decorate-BZbkqIhA.js +9 -0
  37. package/dist/defaults-FEZaGiYZ.js +38 -0
  38. package/dist/defaults-FEZaGiYZ.js.map +1 -0
  39. package/dist/dist-By5URG0Y.js +1290 -0
  40. package/dist/dist-By5URG0Y.js.map +1 -0
  41. package/dist/dist-D7kJgnSE.js +1039 -0
  42. package/dist/dist-D7kJgnSE.js.map +1 -0
  43. package/dist/editable-label.d.ts +71 -0
  44. package/dist/editable-label.d.ts.map +1 -0
  45. package/dist/editable-label.js +279 -0
  46. package/dist/editable-label.js.map +1 -0
  47. package/dist/hex-editor-Gib1Grg2.d.ts +131 -0
  48. package/dist/hex-editor-Gib1Grg2.d.ts.map +1 -0
  49. package/dist/hex-editor-Wd6ZtZA2.js +1147 -0
  50. package/dist/hex-editor-Wd6ZtZA2.js.map +1 -0
  51. package/dist/hex.d.ts +2 -0
  52. package/dist/hex.js +2 -0
  53. package/dist/highlight-CAjwQ4GE.js +50 -0
  54. package/dist/highlight-CAjwQ4GE.js.map +1 -0
  55. package/dist/icon-BR5aTIiP.js +100 -0
  56. package/dist/icon-BR5aTIiP.js.map +1 -0
  57. package/dist/icon-DQKdfR7U.d.ts +36 -0
  58. package/dist/icon-DQKdfR7U.d.ts.map +1 -0
  59. package/dist/icons.d.ts +3 -0
  60. package/dist/icons.js +9 -0
  61. package/dist/icons.js.map +1 -0
  62. package/dist/incr-search-BjCNClnC.js +311 -0
  63. package/dist/incr-search-BjCNClnC.js.map +1 -0
  64. package/dist/incr-search.d.ts +2 -0
  65. package/dist/incr-search.js +3 -0
  66. package/dist/index-B1hNR7Z9.d.ts +36 -0
  67. package/dist/index-B1hNR7Z9.d.ts.map +1 -0
  68. package/dist/index-C5dK8RZa.d.ts +23 -0
  69. package/dist/index-C5dK8RZa.d.ts.map +1 -0
  70. package/dist/index-C9iBN908.d.ts +160 -0
  71. package/dist/index-C9iBN908.d.ts.map +1 -0
  72. package/dist/index-CPVcTTXo.d.ts +396 -0
  73. package/dist/index-CPVcTTXo.d.ts.map +1 -0
  74. package/dist/index-CQxanqXF.d.ts +183 -0
  75. package/dist/index-CQxanqXF.d.ts.map +1 -0
  76. package/dist/index-CpbBI3n7.d.ts +1239 -0
  77. package/dist/index-CpbBI3n7.d.ts.map +1 -0
  78. package/dist/index.d.ts +422 -13
  79. package/dist/index.d.ts.map +1 -1
  80. package/dist/index.js +5729 -14
  81. package/dist/index.js.map +1 -1
  82. package/dist/interaction-CQDQJf2Q.js +1 -0
  83. package/dist/keyboard-De_vOHLg.js +20 -0
  84. package/dist/keyboard-De_vOHLg.js.map +1 -0
  85. package/dist/labelled-input-base-DS6-6C0r.js +155 -0
  86. package/dist/labelled-input-base-DS6-6C0r.js.map +1 -0
  87. package/dist/labelled-input-base-DnRh4reU.d.ts +43 -0
  88. package/dist/labelled-input-base-DnRh4reU.d.ts.map +1 -0
  89. package/dist/labelled-radial-input.d.ts +34 -0
  90. package/dist/labelled-radial-input.d.ts.map +1 -0
  91. package/dist/labelled-radial-input.js +188 -0
  92. package/dist/labelled-radial-input.js.map +1 -0
  93. package/dist/labelled-range-input.d.ts +2 -0
  94. package/dist/labelled-range-input.js +132 -0
  95. package/dist/labelled-range-input.js.map +1 -0
  96. package/dist/led.d.ts +25 -0
  97. package/dist/led.d.ts.map +1 -0
  98. package/dist/led.js +92 -0
  99. package/dist/led.js.map +1 -0
  100. package/dist/menu-BV6UFx_z.js +813 -0
  101. package/dist/menu-BV6UFx_z.js.map +1 -0
  102. package/dist/menu-item-Cikacp4F.d.ts +128 -0
  103. package/dist/menu-item-Cikacp4F.d.ts.map +1 -0
  104. package/dist/menu-item-DEzL_Yjk.js +766 -0
  105. package/dist/menu-item-DEzL_Yjk.js.map +1 -0
  106. package/dist/menu.d.ts +3 -0
  107. package/dist/menu.js +3 -0
  108. package/dist/miller.d.ts +324 -0
  109. package/dist/miller.d.ts.map +1 -0
  110. package/dist/miller.js +1343 -0
  111. package/dist/miller.js.map +1 -0
  112. package/dist/narrowed-text.d.ts +72 -0
  113. package/dist/narrowed-text.d.ts.map +1 -0
  114. package/dist/narrowed-text.js +571 -0
  115. package/dist/narrowed-text.js.map +1 -0
  116. package/dist/panel.d.ts +43 -0
  117. package/dist/panel.d.ts.map +1 -0
  118. package/dist/panel.js +408 -0
  119. package/dist/panel.js.map +1 -0
  120. package/dist/plots.d.ts +2 -0
  121. package/dist/plots.js +2 -0
  122. package/dist/polar-pad.d.ts +67 -0
  123. package/dist/polar-pad.d.ts.map +1 -0
  124. package/dist/polar-pad.js +537 -0
  125. package/dist/polar-pad.js.map +1 -0
  126. package/dist/popup-Ddx9LCzY.js +24 -0
  127. package/dist/popup-Ddx9LCzY.js.map +1 -0
  128. package/dist/prominence-CreDBdCs.js +98 -0
  129. package/dist/prominence-CreDBdCs.js.map +1 -0
  130. package/dist/radial-input-CNJ8asY2.js +849 -0
  131. package/dist/radial-input-CNJ8asY2.js.map +1 -0
  132. package/dist/radial-input-xSTd4kEz.d.ts +70 -0
  133. package/dist/radial-input-xSTd4kEz.d.ts.map +1 -0
  134. package/dist/radial-input.d.ts +2 -0
  135. package/dist/radial-input.js +2 -0
  136. package/dist/range-input.d.ts +43 -0
  137. package/dist/range-input.d.ts.map +1 -0
  138. package/dist/range-input.js +459 -0
  139. package/dist/range-input.js.map +1 -0
  140. package/dist/range.d.ts +28 -0
  141. package/dist/range.d.ts.map +1 -0
  142. package/dist/range.js +136 -0
  143. package/dist/range.js.map +1 -0
  144. package/dist/registry-CZEB1YI9.js +21 -0
  145. package/dist/registry-CZEB1YI9.js.map +1 -0
  146. package/dist/selecthorizontal.d.ts +13 -8
  147. package/dist/selecthorizontal.d.ts.map +1 -1
  148. package/dist/selecthorizontal.js +21 -25
  149. package/dist/selecthorizontal.js.map +1 -1
  150. package/dist/snap-container.d.ts +50 -0
  151. package/dist/snap-container.d.ts.map +1 -0
  152. package/dist/snap-container.js +297 -0
  153. package/dist/snap-container.js.map +1 -0
  154. package/dist/split-layout.d.ts +56 -0
  155. package/dist/split-layout.d.ts.map +1 -0
  156. package/dist/split-layout.js +545 -0
  157. package/dist/split-layout.js.map +1 -0
  158. package/dist/style.css +133 -0
  159. package/dist/swipe.d.ts +48 -0
  160. package/dist/swipe.d.ts.map +1 -0
  161. package/dist/swipe.js +204 -0
  162. package/dist/swipe.js.map +1 -0
  163. package/dist/tab-list-CFF7uSYH.d.ts +66 -0
  164. package/dist/tab-list-CFF7uSYH.d.ts.map +1 -0
  165. package/dist/tabs.d.ts +2 -0
  166. package/dist/tabs.js +203 -0
  167. package/dist/tabs.js.map +1 -0
  168. package/dist/tickled-controller-Cq1Va0rR.d.ts +218 -0
  169. package/dist/tickled-controller-Cq1Va0rR.d.ts.map +1 -0
  170. package/dist/tickled-styles-Bg3QbcrD.js +327 -0
  171. package/dist/tickled-styles-Bg3QbcrD.js.map +1 -0
  172. package/dist/timeline-DBWJsSjd.js +1748 -0
  173. package/dist/timeline-DBWJsSjd.js.map +1 -0
  174. package/dist/timeline.d.ts +2 -0
  175. package/dist/timeline.js +2 -0
  176. package/dist/tooltip-DMxmBNky.js +104 -0
  177. package/dist/tooltip-DMxmBNky.js.map +1 -0
  178. package/dist/tooltip-kfUBWYVB.d.ts +26 -0
  179. package/dist/tooltip-kfUBWYVB.d.ts.map +1 -0
  180. package/dist/tree-component-CQpoPo4s.d.ts +326 -0
  181. package/dist/tree-component-CQpoPo4s.d.ts.map +1 -0
  182. package/dist/tree-data-model-DGvRVOFY.js +190 -0
  183. package/dist/tree-data-model-DGvRVOFY.js.map +1 -0
  184. package/dist/tree.d.ts +100 -0
  185. package/dist/tree.d.ts.map +1 -0
  186. package/dist/tree.js +1144 -0
  187. package/dist/tree.js.map +1 -0
  188. package/dist/types-BKaqnpwx.d.ts +8 -0
  189. package/dist/types-BKaqnpwx.d.ts.map +1 -0
  190. package/dist/xy-axis-BANbgrI5.js +6243 -0
  191. package/dist/xy-axis-BANbgrI5.js.map +1 -0
  192. package/dist/xy-axis-CIFok7MF.d.ts +141 -0
  193. package/dist/xy-axis-CIFok7MF.d.ts.map +1 -0
  194. package/dist/xy-pad.d.ts +81 -0
  195. package/dist/xy-pad.d.ts.map +1 -0
  196. package/dist/xy-pad.js +435 -0
  197. package/dist/xy-pad.js.map +1 -0
  198. package/package.json +48 -39
  199. package/README.md +0 -14
  200. package/dist/charts/frequency-histogram-plot.d.ts +0 -33
  201. package/dist/charts/frequency-histogram-plot.d.ts.map +0 -1
  202. package/dist/charts/frequency-histogram-plot.js +0 -54
  203. package/dist/charts/frequency-histogram-plot.js.map +0 -1
  204. package/dist/charts/histogram-vis.d.ts +0 -57
  205. package/dist/charts/histogram-vis.d.ts.map +0 -1
  206. package/dist/charts/histogram-vis.js +0 -222
  207. package/dist/charts/histogram-vis.js.map +0 -1
  208. package/dist/charts/plot.d.ts +0 -199
  209. package/dist/charts/plot.d.ts.map +0 -1
  210. package/dist/charts/plot.js +0 -914
  211. package/dist/charts/plot.js.map +0 -1
  212. package/dist/crumb-nav.d.ts +0 -41
  213. package/dist/crumb-nav.d.ts.map +0 -1
  214. package/dist/crumb-nav.js +0 -198
  215. package/dist/crumb-nav.js.map +0 -1
  216. package/dist/crumb-navigation.d.ts +0 -30
  217. package/dist/crumb-navigation.d.ts.map +0 -1
  218. package/dist/crumb-navigation.js +0 -307
  219. package/dist/crumb-navigation.js.map +0 -1
  220. package/dist/dial.d.ts +0 -89
  221. package/dist/dial.d.ts.map +0 -1
  222. package/dist/dial.js +0 -506
  223. package/dist/dial.js.map +0 -1
  224. package/dist/my-element.d.ts +0 -14
  225. package/dist/my-element.d.ts.map +0 -1
  226. package/dist/my-element.js +0 -44
  227. package/dist/my-element.js.map +0 -1
  228. package/dist/split-layout/split-layout.d.ts +0 -35
  229. package/dist/split-layout/split-layout.d.ts.map +0 -1
  230. package/dist/split-layout/split-layout.js +0 -220
  231. package/dist/split-layout/split-layout.js.map +0 -1
  232. package/dist/svg-edit-label.d.ts +0 -2
  233. package/dist/svg-edit-label.d.ts.map +0 -1
  234. package/dist/svg-edit-label.js +0 -110
  235. package/dist/svg-edit-label.js.map +0 -1
  236. package/dist/tabs/tab-layout-item.d.ts +0 -10
  237. package/dist/tabs/tab-layout-item.d.ts.map +0 -1
  238. package/dist/tabs/tab-layout-item.js +0 -20
  239. package/dist/tabs/tab-layout-item.js.map +0 -1
  240. package/dist/tabs/tab-layout.d.ts +0 -10
  241. package/dist/tabs/tab-layout.d.ts.map +0 -1
  242. package/dist/tabs/tab-layout.js +0 -25
  243. package/dist/tabs/tab-layout.js.map +0 -1
  244. package/dist/tabs/tab-list-item.d.ts +0 -18
  245. package/dist/tabs/tab-list-item.d.ts.map +0 -1
  246. package/dist/tabs/tab-list-item.js +0 -63
  247. package/dist/tabs/tab-list-item.js.map +0 -1
  248. package/dist/tabs/tab-list.d.ts +0 -21
  249. package/dist/tabs/tab-list.d.ts.map +0 -1
  250. package/dist/tabs/tab-list.js +0 -148
  251. package/dist/tabs/tab-list.js.map +0 -1
  252. package/dist/tabs/tab-panel.d.ts +0 -11
  253. package/dist/tabs/tab-panel.d.ts.map +0 -1
  254. package/dist/tabs/tab-panel.js +0 -30
  255. package/dist/tabs/tab-panel.js.map +0 -1
  256. package/dist/tabs/tab-panels.d.ts +0 -30
  257. package/dist/tabs/tab-panels.d.ts.map +0 -1
  258. package/dist/tabs/tab-panels.js +0 -80
  259. package/dist/tabs/tab-panels.js.map +0 -1
  260. package/dist/util/circle-arc.d.ts +0 -34
  261. package/dist/util/circle-arc.d.ts.map +0 -1
  262. package/dist/util/circle-arc.js +0 -77
  263. package/dist/util/circle-arc.js.map +0 -1
  264. package/dist/util/compare.d.ts +0 -53
  265. package/dist/util/compare.d.ts.map +0 -1
  266. package/dist/util/compare.js +0 -91
  267. package/dist/util/compare.js.map +0 -1
  268. package/dist/util/content-editable.d.ts +0 -2
  269. package/dist/util/content-editable.d.ts.map +0 -1
  270. package/dist/util/content-editable.js +0 -13
  271. package/dist/util/content-editable.js.map +0 -1
  272. package/dist/util/drag-controller.d.ts +0 -13
  273. package/dist/util/drag-controller.d.ts.map +0 -1
  274. package/dist/util/drag-controller.js +0 -21
  275. package/dist/util/drag-controller.js.map +0 -1
  276. package/dist/util/key-value.d.ts +0 -5
  277. package/dist/util/key-value.d.ts.map +0 -1
  278. package/dist/util/key-value.js +0 -30
  279. package/dist/util/key-value.js.map +0 -1
  280. package/dist/util/primitive-types.d.ts +0 -6
  281. package/dist/util/primitive-types.d.ts.map +0 -1
  282. package/dist/util/primitive-types.js +0 -2
  283. package/dist/util/primitive-types.js.map +0 -1
  284. package/dist/util/svg-editable-text.d.ts +0 -22
  285. package/dist/util/svg-editable-text.d.ts.map +0 -1
  286. package/dist/util/svg-editable-text.js +0 -121
  287. package/dist/util/svg-editable-text.js.map +0 -1
  288. package/dist/util/time.d.ts +0 -2
  289. package/dist/util/time.d.ts.map +0 -1
  290. package/dist/util/time.js +0 -2
  291. package/dist/util/time.js.map +0 -1
@@ -1,914 +0,0 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- import { css, html, LitElement } from "lit";
8
- import { customElement, property } from "lit/decorators.js";
9
- import { createRef, ref } from "lit/directives/ref.js";
10
- import { CanvasHelper } from "ixfx/visual.js";
11
- import { Rects } from "ixfx/geometry.js";
12
- import * as Arrays from 'ixfx/arrays.js';
13
- import * as Numbers from 'ixfx/numbers.js';
14
- import { getCssVariable } from 'ixfx/dom.js';
15
- import { Drawing, Colour } from "ixfx/visual.js";
16
- import { Flow, Pathed } from 'ixfx';
17
- const rangeIsEqual = (a, b) => {
18
- if (a === undefined || b === undefined)
19
- return false;
20
- return (a.max === b.max && a.min === b.min);
21
- };
22
- export class PlotAxis {
23
- // units: Readonly<{ major: number, minor: number }> = { major: Number.NaN, minor: Number.NaN }
24
- // altAxisCrossing: AxisCrossing<T> = { at: `min` }
25
- // ticks: TickMarks = { major: `inside`, minor: `inside` }
26
- // labels: AxisLabels = `axis`;
27
- #currentScalerRange;
28
- #persistentScale;
29
- #currentScaler;
30
- constructor(name) {
31
- this.name = name;
32
- this.bounds = `auto`;
33
- this.#persistentScale = Numbers.rangeInit();
34
- this.#currentScaler = (v) => v;
35
- }
36
- humanFormatValue(value) {
37
- if (value.length === 0)
38
- return ``;
39
- const v = value[0];
40
- return v.toFixed(2);
41
- }
42
- getRange(series) {
43
- if (this.bounds === `auto`)
44
- return this.computeActualRange(series);
45
- if (this.bounds === `auto-persistent`) {
46
- const r = this.computeActualRange(series);
47
- this.#persistentScale = Numbers.rangeMergeRange(r, this.#persistentScale);
48
- return this.#persistentScale;
49
- }
50
- return this.bounds;
51
- }
52
- getCurrentRange() {
53
- return this.#currentScalerRange;
54
- }
55
- getValueScaler(series) {
56
- const r = this.getRange(series);
57
- if (!rangeIsEqual(r, this.#currentScalerRange)) {
58
- this.#currentScalerRange = r;
59
- this.#currentScaler = Numbers.scaler(r.min, r.max, 0, 1);
60
- }
61
- return this.#currentScaler;
62
- }
63
- computeActualRange(seriesOnAxis, column = 0) {
64
- let min = Number.MAX_SAFE_INTEGER;
65
- let max = Number.MIN_SAFE_INTEGER;
66
- let count = 0;
67
- for (const s of seriesOnAxis) {
68
- for (const [v, _index] of s.getValuesForColumn(column)) {
69
- if (typeof v !== `number`)
70
- continue;
71
- if (Number.isNaN(v))
72
- continue;
73
- if (v < min)
74
- min = v;
75
- if (v > max)
76
- max = v;
77
- }
78
- count++;
79
- }
80
- return { min, max };
81
- }
82
- }
83
- /**
84
- * Attributes
85
- * * streaming: true/false (default: true)
86
- * * max-length: number (default: 500). How many data points per series to store
87
- * * data-width: when streaming, how much horizontal width per point
88
- * * fixed-max/fixed-min: global input scaling (default: NaN, ie. disabled)
89
- *
90
- * * line-width: stroke width of drawing line (default:2)
91
- *
92
- * * render: 'dot', 'line' or 'bar'(default: 'dot')
93
- * * hide-legend: If added, legend is not shown
94
- * * manual-draw: If added, automatic drawning is disabled
95
- *
96
- * Styling variables
97
- * * --legend-fg: legend foreground text
98
- */
99
- let PlotElement = class PlotElement extends LitElement {
100
- constructor() {
101
- //@property({ attribute: `streaming`, type: Boolean })
102
- //streaming = true;
103
- super(...arguments);
104
- this.hideLegend = false;
105
- //@property({ attribute: `max-length`, type: Number })
106
- //maxLength = 500;
107
- //@property({ attribute: `data-width`, type: Number })
108
- //dataWidth = 5;
109
- //@property({ attribute: `fixed-max`, type: Number })
110
- //fixedMax = Number.NaN;
111
- //@property({ attribute: `fixed-min`, type: Number })
112
- //fixedMin = Number.NaN;
113
- //@property({ attribute: `line-width`, type: Number })
114
- //lineWidth = 2;
115
- this.renderStyle = `dot`;
116
- //@property({ attribute: `manual-draw`, type: Boolean })
117
- //manualDraw = false;
118
- this.padding = 5;
119
- this.primaryAxis = new PlotAxis(`primary`);
120
- this.secondaryAxis = new PlotAxis(`secondary`);
121
- this.paused = false;
122
- this.plotAreaFormat = {
123
- fill: { type: `none` },
124
- outline: { type: `none` }
125
- };
126
- /**
127
- * Settings used for automatically generating series colour
128
- */
129
- this.automaticSeriesColour = {
130
- saturation: 1,
131
- lightness: 0.5,
132
- alpha: 1
133
- };
134
- this.seriesDefault = {};
135
- this.#series = new Map();
136
- this.#legendColour = ``;
137
- this.#autoSeriesColour = 0;
138
- this.#hitboxes = [];
139
- this.#seriesFormatting = new Map();
140
- this.#swatchSize = 10;
141
- this.canvasEl = createRef();
142
- this.tooltipEl = createRef();
143
- this.#drawThrottled = Flow.throttle(() => this.#drawImpl(), 100);
144
- this.seriesColourGenerate = (_seriesName) => {
145
- const c = Colour.goldenAngleColour(this.#autoSeriesColour, this.automaticSeriesColour.saturation, this.automaticSeriesColour.lightness, this.automaticSeriesColour.alpha);
146
- this.#autoSeriesColour++;
147
- return c;
148
- };
149
- }
150
- #series;
151
- #canvas;
152
- #drawing;
153
- #legendColour;
154
- #autoSeriesColour;
155
- #hitboxes;
156
- #seriesFormatting;
157
- #swatchSize;
158
- #drawThrottled;
159
- setDrawDebounce(millis) {
160
- this.#drawThrottled = Flow.throttle(() => this.#drawImpl(), millis);
161
- }
162
- get series() {
163
- return [...this.#series.values()];
164
- }
165
- get seriesCount() {
166
- return this.#series.size;
167
- }
168
- getSeriesFormatting(seriesName, createIfNeeded) {
169
- let f = this.#seriesFormatting.get(seriesName);
170
- if (!f && createIfNeeded) {
171
- f = {
172
- axis: `primary`,
173
- fill: {
174
- colour: this.seriesColourGenerate(seriesName),
175
- type: `solid`
176
- },
177
- outline: {
178
- type: `none`
179
- },
180
- bar: {
181
- gapWidth: 3
182
- },
183
- dot: {
184
- gapWidth: 0,
185
- radius: `automatic`
186
- },
187
- line: {
188
- width: 2,
189
- cap: `round`,
190
- join: `round`
191
- }
192
- };
193
- this.#seriesFormatting.set(seriesName, f);
194
- }
195
- return f;
196
- }
197
- setSeriesFormatting(seriesName, formatting) {
198
- let existing = this.getSeriesFormatting(seriesName, true);
199
- const combined = {
200
- ...existing,
201
- ...formatting
202
- };
203
- combined.fill = resolveFillDrawStyle(combined.fill);
204
- combined.outline = resolveOutlineDrawStyle(combined.outline);
205
- this.#seriesFormatting.set(seriesName, combined);
206
- }
207
- /**
208
- * Returns a `PlotElement` instance based on a query
209
- * ```js
210
- * PlotElement.fromQuery(`#someplot`); // PlotElement
211
- * ```
212
- *
213
- * Throws an error if query does not match.
214
- * @param query
215
- * @returns
216
- */
217
- static fromQuery(query) {
218
- const el = document.querySelector(query);
219
- if (!el)
220
- throw new Error(`Query does not match an element`);
221
- if (el.nodeName === 'IXFX-PLOT-ELEMENT')
222
- return el;
223
- throw new Error(`Element is not a PlotElement ('${el.nodeName}')`);
224
- }
225
- /**
226
- * Delete a series.
227
- * Returns _true_ if there was a series to delete
228
- * @param name
229
- * @returns
230
- */
231
- deleteSeries(name) {
232
- name = name.toLowerCase();
233
- const s = this.#series.get(name);
234
- if (!s)
235
- return false;
236
- this.#series.delete(name);
237
- return true;
238
- }
239
- /**
240
- * Keeps the series, but deletes its data
241
- * @param name
242
- * @returns
243
- */
244
- clearSeries(name) {
245
- name = name.toLowerCase();
246
- const s = this.#series.get(name);
247
- if (!s)
248
- return false;
249
- this.#series.clear();
250
- return true;
251
- }
252
- /**
253
- * Delete all data & series
254
- */
255
- clear() {
256
- this.#series.clear();
257
- this.#autoSeriesColour = 0;
258
- }
259
- /**
260
- * Keeps all series, but deletes their data
261
- */
262
- clearData() {
263
- for (const s of this.#series.values()) {
264
- s.clear();
265
- }
266
- }
267
- #lastPointerPosition;
268
- #onPointerLeave() {
269
- this.#lastPointerPosition = undefined;
270
- this.#hideTooltip();
271
- }
272
- #onPointerMove(event) {
273
- this.#lastPointerPosition = {
274
- x: event.offsetX,
275
- screenX: event.pageX,
276
- y: event.offsetY,
277
- screenY: event.pageY
278
- };
279
- this.#updateToolTip();
280
- }
281
- #updateToolTip() {
282
- if (!this.#lastPointerPosition)
283
- return;
284
- for (const hb of this.#hitboxes) {
285
- if (hb.width <= 0)
286
- continue;
287
- if (Rects.intersectsPoint(hb, this.#lastPointerPosition)) {
288
- if (hb.value) {
289
- this.#setTooltip(hb.series.humanFormatValue(hb.value));
290
- }
291
- else {
292
- this.#setTooltip(``);
293
- }
294
- return;
295
- }
296
- }
297
- this.#hideTooltip();
298
- }
299
- #hideTooltip() {
300
- const v = this.tooltipEl.value;
301
- if (!v)
302
- return;
303
- v.classList.add(`hidden`);
304
- }
305
- #setTooltip(innerHtml) {
306
- const v = this.tooltipEl.value;
307
- if (!v)
308
- return;
309
- const pos = this.#lastPointerPosition;
310
- v.classList.remove(`hidden`);
311
- const offset = 10;
312
- v.innerHTML = innerHtml;
313
- if (pos) {
314
- v.style.left = `${pos.screenX + offset}px`;
315
- v.style.top = `${pos.screenY + offset}px`;
316
- }
317
- }
318
- #setupCanvas() {
319
- if (this.#canvas !== undefined)
320
- return this.#canvas;
321
- const canvas = this.canvasEl.value; // this.shadowRoot?.querySelector(`canvas`);
322
- if (!canvas)
323
- throw new Error(`canvas element not found`);
324
- const c = new CanvasHelper(canvas);
325
- this.#canvas = c;
326
- this.#drawing = Drawing.makeHelper(c.ctx);
327
- return c;
328
- }
329
- connectedCallback() {
330
- super.connectedCallback();
331
- }
332
- firstUpdated(_changedProperties) {
333
- const ro = new ResizeObserver((event) => {
334
- const c = this.#setupCanvas();
335
- if (!c)
336
- return;
337
- const entry = event[0];
338
- c.setLogicalSize(entry.contentRect);
339
- if (this.#hasDirty()) {
340
- this.#drawImpl();
341
- }
342
- });
343
- ro.observe(this);
344
- this.updateColours();
345
- //this.#setupCanvas();
346
- }
347
- #hasDirty() {
348
- for (const s of this.series.values()) {
349
- if (s.isDirty)
350
- return true;
351
- }
352
- return false;
353
- }
354
- updateColours() {
355
- this.#legendColour = getCssVariable(`legend-fg`, `black`);
356
- }
357
- setRawValues(values, seriesName, automaticallyDraw) {
358
- if (!Array.isArray(values))
359
- throw new TypeError(`Param 'values' is not an array`);
360
- let s = this.getOrCreateSeries(seriesName);
361
- s.setRawValues(values, automaticallyDraw);
362
- return s;
363
- }
364
- /**
365
- * Treats each property of an object as the series name
366
- * @param value
367
- * @param automaticallyDraw
368
- */
369
- appendObjectBySeries(value, automaticallyDraw) {
370
- for (const p of Pathed.getPathsAndData(value, true)) {
371
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
372
- const v = p.value;
373
- if (typeof v === `number`) {
374
- this.appendRawValues(v, p.path, false);
375
- }
376
- }
377
- if (automaticallyDraw)
378
- this.draw();
379
- }
380
- appendRawValues(values, seriesName, automaticallyDraw) {
381
- if (!Array.isArray(values))
382
- values = [values];
383
- let s = this.getOrCreateSeries(seriesName);
384
- for (const v of values) {
385
- s.pushValue(v, false);
386
- }
387
- if (automaticallyDraw)
388
- this.draw();
389
- }
390
- draw(force = false) {
391
- if (force) {
392
- this.#drawImpl();
393
- }
394
- else {
395
- void this.#drawThrottled();
396
- }
397
- }
398
- #drawImpl() {
399
- if (this.paused)
400
- return;
401
- const c = this.#canvas;
402
- const d = this.#drawing;
403
- const padding = this.padding;
404
- if (!d || !c) {
405
- return;
406
- }
407
- c.clear();
408
- const ctx = d.ctx;
409
- const axisYwidth = this.computeAxisYWidth(c);
410
- const remainingWidth = c.width - axisYwidth;
411
- const clLegend = this.computeLegend(c, remainingWidth, padding);
412
- const plotHeight = c.height - clLegend.bounds.height - padding;
413
- const cy = { width: axisYwidth, height: plotHeight };
414
- const plotDataArea = this.calculatePlotDataArea(c, plotHeight, cy.width, padding);
415
- const cl = { ...clLegend.bounds, x: cy.width, y: plotDataArea.y + plotDataArea.height + padding };
416
- // Draw legend
417
- if (!this.hideLegend) {
418
- ctx.save();
419
- ctx.translate(cl.x + padding, cl.y + padding);
420
- this.drawLegend(cl, d);
421
- ctx.restore();
422
- }
423
- ctx.save();
424
- ctx.translate(plotDataArea.x + padding, plotDataArea.y + padding);
425
- if (this.plotAreaFormat.fill.type === `solid`) {
426
- ctx.fillStyle = Colour.resolveCss(this.plotAreaFormat.fill.colour);
427
- ctx.fillRect(0, 0, plotDataArea.width, plotDataArea.height);
428
- }
429
- if (this.plotAreaFormat.outline.type === `solid`) {
430
- ctx.strokeStyle = Colour.resolveCss(this.plotAreaFormat.outline.colour);
431
- ctx.strokeRect(0, 0, plotDataArea.width, plotDataArea.height);
432
- }
433
- // Compute axis scaling
434
- const primaryAxisS = this.primaryAxis.getValueScaler(this.#series.values().filter(s => s.onPrimaryAxis));
435
- const secondaryAxisAxisS = this.secondaryAxis.getValueScaler(this.#series.values().filter(s => !s.onPrimaryAxis));
436
- // Draw data
437
- this.#hitboxes = [];
438
- for (const series of this.#series.values()) {
439
- switch (this.renderStyle) {
440
- case `line`: {
441
- this.#drawLineSeries(series, d, series.onPrimaryAxis ? primaryAxisS : secondaryAxisAxisS, plotDataArea, { x: padding, y: padding });
442
- break;
443
- }
444
- case `bar`: {
445
- this.#drawBarSeries(series, d, series.onPrimaryAxis ? primaryAxisS : secondaryAxisAxisS, plotDataArea, { x: padding, y: padding });
446
- break;
447
- }
448
- default: {
449
- this.#drawDotSeries(series, d, series.onPrimaryAxis ? primaryAxisS : secondaryAxisAxisS, plotDataArea, { x: padding, y: padding });
450
- }
451
- }
452
- series.isDirty = false;
453
- }
454
- ctx.restore();
455
- this.#updateToolTip();
456
- }
457
- drawLegend(cl, d) {
458
- const textColour = this.#legendColour;
459
- const padding = this.padding;
460
- let x = 0;
461
- let y = padding;
462
- const swatchSize = 10;
463
- const ctx = d.ctx;
464
- for (const series of this.#series.values()) {
465
- const f = series.getFormatting();
466
- const colour = (f.fill.type === `solid`) ? f.fill.colour : `transparent`;
467
- ctx.fillStyle = Colour.toCssColour(colour);
468
- ctx.fillRect(x, y, swatchSize, swatchSize);
469
- ctx.fillStyle = textColour;
470
- x += swatchSize + padding;
471
- const m = ctx.measureText(series.name);
472
- ctx.textBaseline = `middle`;
473
- ctx.fillText(series.name, x, y + swatchSize / 2);
474
- x += m.width + padding;
475
- if (x >= cl.width) {
476
- y += 10 + padding;
477
- x = 0;
478
- }
479
- }
480
- }
481
- // #drawBarSeries(data: number[], cp: Rect, d: DrawingHelper, series: PlotSeries) {
482
- // const barWidth = this.streaming ? this.dataWidth : (cp.width / data.length);
483
- // const formatting = series.getFormatting();
484
- // let x = 0;
485
- // if (this.streaming) x = cp.width - (barWidth * data.length);
486
- // const rects = data.map(d => {
487
- // x += barWidth;
488
- // const h = (d) * cp.height;
489
- // return {
490
- // x: x,
491
- // y: cp.height - h,
492
- // height: h,
493
- // width: barWidth,
494
- // value: d
495
- // };
496
- // })
497
- // this.#hitboxes = rects.map(r => {
498
- // return {
499
- // ...r,
500
- // series: series.name
501
- // }
502
- // })
503
- // let drawOptions: { stroke: boolean, filled: boolean, strokeWidth?: number, strokeStyle?: string, fillStyle?: string } = {
504
- // stroke: false,
505
- // filled: false
506
- // }
507
- // if (formatting.outline.type === `solid`) {
508
- // drawOptions.stroke = true;
509
- // drawOptions.strokeStyle = formatting.outline.colour;
510
- // drawOptions.strokeWidth = 1;
511
- // }
512
- // if (formatting.fill.type === `solid`) {
513
- // drawOptions.filled = true;
514
- // drawOptions.fillStyle = formatting.fill.colour;
515
- // }
516
- // d.rect(rects, drawOptions);
517
- // }
518
- #drawLineSeries(series, d, scaler, plotDataArea, plotDataAreaOffset) {
519
- const formatting = series.getFormatting();
520
- const lineFormatting = formatting.line;
521
- const widthPerValue = plotDataArea.width / series.length;
522
- const xOffset = widthPerValue / 2;
523
- const lineThickness = lineFormatting.width;
524
- const lineThicknessHalf = lineThickness / 2;
525
- const h = plotDataArea.height;
526
- let x = 0;
527
- const dotsToDraw = [...series.getValuesForColumn(0)].map(d => {
528
- const [value, index] = d;
529
- x += widthPerValue;
530
- const scaledValue = scaler(value);
531
- if (Number.isNaN(value))
532
- return undefined;
533
- return {
534
- x: x - xOffset,
535
- y: (1 - scaledValue) * h,
536
- value, index
537
- };
538
- });
539
- const filtered = dotsToDraw.filter(f => f !== undefined);
540
- const hitboxes = filtered.map(d => ({
541
- height: lineThickness,
542
- width: widthPerValue,
543
- x: plotDataAreaOffset.x + d.x - lineThicknessHalf,
544
- y: plotDataAreaOffset.y + d.y - lineThicknessHalf,
545
- series,
546
- index: d.index,
547
- value: series.getValue(d.index),
548
- }));
549
- this.#hitboxes.push(...hitboxes);
550
- const drawOpts = {
551
- filled: false,
552
- fillStyle: `transparent`,
553
- stroked: true,
554
- strokeStyle: `black`,
555
- strokeWidth: lineFormatting.width
556
- };
557
- if (formatting.outline.type === `solid`) {
558
- drawOpts.strokeStyle = formatting.outline.colour;
559
- }
560
- else if (formatting.fill.type === `solid`) {
561
- drawOpts.strokeStyle = formatting.fill.colour;
562
- }
563
- d.ctx.lineWidth = lineFormatting.width;
564
- d.ctx.lineCap = lineFormatting.cap;
565
- d.ctx.lineJoin = lineFormatting.join;
566
- d.connectedPoints(filtered, drawOpts);
567
- //d.textBlock([ `hello` ], { fillStyle: `black`, anchor: { x: 1, y: 1 } })
568
- }
569
- #drawDotSeries(series, d, scaler, plotDataArea, plotDataAreaOffset) {
570
- const formatting = series.getFormatting();
571
- const dotFormatting = formatting.dot;
572
- const widthPerValue = plotDataArea.width / series.length;
573
- const radius = dotFormatting.radius === `automatic` ? widthPerValue * 0.3 : dotFormatting.radius;
574
- const xOffset = widthPerValue / 2;
575
- const h = plotDataArea.height;
576
- let x = 0;
577
- const dotsToDraw = [...series.getValuesForColumn(0)].map(d => {
578
- const [value, index] = d;
579
- x += widthPerValue;
580
- const scaledValue = scaler(value);
581
- if (Number.isNaN(value))
582
- return undefined;
583
- return {
584
- x: x - xOffset,
585
- y: (1 - scaledValue) * h,
586
- radius: radius,
587
- value, index
588
- };
589
- });
590
- const filtered = dotsToDraw.filter(f => f !== undefined);
591
- const hitboxes = filtered.map(d => ({
592
- height: d.radius * 2,
593
- width: d.radius * 2,
594
- x: plotDataAreaOffset.x + d.x - d.radius,
595
- y: plotDataAreaOffset.y + d.y - d.radius,
596
- series,
597
- index: d.index,
598
- value: series.getValue(d.index),
599
- }));
600
- this.#hitboxes.push(...hitboxes);
601
- const drawOpts = { filled: false, fillStyle: `transparent`, stroked: false, strokeStyle: `transparent` };
602
- if (formatting.fill.type === `solid`) {
603
- drawOpts.filled = true;
604
- drawOpts.fillStyle = formatting.fill.colour;
605
- }
606
- if (formatting.outline.type === `solid`) {
607
- drawOpts.stroked = true;
608
- drawOpts.strokeStyle = formatting.outline.colour;
609
- }
610
- d.dot(filtered, drawOpts);
611
- //d.textBlock([ `hello` ], { fillStyle: `black`, anchor: { x: 1, y: 1 } })
612
- }
613
- #drawBarSeries(series, d, scaler, plotDataArea, plotDataAreaOffset) {
614
- const formatting = series.getFormatting();
615
- const barFormatting = formatting.bar;
616
- const widthPerValue = plotDataArea.width / series.length;
617
- const rectWidth = widthPerValue - (barFormatting.gapWidth / 2);
618
- //const xOffset = widthPerValue / 2;
619
- const h = plotDataArea.height;
620
- let x = 0;
621
- const rectsToDraw = [...series.getValuesForColumn(0)].map(d => {
622
- const [value, index] = d;
623
- x += widthPerValue;
624
- const scaledValue = scaler(value);
625
- if (Number.isNaN(value))
626
- return undefined;
627
- const barHeight = scaledValue * h;
628
- return {
629
- x: x - rectWidth,
630
- y: h - barHeight,
631
- width: rectWidth,
632
- height: barHeight,
633
- value, index
634
- };
635
- });
636
- const filtered = rectsToDraw.filter(f => f !== undefined);
637
- const hitboxes = filtered.map(d => ({
638
- height: Math.max(5, d.height),
639
- width: d.width,
640
- x: plotDataAreaOffset.x + d.x,
641
- y: plotDataAreaOffset.y + d.y,
642
- series,
643
- index: d.index,
644
- value: series.getValue(d.index),
645
- }));
646
- this.#hitboxes.push(...hitboxes);
647
- const drawOpts = { filled: false, fillStyle: `transparent`, stroked: false, strokeStyle: `transparent` };
648
- if (formatting.fill.type === `solid`) {
649
- drawOpts.filled = true;
650
- drawOpts.fillStyle = formatting.fill.colour;
651
- }
652
- if (formatting.outline.type === `solid`) {
653
- drawOpts.stroked = true;
654
- drawOpts.strokeStyle = formatting.outline.colour;
655
- }
656
- d.rect(filtered, drawOpts);
657
- //d.textBlock([ `hello` ], { fillStyle: `black`, anchor: { x: 1, y: 1 } })
658
- }
659
- calculatePlotDataArea(c, plotHeight, axisYwidth, padding) {
660
- return {
661
- x: axisYwidth,
662
- y: 0,
663
- width: c.width - axisYwidth - padding - padding,
664
- height: plotHeight - padding
665
- };
666
- }
667
- computeAxisYWidth(_c) {
668
- return 0;
669
- }
670
- computeLegend(c, maxWidth, padding) {
671
- if (this.hideLegend) {
672
- return {
673
- bounds: { width: 0, height: 0 },
674
- parts: []
675
- };
676
- }
677
- const ctx = c.ctx;
678
- const series = [...this.#series.values()];
679
- let largestH = 0;
680
- const sizes = series.map(s => {
681
- let width = this.#swatchSize + padding;
682
- const m = ctx.measureText(s.name);
683
- width += m.width;
684
- const height = m.emHeightAscent + m.emHeightDescent;
685
- largestH = Math.max(height, largestH);
686
- return {
687
- width,
688
- height
689
- };
690
- });
691
- const parts = [];
692
- let x = padding;
693
- let y = padding;
694
- let usedWidthMax = 0;
695
- for (const s of sizes) {
696
- parts.push({
697
- x, y, ...s
698
- });
699
- x += s.width;
700
- usedWidthMax = Math.max(x, usedWidthMax);
701
- if (x >= maxWidth) {
702
- x = padding;
703
- y += largestH + padding;
704
- }
705
- }
706
- const bounds = { width: usedWidthMax, height: y + largestH + padding };
707
- return {
708
- bounds, parts
709
- };
710
- }
711
- getOrCreateSeries(name) {
712
- let s = this.#series.get(name.toLowerCase());
713
- if (s)
714
- return s;
715
- s = new PlotSeries(name, this);
716
- const seriesDefault = {
717
- limit: Number.NaN,
718
- ...this.seriesDefault
719
- };
720
- if (!Number.isNaN(seriesDefault.limit)) {
721
- s.setCapacityLimit(seriesDefault.limit);
722
- }
723
- this.#series.set(name.toLowerCase(), s);
724
- return s;
725
- }
726
- getSeries(name) {
727
- return this.#series.get(name);
728
- }
729
- render() {
730
- // eslint-disable-next-line @typescript-eslint/unbound-method
731
- return html `<canvas @pointerleave="${this.#onPointerLeave}" @pointermove="${this.#onPointerMove}" ${ref(this.canvasEl)}></canvas><div class="hidden" ${ref(this.tooltipEl)} id="tooltip"></div>`;
732
- }
733
- static { this.styles = css `
734
- :host {
735
- width: 100%;
736
- height: 100%;
737
- display: block;
738
- }
739
-
740
- #tooltip {
741
- border: 1px solid black;
742
- background: white;
743
- color: black;
744
- padding: 0.3em;
745
- font-size: 10px;
746
- display: inline-block;
747
- position: absolute;
748
- left: 0px;
749
- top: 0px;
750
- opacity:1;
751
- pointer-events: none;
752
- }
753
-
754
- .hidden {
755
- opacity:0 !important;
756
- }
757
- `; }
758
- };
759
- __decorate([
760
- property({ attribute: `hide-legend`, type: Boolean })
761
- ], PlotElement.prototype, "hideLegend", void 0);
762
- __decorate([
763
- property({ attribute: `render`, type: String })
764
- ], PlotElement.prototype, "renderStyle", void 0);
765
- __decorate([
766
- property({ attribute: `padding`, type: Number })
767
- ], PlotElement.prototype, "padding", void 0);
768
- PlotElement = __decorate([
769
- customElement(`ixfx-plot-element`)
770
- ], PlotElement);
771
- export { PlotElement };
772
- const resolveFillDrawStyle = (s) => {
773
- if (s.type === `none`)
774
- return s;
775
- const c = Colour.resolveCss(s.colour);
776
- return {
777
- type: `solid`,
778
- colour: c
779
- };
780
- };
781
- const resolveOutlineDrawStyle = (s) => {
782
- if (s.type === `none`)
783
- return s;
784
- const c = Colour.resolveCss(s.colour);
785
- return {
786
- ...s,
787
- colour: c
788
- };
789
- };
790
- //export type Range = { min: number, max: number }
791
- // const initRange = (): Range => ({ min: Number.MAX_SAFE_INTEGER, max: Number.MIN_SAFE_INTEGER });
792
- // function computeRangeWithNewValue(v: number | undefined, prev: Range): Range {
793
- // if (typeof v === `number`) {
794
- // // Skip creating an object if it's in range
795
- // if (v >= prev.min && v <= prev.max) return prev;
796
- // return {
797
- // min: Math.min(v, prev.min),
798
- // max: Math.max(v, prev.max),
799
- // }
800
- // }
801
- // return prev;
802
- // }
803
- // function computeMergedRange(newRange: Range, existingRange: Range): Range {
804
- // if (newRange.max <= existingRange.max && newRange.min >= existingRange.min) return existingRange;
805
- // return {
806
- // min: Math.min(newRange.min, existingRange.min),
807
- // max: Math.max(newRange.max, existingRange.max)
808
- // }
809
- // }
810
- export class PlotSeries {
811
- #data = [];
812
- #capacityLimit = Number.NaN;
813
- #dirty = false;
814
- #onPrimaryAxis = true;
815
- constructor(name, plot) {
816
- this.name = name;
817
- this.plot = plot;
818
- }
819
- get length() {
820
- return this.#data.length;
821
- }
822
- *getValuesForColumn(column) {
823
- let index = 0;
824
- for (const dv of this.#data) {
825
- if (dv && column in dv) {
826
- yield [dv[column], index];
827
- }
828
- else {
829
- yield [Number.NaN, index];
830
- }
831
- index++;
832
- }
833
- }
834
- getValue(index) {
835
- return this.#data[index];
836
- }
837
- pushValue(value, automaticallyDraw) {
838
- if (!Array.isArray(value)) {
839
- value = [value];
840
- }
841
- if (value.length === 0)
842
- throw new Error(`Param 'value' is empty. Expected a value or array of value components`);
843
- this.#data.push(value);
844
- if (!Number.isNaN(this.#capacityLimit)) {
845
- this.#data = Arrays.ensureLength(this.#data, this.#capacityLimit, `undefined`, `from-start`);
846
- }
847
- this.#dirty = true;
848
- if (automaticallyDraw)
849
- this.plot.draw();
850
- }
851
- setValues(values, automaticallyDraw) {
852
- if (!Array.isArray(values))
853
- throw new TypeError(`Param 'values' is not an array`);
854
- this.#data = Arrays.ensureLength(values, this.#capacityLimit, `undefined`);
855
- //this.#updateRanges();
856
- this.#dirty = true;
857
- if (automaticallyDraw)
858
- this.plot.draw();
859
- }
860
- humanFormatValue(value) {
861
- let v = `${this.name} `;
862
- if (this.onPrimaryAxis) {
863
- v += this.plot.primaryAxis.humanFormatValue(value);
864
- }
865
- else {
866
- v += this.plot.secondaryAxis.humanFormatValue(value);
867
- }
868
- return v;
869
- }
870
- setRawValues(values, automaticallyDraw) {
871
- this.setValues(values.map(v => [v]), automaticallyDraw);
872
- }
873
- setCapacityLimit(v) {
874
- if (typeof v !== `number`)
875
- throw new TypeError(`Expect type number. Got: ${typeof v}`);
876
- if (!Number.isFinite(v)) {
877
- throw new TypeError(`Param 'v' is not finite`);
878
- }
879
- if (Number.isNaN(v)) {
880
- throw new TypeError(`Param 'v' is NaN`);
881
- }
882
- this.#capacityLimit = v;
883
- this.#data = Arrays.ensureLength(this.#data, this.#capacityLimit, `undefined`);
884
- }
885
- unsetCapacityLimit() {
886
- this.#capacityLimit = Number.NaN;
887
- }
888
- setFormatting(formatting) {
889
- this.plot.setSeriesFormatting(this.name, formatting);
890
- }
891
- getFormatting() {
892
- return this.plot.getSeriesFormatting(this.name, true);
893
- }
894
- get isDirty() {
895
- return this.#dirty;
896
- }
897
- set isDirty(value) {
898
- this.#dirty = value;
899
- }
900
- get onPrimaryAxis() {
901
- return this.#onPrimaryAxis;
902
- }
903
- set onPrimaryAxis(value) {
904
- if (value === this.#onPrimaryAxis)
905
- return;
906
- this.#onPrimaryAxis = value;
907
- this.#dirty = true;
908
- }
909
- clear() {
910
- this.#data = [];
911
- this.#dirty = true;
912
- }
913
- }
914
- //# sourceMappingURL=plot.js.map