svelte-plots-basic 3.2.1 → 3.4.0

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.
@@ -40,7 +40,7 @@
40
40
  </Axes>
41
41
  -->
42
42
  <script>
43
- import { getContext } from 'svelte';
43
+ import { getContext, onDestroy } from 'svelte';
44
44
  import { Colors, MARKER_SYMBOLS } from '../constants';
45
45
  import { text2svg } from '../methods';
46
46
 
@@ -78,8 +78,9 @@
78
78
  return null;
79
79
  }
80
80
 
81
+ const result = [];
81
82
  for (let i = 0; i < items.length; i++) {
82
- const item = items[i];
83
+ const item = {...items[i]};
83
84
 
84
85
  // check and transform label
85
86
  if (!item.label) {
@@ -88,13 +89,14 @@
88
89
  }
89
90
 
90
91
  const newLabel = text2svg(item.label);
91
- const labelHeight = newLabel.length === item.label ? 1 : 1.4;
92
+ const labelHeight = newLabel.length === item.label.length ? 1 : 1.4;
92
93
  item.label = newLabel;
93
- item['labelHeight'] = labelHeight;
94
+ item.labelHeight = labelHeight;
94
95
 
95
96
  // set default values for lines
96
97
  if (item.line) {
97
- if (!item.line.lineType) item.line['lineType'] = 1
98
+ item.line = {...item.line};
99
+ if (!item.line.lineType) item.line.lineType = 1
98
100
  if (!(item.line.lineType > 0 && item.line.lineType <= 4)) {
99
101
  console.error('Legend: parameter "lineType" for legend item ' + (i + 1) + ' is incorrect.');
100
102
  }
@@ -104,7 +106,8 @@
104
106
 
105
107
  // set default values for markers
106
108
  if (item.point) {
107
- if (!item.point.marker) item.point['marker'] = 1
109
+ item.point = {...item.point};
110
+ if (!item.point.marker) item.point.marker = 1
108
111
  if (!(item.point.marker > 0 && item.point.marker <= MARKER_SYMBOLS.length)) {
109
112
  console.error('Legend: parameter "marker" for legend item ' + (i + 1) + ' is incorrect.');
110
113
  }
@@ -113,8 +116,10 @@
113
116
  item.point.markerSize = item.point.markerSize ? item.point.markerSize : 1;
114
117
  item.point.lineColor = item.point.lineColor ? item.point.lineColor : Colors.PRIMARY;
115
118
  }
119
+
120
+ result.push(item);
116
121
  }
117
- return items;
122
+ return result;
118
123
  }
119
124
 
120
125
  // get context and update group legend parameters reactivey
@@ -124,8 +129,16 @@
124
129
  const newPosition = checkPosition(position);
125
130
  axes.setGroupLegend(
126
131
  newItems && newPosition ?
127
- {show, position, items, lineColor, faceColor, lineWidth, fontSize} :
132
+ {show, position, items: newItems, lineColor, faceColor, lineWidth, fontSize} :
128
133
  {show: false, position: null, items: null}
129
134
  );
130
135
  });
136
+
137
+ onDestroy(() => {
138
+ axes.setGroupLegend({
139
+ show: false,
140
+ position: null,
141
+ items: null
142
+ });
143
+ });
131
144
  </script>
@@ -30,7 +30,6 @@
30
30
  import { val2p, checkCoords, handleClick } from '../methods';
31
31
  import { LINE_STYLES } from '../constants';
32
32
 
33
- /** @type {Props} */
34
33
  let {
35
34
  xValues, // vector or array with x-coordinates of the points
36
35
  yValues, // vector or array with y-coordinates of the points
@@ -60,4 +59,3 @@
60
59
  <polyline class="line" points={p}/>
61
60
  </g>
62
61
  {/if}
63
-
@@ -38,7 +38,6 @@
38
38
  import { val2p, checkCoords, handleClick } from '../methods';
39
39
  import { LINE_STYLES } from '../constants';
40
40
 
41
- /** @type {Props} */
42
41
  let {
43
42
  xValues, // vector or array with x-coordinates of the points
44
43
  yValues, // vector or array with y-coordinates of the points
@@ -61,6 +60,7 @@
61
60
 
62
61
  if (xv.length !== yValues.nrows) {
63
62
  console.error('Multilines: parameter "xValues" must have the same number of values as number of rows in "yValues".');
63
+ return null;
64
64
  }
65
65
 
66
66
  return yValues;
@@ -91,4 +91,3 @@
91
91
  {/each}
92
92
  </g>
93
93
  {/if}
94
-
@@ -31,7 +31,6 @@
31
31
  import { Colors, MARKER_SYMBOLS } from '../constants';
32
32
  import { checkCoords, transformCoords, handleClick } from '../methods';
33
33
 
34
- /** @type {Props} */
35
34
  let {
36
35
  xValues, // array of vector with x-coordinates of points
37
36
  yValues, // array of vector with y-coordinates of points
@@ -36,7 +36,6 @@
36
36
  import { Colors } from '../constants';
37
37
  import { checkCoords, transformCoords, transformObjects, handleClick } from '../methods';
38
38
 
39
- /** @type {Props} */
40
39
  let {
41
40
  left, // array of vector with coordinates of left sides of the bars
42
41
  top, // array of vector with coordinates of top sides of the bars
@@ -80,4 +79,3 @@
80
79
  </g>
81
80
  {/if}
82
81
 
83
-
@@ -71,8 +71,22 @@
71
71
  const p = $derived.by(() => {
72
72
  if (!l) return null;
73
73
 
74
- if (typeof labels === 'string' && typeof pos !== 'number' ) {
75
- console.error('TextLabels: parameter "labels" is provided as single string, so "pos" must be a single number.');
74
+ const hasIndividualPositions =
75
+ Array.isArray(pos) || ArrayBuffer.isView(pos);
76
+
77
+ if (typeof labels === 'string' && hasIndividualPositions) {
78
+ console.error('TextLabels: when "labels" is a single string, "pos" must be a single number.');
79
+ return null;
80
+ }
81
+
82
+ if (hasIndividualPositions && pos.length !== yv.length) {
83
+ console.error('TextLabels: the number of values in "pos" must match the number of coordinates.');
84
+ return null;
85
+ }
86
+
87
+ const positions = hasIndividualPositions ? Array.from(pos) : [pos];
88
+ if (positions.some(v => !Number.isInteger(v) || v < 0 || v > 4)) {
89
+ console.error('TextLabels: values in "pos" must be whole numbers from 0 to 4.');
76
90
  return null;
77
91
  }
78
92
 
@@ -106,14 +120,14 @@
106
120
  {#each x as v, i}
107
121
  <text data-id={i} x={x[i]} y={y[i]} dx={dx[pos]} dy={dy[pos]}
108
122
  transform={rotateAngle !== undefined ? `rotate(${rotateAngle}, ${x[i] + dx[pos]}, ${y[i] + dy[pos]})` : ''}
109
- text-anchor={textAnchors[pos[i]]}>{@html labels}</text>
123
+ text-anchor={textAnchors[pos]}>{@html labels}</text>
110
124
  {/each}
111
125
 
112
126
  {:else if (Array.isArray(pos) || ArrayBuffer.isView(pos))}
113
127
 
114
128
  {#each x as v, i}
115
129
  <text data-id={i} x={x[i]} y={y[i]} dx={dx[pos[i]]} dy={dy[pos[i]]}
116
- transform={rotateAngle !== undefined ? `rotate(${rotateAngle}, ${x[i] + dx[pos]}, ${y[i] + dy[pos]})` : ''}
130
+ transform={rotateAngle !== undefined ? `rotate(${rotateAngle}, ${x[i] + dx[pos[i]]}, ${y[i] + dy[pos[i]]})` : ''}
117
131
  text-anchor={textAnchors[pos[i]]}>{@html labels[i]}</text>
118
132
  {/each}
119
133
 
@@ -1,6 +1,7 @@
1
1
  <script>
2
2
  import { getContext } from 'svelte';
3
3
  import { Colors } from '../constants';
4
+ import { transformCoords } from '../methods';
4
5
 
5
6
  let {
6
7
  left, // vector/array with coordinates of lef side of each text box
@@ -15,8 +16,16 @@
15
16
  } = $props()
16
17
 
17
18
  const axes = getContext('axes');
18
- const x = $derived(left ? transformCoords([left], axes.tX()) : null);
19
- const y = $derived(top ? transformCoords([top], axes.tY()) : null );
19
+ const x = $derived(
20
+ left !== undefined && left !== null
21
+ ? transformCoords([left], axes.tX())
22
+ : null
23
+ );
24
+ const y = $derived(
25
+ top !== undefined && top !== null
26
+ ? transformCoords([top], axes.tY())
27
+ : null
28
+ );
20
29
 
21
30
  // styles for bars and labels
22
31
  const textStyleStr = $derived(`fill:${faceColor};stroke-width:${lineWidth}px;stroke:${lineColor};font-size:${textSize}em;`);
@@ -28,4 +37,4 @@
28
37
  <tspan {x} {dx} dy={i === 0 ? 0 : dy}>{@html el}</tspan>
29
38
  {/each}
30
39
  </text>
31
- {/if}
40
+ {/if}
@@ -21,7 +21,7 @@
21
21
  -->
22
22
  <script>
23
23
 
24
- import { getContext } from 'svelte';
24
+ import { getContext, onDestroy } from 'svelte';
25
25
  import { text2svg, validateTicks, validateTickLabels } from '../methods';
26
26
 
27
27
  let {
@@ -60,4 +60,8 @@
60
60
  axes.setXAxis({show, error: error, label: axisLabel, ticks: ticksProcessed,
61
61
  labelHeight, showGrid, las, whole, tickLabels: tickLabelsProcessed});
62
62
  });
63
+
64
+ onDestroy(() => {
65
+ axes.setXAxis({show: false, error: ''});
66
+ });
63
67
  </script>
@@ -21,7 +21,7 @@
21
21
  -->
22
22
  <script>
23
23
 
24
- import { getContext } from 'svelte';
24
+ import { getContext, onDestroy } from 'svelte';
25
25
  import { text2svg, validateTicks, validateTickLabels } from '../methods';
26
26
 
27
27
 
@@ -63,4 +63,8 @@
63
63
  axes.setYAxis({show, error: error, label: axisLabel, ticks: ticksProcessed,
64
64
  labelHeight, showGrid, las, whole, tickLabels: tickLabelsProcessed, pos: 4});
65
65
  });
66
+
67
+ onDestroy(() => {
68
+ axes.setYAxis({show: false, error: ''});
69
+ });
66
70
  </script>
@@ -5,8 +5,8 @@
5
5
  - `limX` - array with limits for x-axis (in plot units), default: `[0, 1]`.
6
6
  - `limY` - array with limits for y-axis (in plot units), default: `[0, 1]`.
7
7
  - `limZ` - array with limits for y-axis (in plot units), default: `[0, 1]`.
8
- - `theta` - angle (in degrees) for orientation of projection plane, default: `-10`.
9
- - `phi` - angle (in degrees) for orientation of projection plane, default: `-10`.
8
+ - `theta` - angle (in radians) for orientation of projection plane, default: `-10`.
9
+ - `phi` - angle (in radians) for orientation of projection plane, default: `-10`.
10
10
  - `zoom` - zooming factor, default: `0.5`.
11
11
 
12
12
  Properties for downloading the plot as PNG or SVG file or copying it to clipboard:
@@ -33,14 +33,13 @@
33
33
  import { matrix, Matrix } from 'mdatools/arrays';
34
34
  import { setContext } from 'svelte';
35
35
  import { PLOT_FONT_SIZE } from '../constants.js';
36
- import { checkArray, getScale, getXAxisCoords3D, getYAxisCoords3D, getZAxisCoords3D,
36
+ import { getScale, getXAxisCoords3D, getYAxisCoords3D, getZAxisCoords3D,
37
37
  downloadPNG, downloadSVG, copyToClipboard} from '../methods.js';
38
38
 
39
39
  import AxisLines from './AxisLines.svelte';
40
40
  import AxisTickLabels from './AxisTickLabels.svelte';
41
41
  import TextLabels from './TextLabels.svelte';
42
42
 
43
- /** @type {Props} */
44
43
  let {
45
44
  limX = [0, 1],
46
45
  limY = [0, 1],
@@ -48,7 +47,7 @@
48
47
  theta = -10,
49
48
  phi = -10,
50
49
  zoom = 0.5,
51
- downloadLinks = 'hover',
50
+ downloadLinks = 'none',
52
51
  fileName = 'plot',
53
52
  pngWidth = 8,
54
53
  pngHeight = 8,
@@ -59,6 +58,21 @@
59
58
  } = $props();
60
59
 
61
60
 
61
+ function hasUsableRange(lim) {
62
+ if (!Array.isArray(lim) || lim.length !== 2) return false;
63
+ if (!lim.every(value =>
64
+ typeof value === 'number' && Number.isFinite(value)
65
+ )) return false;
66
+
67
+ const span = lim[1] - lim[0];
68
+ const scale = Math.max(Math.abs(lim[0]), Math.abs(lim[1]));
69
+
70
+ return span > 0 &&
71
+ Number.isFinite(1 / span) &&
72
+ span > Number.EPSILON * scale * 16;
73
+ }
74
+
75
+
62
76
 
63
77
  /* Copy plot to clipboard as PNG image. */
64
78
  async function handleClickCopy(e) {
@@ -105,12 +119,9 @@
105
119
 
106
120
  // check main plot parameters and set status
107
121
  const isOk = $derived(
108
- checkArray(limX, 2) &&
109
- checkArray(limY, 2) &&
110
- checkArray(limZ, 2) &&
111
- limX[0] < limX[1] &&
112
- limY[0] < limY[1] &&
113
- limZ[0] < limZ[1] &&
122
+ hasUsableRange(limX) &&
123
+ hasUsableRange(limY) &&
124
+ hasUsableRange(limZ) &&
114
125
  width > 50 &&
115
126
  height > 50
116
127
  );
@@ -174,9 +185,9 @@
174
185
  );
175
186
 
176
187
  // containers for axis properties
177
- let xaxis = $state({show: false, label: ""});
178
- let yaxis = $state({show: false, label: ""});
179
- let zaxis = $state({show: false, label: ""});
188
+ let xaxis = $state.raw({show: false, label: ""});
189
+ let yaxis = $state.raw({show: false, label: ""});
190
+ let zaxis = $state.raw({show: false, label: ""});
180
191
 
181
192
  // axes context to share with children
182
193
  setContext('axes', {
@@ -290,9 +301,9 @@
290
301
  </p>
291
302
  {:else}
292
303
  <div class="download-links">
293
- <button onclick={handleClickSVG} onkeydown={handleClickSVG}>⇩ svg</button>
294
- <button onclick={handleClickPNG} onkeydown={handleClickPNG}>⇩ png</button>
295
- <button onclick={handleClickCopy} onkeydown={handleClickCopy}>⧉ copy</button>
304
+ <button type="button" onclick={handleClickSVG}>⇩ svg</button>
305
+ <button type="button" onclick={handleClickPNG}>⇩ png</button>
306
+ <button type="button" onclick={handleClickCopy}>⧉ copy</button>
296
307
  </div>
297
308
  {/if}
298
309
  </div>
@@ -370,7 +381,6 @@
370
381
  transition: bottom 0.35s ease;
371
382
  box-shadow: 0 0 0.75em #00000060;
372
383
  margin: 0.6em;
373
- box-sizing: border-box;
374
384
 
375
385
  display: flex;
376
386
  align-items: center;
@@ -400,4 +410,4 @@
400
410
  background: #4488ee;
401
411
  }
402
412
 
403
- </style>
413
+ </style>
@@ -45,25 +45,50 @@
45
45
 
46
46
  // check user defined coordinates
47
47
  const ux = $derived(checkCoords(xValues, 'Mesh (3D)'));
48
- const uz = $derived(ux ? checkCoords(zValues, 'Mesh (3D)', ux.length) : null);
48
+ const uz = $derived(ux ? checkCoords(zValues, 'Mesh (3D)') : null);
49
49
  const Uy = $derived.by(() => {
50
50
  if (!ux || !uz) return null;
51
51
  if (!ismatrix(yValues)) {
52
52
  console.error('Mesh: parameter "yValues" must be a matrix with height values of mesh points.');
53
53
  return null;
54
54
  }
55
+ if (yValues.nrows !== ux.length || yValues.ncols !== uz.length) {
56
+ console.error('Mesh: dimensions of "yValues" must match the lengths of "xValues" and "zValues".');
57
+ return null;
58
+ }
55
59
  return yValues;
56
60
  });
57
61
 
58
62
 
63
+ const colors = $derived.by(() => {
64
+ const isValid =
65
+ Array.isArray(colmap) &&
66
+ colmap.length > 0 &&
67
+ colmap.every(color =>
68
+ typeof color === 'string' && color.length > 0
69
+ );
70
+
71
+ if (!isValid) {
72
+ console.error(
73
+ 'Mesh: parameter "colmap" must be a non-empty array of color strings.'
74
+ );
75
+ return null;
76
+ }
77
+
78
+ return colmap;
79
+ });
80
+
81
+
59
82
  // compute coordinates of mesh elements
60
83
  const mesh = $derived.by(() => {
61
84
 
62
- if (!Uy) return null;
85
+ if (!Uy || !colors) return null;
63
86
 
64
- const nbins = colmap.length;
87
+ const nbins = colors.length;
65
88
  const nx = Uy.nrows;
66
89
  const nz = Uy.ncols;
90
+ const nsegmentsX = (nx - 1) * nz;
91
+ const nsegmentsZ = nx * (nz - 1);
67
92
 
68
93
  const nr = range(Uy.v);
69
94
  const dnr = (nr[1] - nr[0]) / 100;
@@ -71,26 +96,36 @@
71
96
  const right = nr[1] + dnr;
72
97
  const span = right - left;
73
98
 
99
+ function getColorIndex(value) {
100
+ if (!(span > 0)) return Math.floor(nbins / 2);
101
+
102
+ const index = Math.round(
103
+ (value - left) / span * (nbins - 1)
104
+ );
105
+
106
+ return Math.max(0, Math.min(nbins - 1, index));
107
+ }
108
+
74
109
  // compute coordinates for mesh segments lines
75
- const x1s = Vector.zeros((nx - 1) * nz);
76
- const z1s = Vector.zeros((nx - 1) * nz);
77
- const y1s = Vector.zeros((nx - 1) * nz);
110
+ const x1s = Vector.zeros(nsegmentsX);
111
+ const z1s = Vector.zeros(nsegmentsX);
112
+ const y1s = Vector.zeros(nsegmentsX);
78
113
 
79
- const x2s = Vector.zeros((nx - 1) * nz);
80
- const z2s = Vector.zeros((nx - 1) * nz);
81
- const y2s = Vector.zeros((nx - 1) * nz);
114
+ const x2s = Vector.zeros(nsegmentsZ);
115
+ const z2s = Vector.zeros(nsegmentsZ);
116
+ const y2s = Vector.zeros(nsegmentsZ);
82
117
 
83
- const color1 = Vector.zeros((nx - 1) * nz);
118
+ const color1 = Vector.zeros(nsegmentsX);
84
119
 
85
- const x1e = Vector.zeros((nx - 1) * nz);
86
- const z1e = Vector.zeros((nx - 1) * nz);
87
- const y1e = Vector.zeros((nx - 1) * nz);
120
+ const x1e = Vector.zeros(nsegmentsX);
121
+ const z1e = Vector.zeros(nsegmentsX);
122
+ const y1e = Vector.zeros(nsegmentsX);
88
123
 
89
- const x2e = Vector.zeros((nx - 1) * nz);
90
- const z2e = Vector.zeros((nx - 1) * nz);
91
- const y2e = Vector.zeros((nx - 1) * nz);
124
+ const x2e = Vector.zeros(nsegmentsZ);
125
+ const z2e = Vector.zeros(nsegmentsZ);
126
+ const y2e = Vector.zeros(nsegmentsZ);
92
127
 
93
- const color2 = Vector.zeros((nx - 1) * nz);
128
+ const color2 = Vector.zeros(nsegmentsZ);
94
129
 
95
130
  let n1 = 0, n2 = 0;
96
131
  for (let z = 0; z < nz; z++) {
@@ -101,14 +136,15 @@
101
136
  // x-direction - start
102
137
  x1s.v[n1] = ux.v[x];
103
138
  z1s.v[n1] = uz.v[z];
104
- y1s.v[n1] = Uy.v[z * nz + x];
139
+ y1s.v[n1] = Uy.v[z * nx + x];
105
140
 
106
141
  // x-direction - end
107
142
  x1e.v[n1] = ux.v[x + 1];
108
143
  z1e.v[n1] = uz.v[z];
109
- y1e.v[n1] = Uy.v[z * nz + x + 1];
144
+ y1e.v[n1] = Uy.v[z * nx + x + 1];
110
145
 
111
- const colInd = Math.round(((Uy.v[z * nz + x] + Uy.v[z * nz + x + 1]) / 2 - left) / span * (nbins - 1));
146
+ const meanHeight = (Uy.v[z * nx + x] + Uy.v[z * nx + x + 1]) / 2;
147
+ const colInd = getColorIndex(meanHeight);
112
148
  color1.v[n1] = colInd;
113
149
  n1 = n1 + 1;
114
150
  }
@@ -118,14 +154,15 @@
118
154
  // z-direction - start
119
155
  x2s.v[n2] = ux.v[x];
120
156
  z2s.v[n2] = uz.v[z];
121
- y2s.v[n2] = Uy.v[z * nz + x];
157
+ y2s.v[n2] = Uy.v[z * nx + x];
122
158
 
123
159
  // z-direction - end
124
160
  x2e.v[n2] = ux.v[x];
125
161
  z2e.v[n2] = uz.v[z + 1];
126
- y2e.v[n2] = Uy.v[(z + 1) * nz + x];
162
+ y2e.v[n2] = Uy.v[(z + 1) * nx + x];
127
163
 
128
- const colInd = Math.round(((Uy.v[z * nz + x] + Uy.v[(z + 1) * nz + x]) / 2 - left) / span * (nbins - 1));
164
+ const meanHeight = (Uy.v[z * nx + x] + Uy.v[(z + 1) * nx + x]) / 2;
165
+ const colInd = getColorIndex(meanHeight);
129
166
  color2.v[n2] = colInd;
130
167
  n2 = n2 + 1;
131
168
  }
@@ -153,11 +190,10 @@
153
190
  <g class="series series_mesh" style={lineStyleStr} data-title={title}>
154
191
  {#if s1s && s1e && s2s && s2e }
155
192
  {#each s1s.x as v, i}
156
- <line x1={s1s.x[i]} x2={s1e.x[i]} y1={s1s.y[i]} y2={s1e.y[i]} style={`stroke:${colmap[mesh.color1.v[i]]};`} />
193
+ <line x1={s1s.x[i]} x2={s1e.x[i]} y1={s1s.y[i]} y2={s1e.y[i]} style={`stroke:${colors[mesh.color1.v[i]]};`} />
157
194
  {/each}
158
195
  {#each s2s.x as v, i}
159
- <line x1={s2s.x[i]} x2={s2e.x[i]} y1={s2s.y[i]} y2={s2e.y[i]} style={`stroke:${colmap[mesh.color2.v[i]]};`} />
196
+ <line x1={s2s.x[i]} x2={s2e.x[i]} y1={s2s.y[i]} y2={s2e.y[i]} style={`stroke:${colors[mesh.color2.v[i]]};`} />
160
197
  {/each}
161
198
  {/if}
162
199
  </g>
163
-
@@ -60,8 +60,8 @@
60
60
  const uz1 = $derived(uy1 ? checkCoords(zStart, 'Segments (3D)', ux1.length) : null);
61
61
 
62
62
  const ux2 = $derived(uz1 ? checkCoords(xEnd, 'Segments (3D)', ux1.length) : null);
63
- const uy2 = $derived(ux1 ? checkCoords(yEnd, 'Segments (3D)', ux1.length) : null);
64
- const uz2 = $derived(uy1 ? checkCoords(zEnd, 'Segments (3D)', ux1.length) : null);
63
+ const uy2 = $derived(ux2 ? checkCoords(yEnd, 'Segments (3D)', ux1.length) : null);
64
+ const uz2 = $derived(uy2 ? checkCoords(zEnd, 'Segments (3D)', ux1.length) : null);
65
65
 
66
66
  // combine world coordinates to matrices
67
67
  const uW1 = $derived(ux1 && uy1 && uz1 ? cbind(ux1, uy1, uz1) : null);
@@ -55,6 +55,7 @@
55
55
  const U = $derived(ux && uy && uz ? cbind(ux, uy, uz) : null);
56
56
 
57
57
  const l = $derived.by(() => {
58
+ if (!ux) return null;
58
59
  if(Array.isArray(labels) && labels.length !== ux.length ) {
59
60
  console.error('TextLabels: labels provided as an array should have the same number of elements as number of coordinates.');
60
61
  return null;
@@ -79,7 +80,7 @@
79
80
  <text data-id={i} x={s.x[i]} y={s.y[i]} dx={0} dy={0}>{@html l}</text>
80
81
  {/each}
81
82
  {:else}
82
- {#each x as v, i}
83
+ {#each s.x as v, i}
83
84
  <text data-id={i} x={s.x[i]} y={s.y[i]} dx={0} dy={0}>{@html l[i]}</text>
84
85
  {/each}
85
86
  {/if}
@@ -22,7 +22,7 @@
22
22
  ```
23
23
  -->
24
24
  <script>
25
- import { getContext } from 'svelte';
25
+ import { getContext, onDestroy } from 'svelte';
26
26
  import { Colors } from '../constants';
27
27
 
28
28
  let {
@@ -41,6 +41,9 @@
41
41
  $effect(() => {
42
42
  axes.setXAxis({show: true, ticks, tickLabels, showGrid, label, lineColor, gridColor, textColor});
43
43
  });
44
- </script>
45
44
 
45
+ onDestroy(() => {
46
+ axes.setXAxis({show: false});
47
+ });
48
+ </script>
46
49
 
@@ -22,7 +22,7 @@
22
22
  ```
23
23
  -->
24
24
  <script>
25
- import { getContext } from 'svelte';
25
+ import { getContext, onDestroy } from 'svelte';
26
26
  import { Colors } from '../constants';
27
27
 
28
28
  let {
@@ -41,6 +41,9 @@
41
41
  $effect(() => {
42
42
  axes.setYAxis({show: true, ticks, tickLabels, showGrid, label, lineColor, gridColor, textColor});
43
43
  });
44
- </script>
45
44
 
45
+ onDestroy(() => {
46
+ axes.setYAxis({show: false});
47
+ });
48
+ </script>
46
49
 
@@ -22,7 +22,7 @@
22
22
  ```
23
23
  -->
24
24
  <script>
25
- import { getContext } from 'svelte';
25
+ import { getContext, onDestroy } from 'svelte';
26
26
  import { Colors } from '../constants';
27
27
 
28
28
  let {
@@ -41,6 +41,9 @@
41
41
  $effect(() => {
42
42
  axes.setZAxis({show: true, ticks, tickLabels, showGrid, label, lineColor, gridColor, textColor});
43
43
  });
44
- </script>
45
44
 
45
+ onDestroy(() => {
46
+ axes.setZAxis({show: false});
47
+ });
48
+ </script>
46
49