@communitiesuk/svelte-component-library 0.1.19-beta.24 → 0.1.19-beta.26

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.
@@ -56,6 +56,7 @@
56
56
  showGridlines = false,
57
57
  showTickMarks = false,
58
58
  strokeWidth = 2,
59
+ niceTicks = true,
59
60
  }: {
60
61
  chartHeight?: number;
61
62
  chartWidth?: number;
@@ -83,6 +84,7 @@
83
84
  strokeWidth?: Number;
84
85
  showGridlines?: Boolean;
85
86
  showTickMarks?: Boolean;
87
+ niceTicks?: Boolean;
86
88
  } = $props();
87
89
 
88
90
  // --- Helpers to compute default domain/range when not supplied ---
@@ -156,6 +158,7 @@
156
158
  {showGridlines}
157
159
  {showTickMarks}
158
160
  {strokeWidth}
161
+ {niceTicks}
159
162
  />
160
163
  {/key}
161
164
  {/if}
@@ -31,6 +31,7 @@ type $$ComponentProps = {
31
31
  strokeWidth?: Number;
32
32
  showGridlines?: Boolean;
33
33
  showTickMarks?: Boolean;
34
+ niceTicks?: Boolean;
34
35
  };
35
36
  declare const Axis: import("svelte").Component<$$ComponentProps, {}, "ticksArray" | "chartWidth">;
36
37
  type Axis = ReturnType<typeof Axis>;
@@ -36,6 +36,7 @@
36
36
 
37
37
  strokeWidth = 2,
38
38
  labelFormatter = undefined as LabelFormatter | undefined,
39
+ niceTicks = true,
39
40
  }: {
40
41
  ticksArray?: number[]; // bindable
41
42
  chartWidth: number;
@@ -54,6 +55,7 @@
54
55
 
55
56
  strokeWidth?: number;
56
57
  labelFormatter?: LabelFormatter;
58
+ niceTicks?: Boolean;
57
59
  } = $props();
58
60
  function axisValue(fn: any, tick: number): number {
59
61
  // Try single-call first: axisFunction(tick)
@@ -142,7 +144,9 @@
142
144
  );
143
145
 
144
146
  let rawTicks = $derived(
145
- generateTicks(min, max, computedTickCount, floor, ceiling),
147
+ niceTicks
148
+ ? generateTicks(min, max, computedTickCount, floor, ceiling)
149
+ : [min, max],
146
150
  );
147
151
 
148
152
  let ticksOrdered = $derived(
@@ -23,6 +23,7 @@ type $$ComponentProps = {
23
23
  showTickMarks?: Boolean;
24
24
  strokeWidth?: number;
25
25
  labelFormatter?: LabelFormatter;
26
+ niceTicks?: Boolean;
26
27
  };
27
28
  declare const Ticks: import("svelte").Component<$$ComponentProps, {}, "ticksArray">;
28
29
  type Ticks = ReturnType<typeof Ticks>;
@@ -11,6 +11,7 @@
11
11
  markerRect = undefined,
12
12
  tooltipSnippet,
13
13
  labelText = undefined,
14
+ yOffset = 20,
14
15
  } = $props();
15
16
 
16
17
  let textDimensions = $state();
@@ -31,7 +32,7 @@ left: {markerRect?.x +
31
32
  style="position:absolute; left: {markerRect?.x - textDimensions?.width / 2}px;
32
33
  top: {markerRect?.y -
33
34
  textDimensions?.height -
34
- 20}px; pointer-events: none"
35
+ yOffset}px; pointer-events: none"
35
36
  bind:contentRect={textDimensions}
36
37
  >
37
38
  {#if tooltipSnippet === undefined}
@@ -15,6 +15,7 @@ declare const ValueLabel: import("svelte").Component<{
15
15
  markerRect?: any;
16
16
  tooltipSnippet: any;
17
17
  labelText?: any;
18
+ yOffset?: number;
18
19
  }, {}, "">;
19
20
  type $$ComponentProps = {
20
21
  activeMarkerId: any;
@@ -28,4 +29,5 @@ type $$ComponentProps = {
28
29
  markerRect?: any;
29
30
  tooltipSnippet: any;
30
31
  labelText?: any;
32
+ yOffset?: number;
31
33
  };
@@ -96,6 +96,7 @@
96
96
  labelFormatter = (tick, index, ticksArrayLength) => {
97
97
  return tick;
98
98
  },
99
+ niceTicks = true,
99
100
  } = $props();
100
101
 
101
102
  let xTicks = $state([]);
@@ -478,6 +479,7 @@
478
479
  {showTickMarks}
479
480
  {showGridlines}
480
481
  {labelFormatter}
482
+ {niceTicks}
481
483
  ></Axis>
482
484
  {/if}
483
485
  {#if showAverage}
@@ -576,6 +578,7 @@
576
578
  {showTickMarks}
577
579
  {showGridlines}
578
580
  {labelFormatter}
581
+ {niceTicks}
579
582
  ></Axis>
580
583
  {/if}
581
584
  </div>
@@ -54,6 +54,7 @@ declare const PositionChart: import("svelte").Component<{
54
54
  showTickMarks?: boolean;
55
55
  showGridlines?: boolean;
56
56
  labelFormatter?: Function;
57
+ niceTicks?: boolean;
57
58
  }, {}, "chartWidth">;
58
59
  type $$ComponentProps = {
59
60
  value?: any;
@@ -106,4 +107,5 @@ type $$ComponentProps = {
106
107
  showTickMarks?: boolean;
107
108
  showGridlines?: boolean;
108
109
  labelFormatter?: Function;
110
+ niceTicks?: boolean;
109
111
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@communitiesuk/svelte-component-library",
3
- "version": "0.1.19-beta.24",
3
+ "version": "0.1.19-beta.26",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/communitiesuk/mhclg_svelte_component_library.git"