svelte-plots-basic 2.5.8 → 3.0.1

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.
@@ -1,68 +1,84 @@
1
- <script>
2
- /****************************************************
3
- * Segments for 3D plot *
4
- * -------------------- *
5
- * shows a series of line segments on the plot *
6
- *****************************************************/
1
+ <!--
2
+ @component Adds a series with line segments.
7
3
 
8
- import { cbind } from 'mdatools/arrays';
9
- import { getContext } from 'svelte';
10
- import { Colors } from '../Colors';
11
- import { checkCoords } from '../Utils';
4
+ Main properties:
5
+ - `xStart` - vector or array with x-coordinates of starting points.
6
+ - `xEnd` - or array with x-coordinates of end points.
7
+ - `yStart` - vector or array with y-coordinates of starting points.
8
+ - `yEnd` - vector or array with y-coordinates of end points.
9
+ - `zStart` - vector or array with z-coordinates of starting points.
10
+ - `zEnd` - vector or array with z-coordinates of end points.
11
+ - `lineColor` - color of segment lines, default: `Colors.PRIMARY`.
12
+ - `lineType` - type of segment lines (`1` - solid, `2` - dashed, `3` - dotted, `4` - dashdot).
13
+ - `lineWidth` - width (thickness) of segment lines in pixels, default: `1`.
14
+ - `className` - CSS class name of the SVG group, default: `'series-seg'`.
15
+ - `title` - title of the segment series group.
16
+ - `onclick` - function (callback) to be called when user clicks on any segment.
12
17
 
18
+ Example:
19
+ ```jsx
20
+ <script>
21
+ import { Axes, Segments } from 'svelte-plots-basic/3d';
13
22
 
14
- /*****************************************/
15
- /* Input parameters */
16
- /*****************************************/
23
+ const xStart = [1, 2, 3, 4];
24
+ const xEnd = [1, 2, 3, 4];
25
+ const yStart = [-2, -1, 0, -1, -2];
26
+ const yEnd = [2, 1, 0, 1, 2];
27
+ const zStart = [1, 2, 3, 4];
28
+ const zEnd = [1, 2, 3, 4];
29
+ </script>
17
30
 
18
- export let title = '';
19
- export let xStart;
20
- export let xEnd;
21
- export let yStart;
22
- export let yEnd;
23
- export let zStart;
24
- export let zEnd;
31
+ <Axes limX={[0, 5]} limY={[-3, 3]} >
32
+ <Segments {xStart} {yStart} {zStart} {xEnd} {yEnd} {zEnd} lineColor="red" lineType={3} />
33
+ </Axes>
34
+ ```
35
+ -->
36
+ <script>
37
+ import { cbind } from 'mdatools/arrays';
38
+ import { getContext } from 'svelte';
39
+ import { Colors, LINE_STYLES } from '../constants';
40
+ import { checkCoords, transform3D } from '../methods';
25
41
 
26
- export let lineColor = Colors.PRIMARY;
27
- export let lineType = 1;
28
- export let lineWidth = 1;
29
42
 
30
- // get axes context and reactive variables needed to compute coordinates
31
- const axes = getContext('axes');
32
- const scale = axes.scale;
33
- const tM = axes.tM;
34
- const isOk = axes.isOk;
43
+ let {
44
+ xStart,
45
+ xEnd,
46
+ yStart,
47
+ yEnd,
48
+ zStart,
49
+ zEnd,
50
+ lineColor = Colors.PRIMARY,
51
+ lineType = 1,
52
+ lineWidth = 1,
53
+ title = '',
54
+ } = $props();
35
55
 
36
- let x1, y1, x2, y2 = undefined;
37
- $: {
38
- if ($isOk) {
39
56
 
40
- [x1, y1] = axes.transform(
41
- cbind(
42
- checkCoords(xStart, 'Segments'),
43
- checkCoords(yStart, 'Segments'),
44
- checkCoords(zStart, 'Segments')
45
- ), $tM
46
- );
57
+ // check user defined coordinates
58
+ const ux1 = $derived(checkCoords(xStart, 'Segments (3D)'));
59
+ const uy1 = $derived(ux1 ? checkCoords(yStart, 'Segments (3D)', ux1.length) : null);
60
+ const uz1 = $derived(uy1 ? checkCoords(zStart, 'Segments (3D)', ux1.length) : null);
47
61
 
48
- [x2, y2] = axes.transform(
49
- cbind(
50
- checkCoords(xEnd, 'Segments'),
51
- checkCoords(yEnd, 'Segments'),
52
- checkCoords(zEnd, 'Segments')
53
- ), $tM
54
- );
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);
55
65
 
56
- }
57
- }
66
+ // combine world coordinates to matrices
67
+ const uW1 = $derived(ux1 && uy1 && uz1 ? cbind(ux1, uy1, uz1) : null);
68
+ const uW2 = $derived(ux2 && uy2 && uz2 ? cbind(ux2, uy2, uz2) : null);
69
+
70
+ // get axes context and compute screen coordinates
71
+ const axes = getContext('axes');
72
+ const s1 = $derived(uW1 ? transform3D(uW1, axes.tM()) : null);
73
+ const s2 = $derived(uW2 ? transform3D(uW2, axes.tM()) : null);
58
74
 
59
- $: lineStyleStr = `stroke:${lineColor};stroke-width: ${lineWidth}px;stroke-dasharray:${axes.LINE_STYLES[$scale][lineType-1]}`;
75
+ const lineStyleStr = $derived(`stroke:${lineColor};stroke-width: ${lineWidth}px;stroke-dasharray:${LINE_STYLES[axes.scale()][lineType-1]}`);
60
76
  </script>
61
77
 
62
- <g class="series series_segment" data-title="{title}" style={lineStyleStr}>
63
- {#if $isOk && x1 !== undefined && y1 !== undefined && x2 !== undefined && y2 !== undefined}
64
- {#each x1 as v, i}
65
- <line vector-effect="non-scaling-stroke" x1={x1[i]} x2={x2[i]} y1={y1[i]} y2={y2[i]} />
78
+ <g class="series series-segments" data-title={title} style={lineStyleStr}>
79
+ {#if s1 && s2}
80
+ {#each s1.x as v, i}
81
+ <line x1={s1.x[i]} x2={s2.x[i]} y1={s1.y[i]} y2={s2.y[i]} />
66
82
  {/each}
67
83
  {/if}
68
84
  </g>
@@ -1,72 +1,86 @@
1
- <script>
2
- /****************************************************
3
- * TextLabels for 3D plots *
4
- * ----------------------- *
5
- * shows a series of text labels on the plot *
6
- *****************************************************/
1
+ <!--
2
+ @component Adds a series of text labels at given coordinates.
3
+
4
+ Main properties:
5
+ - `xValues` - array of vector with x-coordinates of the points.
6
+ - `yValues` - array of vector with y-coordinates of the points.
7
+ - `zValues` - array of vector with z-coordinates of the points.
8
+ - `labels` - array with labels.
9
+ - `faceColor` - face (fill) color of the markers, default: `'transparent'`.
10
+ - `borderColor` - color markers' borders, default: `Colors.PRIMARY`.
11
+ - `borderWidth` - width (thickness) of the markers' borders in pixels, default: `1`.
12
+ - `textSize` - size of the markers in em, default: `1`.
13
+ - `title` - title of the line series group.
14
+
15
+ Example:
16
+ ```jsx
17
+ <script>
18
+ import { Axes, TextLabels } from 'svelte-plots-basic/3d';
19
+
20
+ const xValues = [-3, -2, -1, 0, 1, 2, 3];
21
+ const yValues = [ 9, 4, 1, 0, 1, 4, 9];
22
+ const zValues = [-3, -2, -1, 0, 1, 2, 3];
23
+ const labels = ["A", "B", "C", "D", "E", "F", "G"];
24
+ </script>
7
25
 
26
+ <Axes limX={[-4, 4]} limY={[-2, 10]} limZ={[-4, 4]}>
27
+ <TextLabels {xValues} {yValues} {zValues} {labels} />
28
+ </Axes>
29
+ ```
30
+ -->
31
+ <script>
8
32
  import { cbind } from 'mdatools/arrays';
9
33
  import { getContext } from 'svelte';
10
- import { Colors } from '../Colors';
11
- import { checkCoords } from '../Utils';
12
-
34
+ import { Colors } from '../constants';
35
+ import { checkCoords, transform3D } from '../methods';
13
36
 
14
- /*****************************************/
15
- /* Input parameters */
16
- /*****************************************/
37
+ let {
38
+ title = '',
39
+ xValues,
40
+ yValues,
41
+ zValues,
42
+ labels,
43
+ faceColor = Colors.PRIMARY_TEXT,
44
+ borderColor = 'transparent',
45
+ borderWidth = 0,
46
+ textSize = 1,
47
+ className = 'series-textlabel',
48
+ fontWeight = 'normal'
49
+ } = $props();
17
50
 
18
- export let title = '';
19
- export let xValues;
20
- export let yValues;
21
- export let zValues;
22
- export let labels;
23
51
 
24
- export let faceColor = Colors.PRIMARY_TEXT;
25
- export let borderColor = 'transparent';
26
- export let borderWidth = 0;
27
- export let textSize = 1;
28
- export let className = 'series_textlabel';
52
+ const ux = $derived(checkCoords(xValues, 'TextLabels (3D)'));
53
+ const uy = $derived(ux ? checkCoords(yValues, 'TextLabels (3D)', ux.length) : null);
54
+ const uz = $derived(uy ? checkCoords(zValues, 'TextLabels (3D)', uy.length) : null);
55
+ const U = $derived(ux && uy && uz ? cbind(ux, uy, uz) : null);
29
56
 
57
+ const l = $derived.by(() => {
58
+ if(Array.isArray(labels) && labels.length !== ux.length ) {
59
+ console.error('TextLabels: labels provided as an array should have the same number of elements as number of coordinates.');
60
+ return null;
61
+ }
62
+ return labels;
63
+ });
30
64
 
31
65
  // get axes context and reactive variables needed to compute coordinates
32
66
  const axes = getContext('axes');
33
- const tM = axes.tM;
34
- const isOk = axes.isOk;
35
-
36
- // compute screen coordinates
37
- let x, y = undefined;
38
- $: {
39
- if ($isOk) {
40
-
41
- [x, y] = axes.transform(
42
- cbind(
43
- checkCoords(xValues, 'TextValues'),
44
- checkCoords(yValues, 'TextValues'),
45
- checkCoords(zValues, 'TextValues')
46
- ), $tM
47
- );
48
-
49
- if (Array.isArray(labels) && labels.length !== x.length ) {
50
- throw('TextLabels: number of elements in "labels" does not match number of coordinates.')
51
- }
52
- }
53
- }
67
+ const s = $derived(U && l ? transform3D(U, axes.tM()) : null);
54
68
 
55
69
  // styles for the elements
56
- $: textStyleStr = `dominant-baseline:middle;fill:${faceColor};stroke-width:${borderWidth}px;stroke:${borderColor};
57
- font-size:${textSize}em; text-anchor:middle;`;
70
+ const textStyleStr = $derived(`dominant-baseline:middle;fill:${faceColor};stroke-width:${borderWidth}px;stroke:${borderColor};
71
+ font-size:${textSize}em; text-anchor:middle;font-weight:${fontWeight}`);
58
72
  </script>
59
73
 
60
- {#if $isOk && x !== undefined && y !== undefined}
74
+ {#if s}
61
75
  <g class="series {className}" title={title} style={textStyleStr} >
62
76
 
63
77
  {#if typeof labels === 'string'}
64
- {#each x as v, i}
65
- <text data-id={i} x={x[i]} y={y[i]} dx={0} dy={0}>{@html labels}</text>
78
+ {#each s.x as v, i}
79
+ <text data-id={i} x={s.x[i]} y={s.y[i]} dx={0} dy={0}>{@html l}</text>
66
80
  {/each}
67
81
  {:else}
68
82
  {#each x as v, i}
69
- <text data-id={i} x={x[i]} y={y[i]} dx={0} dy={0}>{@html labels[i]}</text>
83
+ <text data-id={i} x={s.x[i]} y={s.y[i]} dx={0} dy={0}>{@html l[i]}</text>
70
84
  {/each}
71
85
  {/if}
72
86
  </g>
@@ -1,123 +1,46 @@
1
+ <!--
2
+ @component Adds x-axis with ticks, label, etc.
3
+
4
+ Main properties:
5
+ - `label` - text label for the axis (optional).
6
+ - `showGrid` - logical, show or not vertical grid lines, default: `false`.
7
+ - `ticks` - array or vector with tick positions (by default will be generated automatically based on `limX`).
8
+ - `tickLabels` - array with tick labels to show at each tick (by default will be generated automatically).
9
+ - `lineColor` - color of axis line, default: `Colors.DARKGRAY`.
10
+ - `gridColor` - color of axis grid line, default: `Colors.MIDDLEGRAY`.
11
+ - `textColor` - color of axis text labels, default: `Colors.DARKGRAY`.
12
+
13
+ Example:
14
+ ```jsx
15
+ <script>
16
+ import {Axes, XAxis} from 'svelte-plots-basic/3d';
17
+ </script>
18
+ <Axes>
19
+ // all other plotting components are here
20
+ <XAxis label="X" showGrid={true} />
21
+ </Axes>
22
+ ```
23
+ -->
1
24
  <script>
2
- /****************************************************
3
- * X-Axis for 3D plots *
4
- * -------------------- *
5
- * shows x-axis and its elements (ticks, grid, etc.) *
6
- *****************************************************/
7
-
8
- import { cbind, matrix, Vector } from 'mdatools/arrays';
9
25
  import { getContext } from 'svelte';
10
- import { Colors } from '../Colors';
11
- import { getAxisTicks } from '../Utils.js';
12
- import Axis from './Axis.svelte';
13
-
14
-
15
- /*****************************************/
16
- /* Input parameters */
17
- /*****************************************/
18
-
19
- export let slot = 'xaxis'; // slot the component must be placed in
20
- export let ticks = undefined; // vector with numeric tick positions in plot units
21
- export let tickLabels = ticks; // vector with labels for each tick
22
- export let showGrid = false; // logical, show or not grid lines
23
- export let title = ''; // axis title
24
-
25
- export let lineColor = Colors.DARKGRAY;
26
- export let gridColor = Colors.MIDDLEGRAY;
27
- export let textColor = Colors.DARKGRAY;
26
+ import { Colors } from '../constants';
28
27
 
28
+ let {
29
+ ticks, // vector with numeric tick positions in plot units
30
+ tickLabels = ticks, // vector with labels for each tick
31
+ showGrid = false, // logical, show or not grid lines
32
+ label = '', // axis label
33
+ lineColor = Colors.DARKGRAY,
34
+ gridColor = Colors.MIDDLEGRAY,
35
+ textColor = Colors.DARKGRAY,
36
+ } = $props();
29
37
 
30
- /*****************************************/
31
- /* Component code */
32
- /*****************************************/
33
-
34
- if (slot !== 'xaxis') {
35
- throw('Component XAxis must have "slot=\'xaxis\'" attribute.');
36
- }
37
38
 
38
39
  // get axes context and adjust x margins
39
40
  const axes = getContext('axes');
40
-
41
- // get reactive variables needed to compute coordinates
42
- const xLim = axes.xLim;
43
- const yLim = axes.yLim;
44
- const zLim = axes.zLim;
45
- const scale = axes.scale;
46
- const isOk = axes.isOk;
47
-
48
- // prepare variables for coordinates
49
- let titleCoords = [];
50
- let grid1 = [];
51
- let grid2 = [];
52
- let axisLine = [];
53
- let tickCoords = [];
54
-
55
- // compute tick x-coordinates
56
- $: if ($isOk) {
57
- const dX = ($xLim[1] - $xLim[0]) / 100; // 1% of axis size
58
- const ticksX = getAxisTicks(ticks, $xLim, axes.TICK_NUM[$scale], true);
59
- const tickNum = ticksX.length;
60
-
61
- // compute tick y-coordinates (middle, up and bottom)
62
- const dY = ($yLim[1] - $yLim[0]) / 100; // 1% of axis size
63
- const ticksY = Vector.fill($yLim[0], tickNum);
64
- const ticksY1 = ticksY.subtract(dY * 1.5);
65
- const ticksY2 = ticksY.add(dY * 1.5);
66
- const ticksY3 = ticksY.subtract(dY * 5);
67
-
68
- // tick z-coordinates (middle, up and bottom)
69
- const dZ = ($zLim[1] - $zLim[0]) / 100; // 1% of axis size
70
- const ticksZ = Vector.fill($zLim[0], tickNum);
71
- const ticksZ1 = ticksZ.subtract(dZ * 1.5);
72
- const ticksZ2 = ticksZ.add(dZ * 1.5);
73
- const ticksZ3 = ticksZ.subtract(dZ * 2);
74
-
75
- // coordinates for the ends of grid
76
- const gridYEnd = Vector.fill($yLim[1], tickNum);
77
- const gridZEnd = Vector.fill($zLim[1], tickNum);
78
-
79
- // tick labels
80
- tickLabels = (ticks === undefined || tickLabels === undefined) ? ticksX.v : tickLabels;
81
- if (tickLabels.length !== ticksX.length) {
82
- throw Error('XAxis: "tickLabels" must be a array of the same size as ticks.');
83
- }
84
-
85
- // combine all coordinates together
86
- grid1 = [
87
- cbind(ticksX, ticksY, ticksZ),
88
- cbind(ticksX, gridYEnd, ticksZ)
89
- ];
90
-
91
- grid2 = [
92
- cbind(ticksX, ticksY, ticksZ),
93
- cbind(ticksX, ticksY2, gridZEnd)
94
- ];
95
-
96
- axisLine = [
97
- matrix([$xLim[0], $yLim[0], $zLim[0]], 1, 3),
98
- matrix([$xLim[1], $yLim[0], $zLim[0]], 1, 3)
99
- ]
100
-
101
- tickCoords = [
102
- cbind(ticksX, ticksY, ticksZ), // middle point
103
- cbind(ticksX, ticksY2, ticksZ), // middle point with positive shift along Y
104
- cbind(ticksX, ticksY, ticksZ2), // middle point with positive shift along Z
105
- cbind(ticksX, ticksY1, ticksZ1), // middle point with negative shift along Y and Z
106
- cbind(ticksX, ticksY3, ticksZ3) // middle point with negative shift along Y and Z for ticks
107
- ];
108
-
109
- // here we do not need to make a matrix as the three values will be used as vectors
110
- titleCoords = [
111
- [$xLim[1] + 3 * dX], [$yLim[0] - 2 * dY], [$zLim[0] - 2 * dZ]
112
- ];
113
- }
41
+ $effect(() => {
42
+ axes.setXAxis({show: true, ticks, tickLabels, showGrid, label, lineColor, gridColor, textColor});
43
+ });
114
44
  </script>
115
45
 
116
- {#if $isOk && axisLine.length > 0}
117
- <Axis
118
- className="mdaplot__xaxis"
119
- {title} {lineColor} {gridColor} {textColor} {titleCoords}
120
- {showGrid} {grid1} {grid2} {axisLine} {tickCoords} {tickLabels}
121
- />
122
- {/if}
123
46
 
@@ -1,123 +1,46 @@
1
+ <!--
2
+ @component Adds y-axis with ticks, label, etc.
3
+
4
+ Main properties:
5
+ - `label` - text label for the axis (optional).
6
+ - `showGrid` - logical, show or not vertical grid lines, default: `false`.
7
+ - `ticks` - array or vector with tick positions (by default will be generated automatically based on `limX`).
8
+ - `tickLabels` - array with tick labels to show at each tick (by default will be generated automatically).
9
+ - `lineColor` - color of axis line, default: `Colors.DARKGRAY`.
10
+ - `gridColor` - color of axis grid line, default: `Colors.MIDDLEGRAY`.
11
+ - `textColor` - color of axis text labels, default: `Colors.DARKGRAY`.
12
+
13
+ Example:
14
+ ```jsx
15
+ <script>
16
+ import {Axes, YAxis} from 'svelte-plots-basic/3d';
17
+ </script>
18
+ <Axes>
19
+ // all other plotting components are here
20
+ <YAxis label="Y" showGrid={true} />
21
+ </Axes>
22
+ ```
23
+ -->
1
24
  <script>
2
- /****************************************************
3
- * Y-Axis for 3D plots *
4
- * -------------------- *
5
- * shows y-axis and its elements (ticks, grid, etc.) *
6
- *****************************************************/
7
-
8
- import { cbind, matrix, Vector } from 'mdatools/arrays';
9
25
  import { getContext } from 'svelte';
10
- import { Colors } from '../Colors';
11
- import { getAxisTicks } from '../Utils.js';
12
- import Axis from './Axis.svelte';
13
-
14
-
15
- /*****************************************/
16
- /* Input parameters */
17
- /*****************************************/
18
-
19
- export let slot = 'yaxis'; // slot the component must be placed in
20
- export let ticks = undefined; // vector with numeric tick positions in plot units
21
- export let tickLabels = ticks; // vector with labels for each tick
22
- export let showGrid = false; // logical, show or not grid lines
23
- export let title = ''; // axis title
24
-
25
- export let lineColor = Colors.DARKGRAY;
26
- export let gridColor = Colors.MIDDLEGRAY;
27
- export let textColor = Colors.DARKGRAY;
26
+ import { Colors } from '../constants';
28
27
 
28
+ let {
29
+ ticks, // vector with numeric tick positions in plot units
30
+ tickLabels = ticks, // vector with labels for each tick
31
+ showGrid = false, // logical, show or not grid lines
32
+ label = '', // axis label
33
+ lineColor = Colors.DARKGRAY,
34
+ gridColor = Colors.MIDDLEGRAY,
35
+ textColor = Colors.DARKGRAY,
36
+ } = $props();
29
37
 
30
- /*****************************************/
31
- /* Component code */
32
- /*****************************************/
33
-
34
- if (slot !== 'yaxis') {
35
- throw('Component YAxis must have "slot=\'yaxis\'" attribute.');
36
- }
37
38
 
38
39
  // get axes context and adjust x margins
39
40
  const axes = getContext('axes');
40
-
41
- // get reactive variables needed to compute coordinates
42
- const xLim = axes.xLim;
43
- const yLim = axes.yLim;
44
- const zLim = axes.zLim;
45
- const scale = axes.scale;
46
- const isOk = axes.isOk;
47
-
48
- // prepare variables for coordinates
49
- let titleCoords = [];
50
- let grid1 = [];
51
- let grid2 = [];
52
- let axisLine = [];
53
- let tickCoords = [];
54
-
55
- // compute tick x-coordinates
56
- $: if ($isOk) {
57
- const dY = ($yLim[1] - $yLim[0]) / 100; // 1% of axis size
58
- const ticksY = getAxisTicks(ticks, $yLim, axes.TICK_NUM[$scale], true);
59
- const tickNum = ticksY.length;
60
-
61
- // compute tick y-coordinates (middle, up and bottom)
62
- const dX = ($xLim[1] - $xLim[0]) / 100; // 1% of axis size
63
- const ticksX = Vector.fill($xLim[0], tickNum);
64
- const ticksX1 = ticksX.subtract(dX * 1.5);
65
- const ticksX2 = ticksX.add(dX * 1.5);
66
- const ticksX3 = ticksX.subtract(dX * 3);
67
-
68
- // tick z-coordinates (middle, up and bottom)
69
- const dZ = ($zLim[1] - $zLim[0]) / 100; // 1% of axis size
70
- const ticksZ = Vector.fill($zLim[0], tickNum);
71
- const ticksZ1 = ticksZ.subtract(dZ * 1.5);
72
- const ticksZ2 = ticksZ.add(dZ * 1.5);
73
- const ticksZ3 = ticksZ.subtract(dZ * 2);
74
-
75
- // coordinates for the ends of grid
76
- const gridXEnd = Vector.fill($xLim[1], tickNum);
77
- const gridZEnd = Vector.fill($zLim[1], tickNum);
78
-
79
- // tick labels
80
- tickLabels = (ticks === undefined || tickLabels === undefined) ? ticksY.v : tickLabels;
81
- if (tickLabels.length !== ticksY.length) {
82
- throw Error('YAxis: "tickLabels" must be a array of the same size as ticks.');
83
- }
84
-
85
- // combine all coordinates together
86
- grid1 = [
87
- cbind(ticksX, ticksY, ticksZ),
88
- cbind(gridXEnd, ticksY, ticksZ)
89
- ];
90
-
91
- grid2 = [
92
- cbind(ticksX, ticksY, ticksZ),
93
- cbind(ticksX, ticksY, gridZEnd)
94
- ];
95
-
96
- axisLine = [
97
- matrix([$xLim[0], $yLim[0], $zLim[0]], 1, 3),
98
- matrix([$xLim[0], $yLim[1], $zLim[0]], 1, 3)
99
- ]
100
-
101
- tickCoords = [
102
- cbind(ticksX, ticksY, ticksZ), // middle point
103
- cbind(ticksX2, ticksY, ticksZ), // middle point with positive shift along X
104
- cbind(ticksX, ticksY, ticksZ2), // middle point with positive shift along Z
105
- cbind(ticksX1, ticksY, ticksZ1), // middle point with negative shift along X and Z
106
- cbind(ticksX3, ticksY, ticksZ3) // middle point with negative shift along X and Z for ticks
107
- ];
108
-
109
- // here we do not need to make a matrix as the three values will be used as vectors
110
- titleCoords = [
111
- [$xLim[0] - 2 * dX], [$yLim[1] + 3 * dY], [$zLim[0] - 2 * dZ]
112
- ];
113
- }
41
+ $effect(() => {
42
+ axes.setYAxis({show: true, ticks, tickLabels, showGrid, label, lineColor, gridColor, textColor});
43
+ });
114
44
  </script>
115
45
 
116
- {#if $isOk && axisLine.length > 0}
117
- <Axis
118
- className="mdaplot__yaxis"
119
- {title} {lineColor} {gridColor} {textColor} {titleCoords}
120
- {showGrid} {grid1} {grid2} {axisLine} {tickCoords} {tickLabels}
121
- />
122
- {/if}
123
46