@rokkit/chart 1.0.3 → 1.0.4

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rokkit/chart",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "type": "module",
5
5
  "description": "Data-driven chart components",
6
6
  "repository": {
@@ -26,6 +26,7 @@
26
26
  * @param {SVGSVGElement} svg
27
27
  * @returns {SVGSVGElement}
28
28
  */
29
+ // eslint-disable-next-line complexity
29
30
  function inlineStyles(svg) {
30
31
  const clone = /** @type {SVGSVGElement} */ (svg.cloneNode(true))
31
32
  const computed = getComputedStyle(svg)
@@ -191,6 +191,7 @@ export class PlotState {
191
191
  // use it instead of deriving distinct values from the local panel data.
192
192
  colors = $derived.by(() => {
193
193
  const field = this.#effectiveChannels.color
194
+ // eslint-disable-next-line svelte/prefer-svelte-reactivity
194
195
  if (isLiteralColor(field)) return new Map([[null, { fill: field, stroke: field }]])
195
196
  const values = this.#colorDomain ?? distinct(this.#data, field)
196
197
  // No color channel but data exists → use first preset color for single-series rendering.
@@ -149,7 +149,7 @@
149
149
  >
150
150
  <g transform="translate({margin.left},{margin.top})">
151
151
  <!-- Y axis ticks -->
152
- {#each yTicks as tick}
152
+ {#each yTicks as tick (tick)}
153
153
  <line
154
154
  x1={0}
155
155
  x2={innerWidth}
@@ -181,7 +181,7 @@
181
181
  />
182
182
 
183
183
  <!-- X axis ticks -->
184
- {#each xTicks as tick}
184
+ {#each xTicks as tick (tick)}
185
185
  <text
186
186
  x={xScale(tick)}
187
187
  y={innerHeight + 12}
@@ -193,7 +193,7 @@
193
193
  {/each}
194
194
 
195
195
  <!-- Bars -->
196
- {#each binned as b}
196
+ {#each binned as b (b.x0)}
197
197
  {@const bx = xScale(b.x0) + 1}
198
198
  {@const bw = Math.max(0, xScale(b.x1) - xScale(b.x0) - 1)}
199
199
  {@const by = yScale(b.length)}
@@ -40,9 +40,11 @@
40
40
  const continuousColor = $derived(plotState.continuousColorScale)
41
41
 
42
42
  // Hex binning: group data points into hexagonal cells
43
+ // eslint-disable-next-line max-params, complexity
43
44
  function hexBin(data, xField, yField, xScale, yScale, r) {
44
45
  const dx = r * 2 * Math.sin(Math.PI / 3) // horizontal spacing
45
46
  const dy = r * 1.5 // vertical spacing
47
+ // eslint-disable-next-line svelte/prefer-svelte-reactivity
46
48
  const bins = new Map()
47
49
 
48
50
  for (const d of data) {
@@ -43,6 +43,7 @@
43
43
  const innerWidth = $derived(plotState.innerWidth)
44
44
 
45
45
  // Compute Sankey-style layout
46
+ // eslint-disable-next-line max-lines-per-function, complexity
46
47
  const ribbons = $derived.by(() => {
47
48
  if (!data?.length) return { links: [], sourceNodes: [], targetNodes: [] }
48
49
 
@@ -55,7 +56,9 @@
55
56
  }))
56
57
 
57
58
  // Compute node positions
59
+ // eslint-disable-next-line svelte/prefer-svelte-reactivity
58
60
  const sourceMap = new Map()
61
+ // eslint-disable-next-line svelte/prefer-svelte-reactivity
59
62
  const targetMap = new Map()
60
63
  for (const f of flows) {
61
64
  sourceMap.set(f.source, (sourceMap.get(f.source) ?? 0) + f.value)
@@ -86,11 +89,14 @@
86
89
  }
87
90
 
88
91
  // Build ribbon paths
92
+ // eslint-disable-next-line svelte/prefer-svelte-reactivity
89
93
  const sourceOffsets = new Map(sourceNodes.map((n) => [n.name, n.y]))
94
+ // eslint-disable-next-line svelte/prefer-svelte-reactivity
90
95
  const targetOffsets = new Map(targetNodes.map((n) => [n.name, n.y]))
91
96
  const x0 = 0
92
97
  const x1 = innerWidth
93
98
 
99
+ // eslint-disable-next-line complexity
94
100
  const links = flows.map((f, i) => {
95
101
  const sy0 = sourceOffsets.get(f.source) ?? 0
96
102
  const ty0 = targetOffsets.get(f.target) ?? 0
@@ -42,6 +42,7 @@
42
42
  const xScale = $derived(plotState.xScale)
43
43
  const yScale = $derived(plotState.yScale)
44
44
 
45
+ // eslint-disable-next-line max-lines-per-function
45
46
  const bars = $derived.by(() => {
46
47
  if (!data?.length || !xScale || !yScale) return []
47
48
  const bw = typeof xScale.bandwidth === 'function' ? xScale.bandwidth() : 10
@@ -10,6 +10,7 @@
10
10
  * @param {boolean} enabled
11
11
  */
12
12
  export function keyboardNav(node, enabled) {
13
+ // eslint-disable-next-line complexity
13
14
  function handleKeydown(e) {
14
15
  if (!enabled) return
15
16
  if (e.key !== 'ArrowLeft' && e.key !== 'ArrowRight') return