@communitiesuk/svelte-component-library 0.1.17 → 0.2.0-alpha.2

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 (97) hide show
  1. package/README.md +116 -98
  2. package/dist/assets/css/base.css +9 -0
  3. package/dist/assets/css/code-block.css +116 -0
  4. package/dist/assets/css/components.css +47 -0
  5. package/dist/assets/css/fonts.css +19 -0
  6. package/dist/assets/css/govuk-additional.css +142 -0
  7. package/dist/assets/css/govuk-frontend.min.css +2 -2
  8. package/dist/assets/css/moduk.css +1 -0
  9. package/dist/assets/css/moj-frontend.min copy.css +4108 -0
  10. package/dist/assets/css/moj-frontend.min.css +2 -0
  11. package/dist/assets/css/moj-frontend.min.css.map +1 -0
  12. package/dist/assets/css/utilities.css +0 -0
  13. package/dist/assets/images/govuk-crest.svg +1 -1
  14. package/dist/assets/js/govuk-frontend.min.js +1 -0
  15. package/dist/assets/js/moj-frontend.min.js +1 -0
  16. package/dist/assets/rebrand/images/favicon.ico +0 -0
  17. package/dist/assets/rebrand/images/favicon.svg +1 -0
  18. package/dist/assets/rebrand/images/govuk-crest.svg +1 -0
  19. package/dist/assets/rebrand/images/govuk-icon-180.png +0 -0
  20. package/dist/assets/rebrand/images/govuk-icon-192.png +0 -0
  21. package/dist/assets/rebrand/images/govuk-icon-512.png +0 -0
  22. package/dist/assets/rebrand/images/govuk-icon-mask.svg +1 -0
  23. package/dist/assets/rebrand/images/govuk-opengraph-image.png +0 -0
  24. package/dist/assets/rebrand/manifest.json +39 -0
  25. package/dist/components/data-vis/line-chart/Line.svelte +48 -41
  26. package/dist/components/data-vis/line-chart/Line.svelte.d.ts +6 -4
  27. package/dist/components/data-vis/line-chart/LineChart.svelte +145 -36
  28. package/dist/components/data-vis/line-chart/LineChart.svelte.d.ts +25 -9
  29. package/dist/components/data-vis/line-chart/Lines.svelte +10 -23
  30. package/dist/components/data-vis/line-chart/Lines.svelte.d.ts +8 -4
  31. package/dist/components/data-vis/line-chart/Marker.svelte +31 -5
  32. package/dist/components/data-vis/line-chart/Marker.svelte.d.ts +6 -2
  33. package/dist/components/data-vis/line-chart/SeriesLabel.svelte +7 -8
  34. package/dist/components/data-vis/line-chart/SeriesLabel.svelte.d.ts +2 -2
  35. package/dist/components/data-vis/line-chart/ValueLabel.svelte +26 -34
  36. package/dist/components/data-vis/line-chart/ValueLabel.svelte.d.ts +8 -4
  37. package/dist/components/data-vis/map/Map.svelte +299 -71
  38. package/dist/components/data-vis/map/Map.svelte.d.ts +39 -12
  39. package/dist/components/data-vis/map/NonStandardControls.svelte +10 -1
  40. package/dist/components/data-vis/map/NonStandardControls.svelte.d.ts +12 -11
  41. package/dist/components/data-vis/map/Tooltip.svelte +3 -4
  42. package/dist/components/data-vis/map/Tooltip.svelte.d.ts +0 -2
  43. package/dist/components/data-vis/map/mapUtils.d.ts +2 -0
  44. package/dist/components/data-vis/map/mapUtils.js +50 -0
  45. package/dist/components/data-vis/table/Table.svelte +28 -40
  46. package/dist/components/data-vis/table/Table.svelte.d.ts +0 -2
  47. package/dist/components/layout/Breadcrumbs.svelte +10 -12
  48. package/dist/components/layout/Breadcrumbs.svelte.d.ts +1 -0
  49. package/dist/components/layout/Footer.svelte +69 -4
  50. package/dist/components/layout/Footer.svelte.d.ts +3 -0
  51. package/dist/components/layout/Header.svelte +56 -16
  52. package/dist/components/layout/Header.svelte.d.ts +1 -0
  53. package/dist/components/layout/InternalHeader.svelte +155 -150
  54. package/dist/components/layout/InternalHeader.svelte.d.ts +1 -0
  55. package/dist/components/ui/Button.svelte +78 -4
  56. package/dist/components/ui/Button.svelte.d.ts +2 -0
  57. package/dist/components/ui/CookieBanner.svelte +356 -0
  58. package/dist/components/ui/CookieBanner.svelte.d.ts +18 -0
  59. package/dist/components/ui/FilterPanel.svelte +167 -158
  60. package/dist/components/ui/FilterPanel.svelte.d.ts +2 -0
  61. package/dist/components/ui/Masthead.svelte +35 -23
  62. package/dist/components/ui/Masthead.svelte.d.ts +2 -0
  63. package/dist/components/ui/PostcodeOrAreaSearch.svelte +200 -0
  64. package/dist/components/ui/PostcodeOrAreaSearch.svelte.d.ts +37 -0
  65. package/dist/components/ui/Search.svelte +2 -2
  66. package/dist/components/ui/SearchAutocomplete.svelte +104 -14
  67. package/dist/components/ui/SearchAutocomplete.svelte.d.ts +4 -0
  68. package/dist/data/IMD2019.json +32846 -0
  69. package/dist/data/places.csv +20039 -0
  70. package/dist/data/places.json +100192 -0
  71. package/dist/data/svgFontDimensions.json +90 -0
  72. package/dist/data/testData.json +52632 -0
  73. package/dist/index.d.ts +2 -0
  74. package/dist/index.js +2 -0
  75. package/dist/package-wrapping/BaseInformation.svelte +0 -33
  76. package/dist/package-wrapping/SidebarContainer.svelte +0 -7
  77. package/dist/utils/area-search/geoConfig.d.ts +435 -0
  78. package/dist/utils/area-search/geoConfig.js +291 -0
  79. package/dist/utils/cookiesNavigation.d.ts +44 -0
  80. package/dist/utils/cookiesNavigation.js +63 -0
  81. package/dist/utils/data-transformations/convert-csv-to-json-proper.cjs +88 -0
  82. package/dist/utils/data-transformations/convert-csv-to-json-proper.d.cts +1 -0
  83. package/dist/utils/data-transformations/convertCSV.d.ts +6 -0
  84. package/dist/utils/data-transformations/convertCSV.js +40 -21
  85. package/dist/utils/text-string-conversion/textStringConversion.d.ts +6 -0
  86. package/dist/utils/text-string-conversion/textStringConversion.js +10 -0
  87. package/package.json +18 -7
  88. package/dist/components/ui/Breadcrumbs.svelte +0 -198
  89. package/dist/components/ui/Breadcrumbs.svelte.d.ts +0 -24
  90. package/dist/components/ui/Footer.svelte +0 -171
  91. package/dist/components/ui/Footer.svelte.d.ts +0 -30
  92. package/dist/components/ui/Header.svelte +0 -43
  93. package/dist/components/ui/Header.svelte.d.ts +0 -7
  94. package/dist/components/ui/ServiceNavigation.svelte +0 -143
  95. package/dist/components/ui/ServiceNavigation.svelte.d.ts +0 -13
  96. package/dist/components/ui/SideNavigation.svelte +0 -346
  97. package/dist/components/ui/SideNavigation.svelte.d.ts +0 -25
@@ -1,5 +1,4 @@
1
1
  <script>
2
- import ValueLabel from "./ValueLabel.svelte";
3
2
  import Marker from "./Marker.svelte";
4
3
  import {
5
4
  curveBasis,
@@ -13,7 +12,6 @@
13
12
  } from "d3-shape";
14
13
 
15
14
  import { scaleLinear } from "d3-scale";
16
- import LineChart from "../../../../routes/playground/create-a-reactive-line-chart-camilla/local-lib/LineChart.svelte";
17
15
 
18
16
  let {
19
17
  dataArray,
@@ -36,7 +34,8 @@
36
34
  halo,
37
35
  chartBackgroundColor,
38
36
  invisibleStrokeWidth,
39
- interactive,
37
+ interactiveLines,
38
+ interactiveMarkers,
40
39
  onClickMarker,
41
40
  onMouseEnterMarker,
42
41
  onMouseLeaveMarker,
@@ -49,7 +48,7 @@
49
48
  activeMarkerId,
50
49
  series,
51
50
  y,
52
- id,
51
+ element,
53
52
  x,
54
53
  markers,
55
54
  markerFill,
@@ -87,55 +86,63 @@
87
86
  </marker>
88
87
  </defs>
89
88
 
90
- <g
91
- data-id={dataId}
92
- {id}
93
- onclick={interactive ? (e) => onClickSeries(dataId, tier) : null}
94
- onmouseenter={interactive ? (e) => onMouseEnterSeries(dataId, tier) : null}
95
- onmouseleave={interactive ? (e) => onMouseLeaveSeries(dataId, tier) : null}
96
- role="button"
97
- tabindex="0"
98
- onkeydown={(e) => e.key === "Enter" && onClickSeries(e, dataArray)}
99
- {opacity}
100
- pointer-events={interactive ? null : "none"}
101
- >
102
- {#if includeArea}
103
- <path d={areaFunction(dataArray)} fill={areaFillColor}></path>
104
- {/if}
105
- <path
106
- d={linePath}
107
- fill="none"
108
- stroke="invisible"
109
- stroke-width={invisibleStrokeWidth}
110
- pointer-events={interactive ? "stroke" : "none"}
111
- ></path>
112
- {#if halo}
89
+ <g data-id={"series-" + dataId} {opacity}>
90
+ <g
91
+ data-id={"line-" + dataId}
92
+ onclick={interactiveLines ? (e) => onClickSeries(dataId, tier) : null}
93
+ onmouseenter={interactiveLines
94
+ ? (e) => onMouseEnterSeries(dataId, tier)
95
+ : null}
96
+ onmouseleave={interactiveLines
97
+ ? (e) => onMouseLeaveSeries(dataId, tier)
98
+ : null}
99
+ role="button"
100
+ tabindex="0"
101
+ onkeydown={interactiveLines
102
+ ? (e) => e.key === "Enter" && onClickSeries(e, dataArray)
103
+ : null}
104
+ pointer-events={interactiveLines ? null : "none"}
105
+ >
106
+ {#if includeArea}
107
+ <path d={areaFunction(dataArray)} fill={areaFillColor}></path>
108
+ {/if}
109
+ <path
110
+ d={linePath}
111
+ fill="none"
112
+ stroke="invisible"
113
+ stroke-width={invisibleStrokeWidth}
114
+ pointer-events={interactiveLines ? "stroke" : "none"}
115
+ ></path>
116
+ {#if halo}
117
+ <path
118
+ d={linePath}
119
+ fill={pathFillColor}
120
+ stroke={chartBackgroundColor}
121
+ stroke-width={pathStrokeWidth * 1.2}
122
+ stroke-dasharray={pathStrokeDashArray}
123
+ pointer-events="none"
124
+ ></path>
125
+ {/if}
113
126
  <path
114
127
  d={linePath}
115
128
  fill={pathFillColor}
116
- stroke={chartBackgroundColor}
117
- stroke-width={pathStrokeWidth * 1.2}
129
+ stroke={pathStrokeColor}
130
+ stroke-width={pathStrokeWidth}
118
131
  stroke-dasharray={pathStrokeDashArray}
119
132
  pointer-events="none"
133
+ marker-start={`url(#${lineEnding}-${pathStrokeColor})`}
120
134
  ></path>
121
- {/if}
122
- <path
123
- d={linePath}
124
- fill={pathFillColor}
125
- stroke={pathStrokeColor}
126
- stroke-width={pathStrokeWidth}
127
- stroke-dasharray={pathStrokeDashArray}
128
- pointer-events="none"
129
- marker-start={`url(#${lineEnding}-${pathStrokeColor})`}
130
- ></path>
135
+ </g>
136
+
131
137
  {#if markers}
132
138
  <Marker
133
139
  {dataArray}
134
- {markerFill}
140
+ markerFill={markerFill ?? pathStrokeColor}
135
141
  {markerRadius}
136
142
  {markerShape}
137
143
  {markerStroke}
138
144
  {markerStrokeWidth}
145
+ {pathStrokeColor}
139
146
  {x}
140
147
  {y}
141
148
  {series}
@@ -144,7 +151,7 @@
144
151
  {onMouseEnterMarker}
145
152
  {onMouseLeaveMarker}
146
153
  {onClickMarker}
147
- {activeMarkerId}
154
+ {interactiveMarkers}
148
155
  ></Marker>
149
156
  {/if}
150
157
  </g>
@@ -24,7 +24,8 @@ declare const Line: import("svelte").Component<{
24
24
  halo: any;
25
25
  chartBackgroundColor: any;
26
26
  invisibleStrokeWidth: any;
27
- interactive: any;
27
+ interactiveLines: any;
28
+ interactiveMarkers: any;
28
29
  onClickMarker: any;
29
30
  onMouseEnterMarker: any;
30
31
  onMouseLeaveMarker: any;
@@ -33,7 +34,7 @@ declare const Line: import("svelte").Component<{
33
34
  activeMarkerId: any;
34
35
  series: any;
35
36
  y: any;
36
- id: any;
37
+ element: any;
37
38
  x: any;
38
39
  markers: any;
39
40
  markerFill: any;
@@ -64,7 +65,8 @@ type $$ComponentProps = {
64
65
  halo: any;
65
66
  chartBackgroundColor: any;
66
67
  invisibleStrokeWidth: any;
67
- interactive: any;
68
+ interactiveLines: any;
69
+ interactiveMarkers: any;
68
70
  onClickMarker: any;
69
71
  onMouseEnterMarker: any;
70
72
  onMouseLeaveMarker: any;
@@ -73,7 +75,7 @@ type $$ComponentProps = {
73
75
  activeMarkerId: any;
74
76
  series: any;
75
77
  y: any;
76
- id: any;
78
+ element: any;
77
79
  x: any;
78
80
  markers: any;
79
81
  markerFill: any;
@@ -5,17 +5,16 @@
5
5
 
6
6
  import { scaleLinear } from "d3-scale";
7
7
  import { curveLinear, line, area } from "d3-shape";
8
- import { highlight } from "../../../utils/syntax-highlighting/shikiHighlight";
8
+ import { highlight } from "./../../../utils/syntax-highlighting/shikiHighlight";
9
9
  import Lines from "./Lines.svelte";
10
+ import ValueLabel from "./ValueLabel.svelte";
10
11
 
11
12
  let {
12
- // Required
13
13
  series,
14
14
  y,
15
15
  x,
16
16
  lineChartData,
17
17
 
18
- // ask
19
18
  xFunction = (number) => {
20
19
  return scaleLinear()
21
20
  .domain([2015, 2022])
@@ -30,16 +29,18 @@
30
29
  .x((d) => xFunction(d[x]))
31
30
  .y((d) => yFunction(d[y]))
32
31
  .curve(curveLinear),
33
- labelText = "labelText",
34
-
35
- tooltipContent = "tooltipContent",
36
-
32
+ labelText = (dataArray) => {
33
+ return dataArray[series];
34
+ },
37
35
  onClickSeries = (series, tier) => {
38
- if (clickedSeries === dataId) {
36
+ if (clickedSeries === series) {
39
37
  clickedSeries = null;
38
+ hoveredSeries = null;
40
39
  } else {
41
40
  clickedSeries = series;
42
41
  clickedTier = tier;
42
+ hoveredSeries = series;
43
+ hoveredTier = tier;
43
44
  }
44
45
  },
45
46
  onMouseLeaveSeries = (series, tier) => {
@@ -56,23 +57,52 @@
56
57
  },
57
58
  onClickMarker = (event, marker, markerId) => {
58
59
  activeMarkerId = marker;
60
+ currentMousePosition = [event.screenX, event.screenY];
61
+ markerRect = rect;
59
62
  },
60
- onMouseEnterMarker = (event, marker, markerId) => {
63
+ onMouseEnterMarker = (event, marker, markerId, rect) => {
61
64
  activeMarkerId = marker;
65
+ if (container) {
66
+ const bounds = container.getBoundingClientRect();
67
+ currentMousePosition = [
68
+ // option for moving tooltip
69
+ event.clientX - bounds.left,
70
+ event.clientY - bounds.top,
71
+ ];
72
+ markerRect = {
73
+ // option for fixed tooltip
74
+ x: rect.x - bounds.left + rect.width / 2,
75
+ y: rect.y - bounds.top + rect.height / 2,
76
+ };
77
+ } else {
78
+ currentMousePosition = [event.clientX, event.clientY];
79
+ markerRect = rect;
80
+ }
62
81
  },
63
82
  onMouseLeaveMarker = (event, marker, dataId) => {
64
83
  activeMarkerId = null;
65
84
  },
66
85
 
67
86
  // Optional
87
+ currentMousePosition = undefined,
88
+ markerRect = undefined,
68
89
  clickedSeries = $bindable(undefined),
69
- hoveredSeries = undefined,
90
+ hoveredSeries = $bindable(undefined),
91
+ hoveredTier = $bindable(undefined),
92
+ clickedTier = $bindable(undefined),
70
93
  overrideLineParams = () => ({}),
71
- getLine = (key, el) => {
94
+ assignLinesToTiers = (tier, el) => {
95
+ if (tier === "hover") {
96
+ return [hoveredSeries].includes(el.areaCode);
97
+ }
98
+ if (tier === "clicked") {
99
+ return [clickedSeries].includes(el.areaCode);
100
+ }
72
101
  return true;
73
102
  },
74
103
  nothingSelected = true,
75
104
  svgWidth = $bindable(500),
105
+ container = $bindable(),
76
106
  svgHeight = 500,
77
107
  paddingTop = 50,
78
108
  paddingBottom = 50,
@@ -81,7 +111,7 @@
81
111
  activeMarkerId = undefined,
82
112
  chartBackgroundColor = "#f5f5f5",
83
113
  seriesLabels = $bindable(false),
84
- globalTierRules = {
114
+ globalTierParams = {
85
115
  otherTier: {},
86
116
  secondary: {
87
117
  opacity: nothingSelected ? 1 : 0.5,
@@ -94,11 +124,57 @@
94
124
  },
95
125
  tieredLineParams = {
96
126
  all: {},
127
+ hover: { pathStrokeWidth: 4 },
128
+ clicked: {
129
+ pathStrokeWidth: 5,
130
+ },
97
131
  },
132
+ tooltipSnippet = undefined,
133
+ tooltipContent = activeMarkerId?.y,
98
134
 
99
135
  basicLineParams = {},
136
+ colorLineParams = (tier, line, lineIndex) => {
137
+ return { pathStrokeColor: lineColorMap[line.areaCode] };
138
+ },
139
+ colors = {
140
+ teal: "#408A7B",
141
+ skyBlue: "#509EC8",
142
+ indigo: "#335F91",
143
+ ochre: "#BA7F30",
144
+ coral: "#E46B6C",
145
+ fuchsia: "#BB2765",
146
+ lavender: "#736CAC",
147
+ ashGrey: "#A0A0A0",
148
+ slateGrey: "#636363",
149
+ black: "#161616",
150
+ forestGreen: "#3C6E3C",
151
+ midnightTeal: "#2C5E5E",
152
+ dustyRose: "#C86B84",
153
+ steelBlue: "#4B6E91",
154
+ burntSienna: "#B65C38",
155
+ oliveGreen: "#7A8644",
156
+ slatePurple: "#64587C",
157
+ },
100
158
  } = $props();
101
159
 
160
+ const colorValues = Array.isArray(colors) ? colors : Object.values(colors);
161
+ const lineColorMap = {};
162
+
163
+ Object.entries(tieredLineParams).forEach(([tier, tierParams]) => {
164
+ const tierLines = lineChartData.lines.filter((line) =>
165
+ assignLinesToTiers(tier, line),
166
+ );
167
+ let colorIndex = 0;
168
+
169
+ tierLines.forEach((line) => {
170
+ const id = line.areaCode;
171
+ if (!(id in lineColorMap)) {
172
+ lineColorMap[id] = colorValues[colorIndex % colorValues.length];
173
+ colorIndex++;
174
+ }
175
+ });
176
+ });
177
+
102
178
  let defaultLineParams = $derived({
103
179
  xFunction,
104
180
  yFunction,
@@ -110,26 +186,30 @@
110
186
  onMouseEnterMarker,
111
187
  onMouseLeaveMarker,
112
188
  haloColor: chartBackgroundColor,
189
+ halo: true,
113
190
  invisibleStrokeWidth: 20,
191
+ placeLabel: true,
192
+ showLabel: true,
193
+ markerFill: undefined,
114
194
  });
115
195
 
116
196
  let chartWidth = $derived(svgWidth - paddingLeft - paddingRight);
117
197
  let chartHeight = $derived(svgHeight - paddingTop - paddingBottom);
118
- // let areaFunction = $derived(
119
- // area()
120
- // .y0((d) => yFunction(0))
121
- // .x((d) => xFunction(d.x))
122
- // .y1((d) => yFunction(d.y))
123
- // .curve(curveLinear),
124
- // );
198
+ let areaFunction = $derived(
199
+ area()
200
+ .y0((d) => yFunction(0))
201
+ .x((d) => xFunction(d.x))
202
+ .y1((d) => yFunction(d.y))
203
+ .curve(curveLinear),
204
+ );
125
205
 
126
206
  let selectedLine = $derived([hoveredSeries, clickedSeries]);
127
207
 
128
208
  function handleClickOutside(event) {
129
209
  if (
130
210
  clickedSeries &&
131
- !event.target.closest('[id^="line"]') &&
132
- !event.target.closest('[id^="label"]')
211
+ !event.target.closest('[data-id^="line"]') && //make this respond to the new element attribute
212
+ !event.target.closest('[data-id^="label"]')
133
213
  ) {
134
214
  clickedSeries = null;
135
215
  }
@@ -141,11 +221,13 @@
141
221
  overrideLineParams,
142
222
  tieredLineParams,
143
223
  basicLineParams,
224
+ colorLineParams,
144
225
  defaultLineParams,
145
226
  ) {
146
227
  const listOfProperties = [
147
228
  ...new Set([
148
229
  ...Object.keys(defaultLineParams),
230
+ ...Object.keys(colorLineParams(tier, line)),
149
231
  ...Object.keys(basicLineParams ?? {}),
150
232
  ...Object.keys(tieredLineParams[tier] ?? {}),
151
233
  ...Object.keys(overrideLineParams(tier, line)),
@@ -158,6 +240,7 @@
158
240
  overrideLineParams(tier, line)[key] ??
159
241
  tieredLineParams[tier]?.[key] ??
160
242
  basicLineParams[key] ??
243
+ colorLineParams(tier, line)[key] ??
161
244
  defaultLineParams[key],
162
245
  ]),
163
246
  );
@@ -173,14 +256,15 @@
173
256
  let tieredDataObject = $derived(
174
257
  Object.keys(tieredLineParams).reduce((acc, tier) => {
175
258
  acc[tier] = lineChartData.lines
176
- .filter((el) => getLine(tier, el))
177
- .map((line) =>
259
+ .filter((el) => assignLinesToTiers(tier, el))
260
+ .map((line, i) =>
178
261
  generateLineAttributes(
179
262
  line,
180
263
  tier,
181
264
  overrideLineParams,
182
265
  tieredLineParams,
183
266
  basicLineParams,
267
+ (tier, line) => colorLineParams(tier, line, i),
184
268
  defaultLineParams,
185
269
  ),
186
270
  );
@@ -195,7 +279,11 @@
195
279
  }
196
280
  </script>
197
281
 
198
- <div bind:clientWidth={svgWidth}>
282
+ <div
283
+ style="position: relative"
284
+ bind:clientWidth={svgWidth}
285
+ bind:this={container}
286
+ >
199
287
  <svg
200
288
  onclick={handleClickOutside}
201
289
  width={svgWidth}
@@ -204,18 +292,32 @@
204
292
  >
205
293
  {#if svgWidth}
206
294
  <g transform="translate({paddingLeft},{paddingTop})">
295
+ <g data-role="y-axis">
296
+ <path d="M0 0 l0 {chartHeight}" stroke="black" stroke-width="2px"
297
+ ></path>
298
+ </g>
299
+ <g data-role="x-axis">
300
+ <path
301
+ d="M0 {chartHeight} l{chartWidth} 0"
302
+ stroke="black"
303
+ stroke-width="2px"
304
+ ></path>
305
+ </g>
207
306
  <g data-role="lines-group">
208
307
  <Lines
209
308
  {tieredDataObject}
210
309
  dataArray={lineChartData.lines}
211
310
  {lineFunction}
311
+ {areaFunction}
212
312
  {chartWidth}
213
313
  {xFunction}
214
314
  {yFunction}
215
315
  {hoveredSeries}
216
316
  {clickedSeries}
317
+ {clickedTier}
318
+ {hoveredTier}
217
319
  {chartHeight}
218
- {globalTierRules}
320
+ {globalTierParams}
219
321
  {chartBackgroundColor}
220
322
  {nothingSelected}
221
323
  {onMouseEnterSeries}
@@ -230,20 +332,27 @@
230
332
  {y}
231
333
  {x}
232
334
  {tooltipContent}
335
+ {currentMousePosition}
336
+ {markerRect}
233
337
  ></Lines>
234
338
  </g>
235
- <g data-role="y-axis">
236
- <path d="M0 0 l0 {chartHeight}" stroke="black" stroke-width="2px"
237
- ></path>
238
- </g>
239
- <g data-role="x-axis">
240
- <path
241
- d="M0 {chartHeight} l{chartWidth} 0"
242
- stroke="black"
243
- stroke-width="2px"
244
- ></path>
245
- </g>
246
339
  </g>
247
340
  {/if}
248
341
  </svg>
342
+ {#if activeMarkerId}
343
+ <ValueLabel
344
+ {activeMarkerId}
345
+ labelColor="lightgrey"
346
+ labelTextColor="black"
347
+ {labelText}
348
+ {tooltipContent}
349
+ {xFunction}
350
+ {yFunction}
351
+ {x}
352
+ {y}
353
+ {currentMousePosition}
354
+ {markerRect}
355
+ {tooltipSnippet}
356
+ ></ValueLabel>
357
+ {/if}
249
358
  </div>
@@ -11,20 +11,24 @@ declare const LineChart: import("svelte").Component<{
11
11
  xFunction?: Function;
12
12
  yFunction?: Function;
13
13
  lineFunction?: any;
14
- labelText?: string;
15
- tooltipContent?: string;
14
+ labelText?: Function;
16
15
  onClickSeries?: Function;
17
16
  onMouseLeaveSeries?: Function;
18
17
  onMouseEnterSeries?: Function;
19
18
  onClickMarker?: Function;
20
19
  onMouseEnterMarker?: Function;
21
20
  onMouseLeaveMarker?: Function;
21
+ currentMousePosition?: any;
22
+ markerRect?: any;
22
23
  clickedSeries?: any;
23
24
  hoveredSeries?: any;
25
+ hoveredTier?: any;
26
+ clickedTier?: any;
24
27
  overrideLineParams?: Function;
25
- getLine?: Function;
28
+ assignLinesToTiers?: Function;
26
29
  nothingSelected?: boolean;
27
30
  svgWidth?: number;
31
+ container?: any;
28
32
  svgHeight?: number;
29
33
  paddingTop?: number;
30
34
  paddingBottom?: number;
@@ -33,10 +37,14 @@ declare const LineChart: import("svelte").Component<{
33
37
  activeMarkerId?: any;
34
38
  chartBackgroundColor?: string;
35
39
  seriesLabels?: boolean;
36
- globalTierRules?: Record<string, any>;
40
+ globalTierParams?: Record<string, any>;
37
41
  tieredLineParams?: Record<string, any>;
42
+ tooltipSnippet?: any;
43
+ tooltipContent?: any;
38
44
  basicLineParams?: Record<string, any>;
39
- }, {}, "clickedSeries" | "svgWidth" | "seriesLabels">;
45
+ colorLineParams?: Function;
46
+ colors?: Record<string, any>;
47
+ }, {}, "clickedSeries" | "hoveredSeries" | "clickedTier" | "hoveredTier" | "svgWidth" | "container" | "seriesLabels">;
40
48
  type $$ComponentProps = {
41
49
  series: any;
42
50
  y: any;
@@ -45,20 +53,24 @@ type $$ComponentProps = {
45
53
  xFunction?: Function;
46
54
  yFunction?: Function;
47
55
  lineFunction?: any;
48
- labelText?: string;
49
- tooltipContent?: string;
56
+ labelText?: Function;
50
57
  onClickSeries?: Function;
51
58
  onMouseLeaveSeries?: Function;
52
59
  onMouseEnterSeries?: Function;
53
60
  onClickMarker?: Function;
54
61
  onMouseEnterMarker?: Function;
55
62
  onMouseLeaveMarker?: Function;
63
+ currentMousePosition?: any;
64
+ markerRect?: any;
56
65
  clickedSeries?: any;
57
66
  hoveredSeries?: any;
67
+ hoveredTier?: any;
68
+ clickedTier?: any;
58
69
  overrideLineParams?: Function;
59
- getLine?: Function;
70
+ assignLinesToTiers?: Function;
60
71
  nothingSelected?: boolean;
61
72
  svgWidth?: number;
73
+ container?: any;
62
74
  svgHeight?: number;
63
75
  paddingTop?: number;
64
76
  paddingBottom?: number;
@@ -67,7 +79,11 @@ type $$ComponentProps = {
67
79
  activeMarkerId?: any;
68
80
  chartBackgroundColor?: string;
69
81
  seriesLabels?: boolean;
70
- globalTierRules?: Record<string, any>;
82
+ globalTierParams?: Record<string, any>;
71
83
  tieredLineParams?: Record<string, any>;
84
+ tooltipSnippet?: any;
85
+ tooltipContent?: any;
72
86
  basicLineParams?: Record<string, any>;
87
+ colorLineParams?: Function;
88
+ colors?: Record<string, any>;
73
89
  };
@@ -1,7 +1,5 @@
1
1
  <script>
2
2
  import Line from "./Line.svelte";
3
- import Marker from "./Marker.svelte";
4
- import ValueLabel from "./ValueLabel.svelte";
5
3
  import SeriesLabel from "./SeriesLabel.svelte";
6
4
  import labelplacer from "labelplacer";
7
5
  import { onMount } from "svelte";
@@ -12,13 +10,16 @@
12
10
  tieredDataObject,
13
11
  dataArray,
14
12
  lineFunction,
13
+ areaFunction,
15
14
  chartWidth,
16
15
  xFunction,
17
16
  yFunction,
18
17
  clickedSeries,
19
18
  hoveredSeries,
19
+ clickedTier,
20
+ hoveredTier,
20
21
  chartHeight,
21
- globalTierRules,
22
+ globalTierParams,
22
23
  chartBackgroundColor = "#fafafa",
23
24
  nothingSelected,
24
25
  onMouseEnterSeries,
@@ -32,7 +33,6 @@
32
33
  series,
33
34
  y,
34
35
  x,
35
- tooltipContent,
36
36
  } = $props();
37
37
 
38
38
  let bounds = $state([0, chartHeight]);
@@ -64,14 +64,15 @@
64
64
 
65
65
  {#each Object.keys(tieredDataObject) as tier}
66
66
  <g id={tier}>
67
- <g {...globalTierRules[tier]}>
67
+ <g {...globalTierParams[tier]}>
68
68
  {#each tieredDataObject[tier] as line, i}
69
69
  <Line
70
70
  {...line}
71
- id={`line-${line[series]}`}
71
+ element={`line-${line[series]}`}
72
72
  {tier}
73
73
  {chartBackgroundColor}
74
74
  {lineFunction}
75
+ {areaFunction}
75
76
  {xFunction}
76
77
  {yFunction}
77
78
  {onMouseEnterSeries}
@@ -79,6 +80,8 @@
79
80
  {onClickSeries}
80
81
  {clickedSeries}
81
82
  {hoveredSeries}
83
+ {clickedTier}
84
+ {hoveredTier}
82
85
  {series}
83
86
  {y}
84
87
  {x}
@@ -97,7 +100,7 @@
97
100
  (el) => el.datum[series] === line[series],
98
101
  )?.[y]}
99
102
  <SeriesLabel
100
- interactive={line.interactive}
103
+ interactiveLines={line.interactiveLines}
101
104
  id={`label-${line[series]}`}
102
105
  {clickedSeries}
103
106
  {hoveredSeries}
@@ -120,19 +123,3 @@
120
123
  </g>
121
124
  </g>
122
125
  {/each}
123
-
124
- {#if activeMarkerId}
125
- <ValueLabel
126
- {activeMarkerId}
127
- labelColor="grey"
128
- labelTextColor="black"
129
- {tooltipContent}
130
- {xFunction}
131
- {yFunction}
132
- {x}
133
- {y}
134
- ></ValueLabel>
135
- {/if}
136
-
137
- <!-- if markerhovered get the id render the tooltip find in the tieredDataObject gets
138
- the data for that line -->