@rokkit/chart 1.0.0-next.93 → 1.0.0-next.95

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.0-next.93",
3
+ "version": "1.0.0-next.95",
4
4
  "description": "Components for making interactive charts.",
5
5
  "author": "Jerry Thomas <me@jerrythomas.name>",
6
6
  "license": "MIT",
@@ -19,10 +19,10 @@
19
19
  "js-yaml": "^4.1.0",
20
20
  "jsdom": "^24.0.0",
21
21
  "svelte": "^4.2.12",
22
- "typescript": "^5.4.3",
23
- "vite": "^5.2.7",
22
+ "typescript": "^5.4.4",
23
+ "vite": "^5.2.8",
24
24
  "vitest": "~1.4.0",
25
- "shared-config": "1.0.0-next.93"
25
+ "shared-config": "1.0.0-next.95"
26
26
  },
27
27
  "dependencies": {
28
28
  "@observablehq/plot": "^0.6.14",
@@ -35,10 +35,10 @@
35
35
  "date-fns": "^3.6.0",
36
36
  "ramda": "^0.29.1",
37
37
  "yootils": "^0.3.1",
38
- "@rokkit/atoms": "1.0.0-next.93",
39
- "@rokkit/core": "1.0.0-next.93",
40
- "@rokkit/stores": "1.0.0-next.93",
41
- "@rokkit/molecules": "1.0.0-next.93"
38
+ "@rokkit/atoms": "1.0.0-next.95",
39
+ "@rokkit/core": "1.0.0-next.95",
40
+ "@rokkit/molecules": "1.0.0-next.95",
41
+ "@rokkit/stores": "1.0.0-next.95"
42
42
  },
43
43
  "files": [
44
44
  "src/**/*.js",
package/src/lib/brewer.js CHANGED
@@ -14,4 +14,4 @@ export function getFillPatterns(values, swatch, gray = false) {
14
14
  return mix
15
15
  }
16
16
 
17
- export function getStrokePatterns() {}
17
+ // export function getStrokePatterns() {}
package/src/lib/chart.js CHANGED
@@ -101,7 +101,7 @@ class Chart {
101
101
  y: [this.height - this.padding - this.margin.bottom, this.margin.top + this.padding]
102
102
  }
103
103
 
104
- let scale = {
104
+ const scale = {
105
105
  x: getScale(this.domain.x, this.range.x, this.spacing),
106
106
  y: getScale(this.domain.y, this.range.y, this.spacing)
107
107
  }
@@ -180,7 +180,7 @@ class Chart {
180
180
 
181
181
  ticks = scale.domain()
182
182
  if (count < scale.domain().length) {
183
- let diff = scale.domain().length - count
183
+ const diff = scale.domain().length - count
184
184
  ticks = ticks.filter((d, i) => i % diff === 0)
185
185
  }
186
186
  }
package/src/lib/grid.js CHANGED
@@ -7,10 +7,11 @@
7
7
 
8
8
  /**
9
9
  * @typedef SwatchGrid
10
- * @property {number} width
11
- * @property {number} height
10
+ * @property {number} width
11
+ * @property {number} height
12
12
  * @property {GridPoint[]} data
13
13
  */
14
+
14
15
  /**
15
16
  * Calculates a grid of centres to fit a list of items of `size` within the number of `columns` and `rows`.
16
17
  *
@@ -47,8 +48,16 @@ export function swatchGrid(count, size, pad = 0, columns = 0, rows = 0) {
47
48
  return { width, height, data }
48
49
  }
49
50
 
51
+ /**
52
+ * Spreads values as patterns with colors from a palette
53
+ *
54
+ * @param {number[]} values
55
+ * @param {string[]} patterns
56
+ * @param {string[]} palette
57
+ * @returns {Record<number, { id: string, pattern: string, color: string }>}
58
+ */
50
59
  export function spreadValuesAsPatterns(values, patterns, palette) {
51
- values
60
+ const result = values
52
61
  .map((value, index) => ({
53
62
  pattern: patterns[index % patterns.length],
54
63
  color: palette[index % palette.length],
@@ -58,11 +67,12 @@ export function spreadValuesAsPatterns(values, patterns, palette) {
58
67
  (acc, { value, pattern, color }) => ({
59
68
  ...acc,
60
69
  [value]: {
61
- id: pattern + '_' + color,
70
+ id: `${pattern}_${color}`,
62
71
  pattern,
63
72
  color
64
73
  }
65
74
  }),
66
75
  {}
67
76
  )
77
+ return result
68
78
  }
package/src/lib/plots.js CHANGED
@@ -1,3 +1,4 @@
1
+ // skipcq: JS-C1003 - Importing all plots from observablehq/plot
1
2
  import * as Plot from '@observablehq/plot'
2
3
 
3
4
  export function plotter(node, options) {
@@ -15,11 +16,11 @@ export function plotter(node, options) {
15
16
  render()
16
17
 
17
18
  return {
18
- update: (options) => {
19
- data = options.data
20
- aes = options.aes
21
- type = options.type
22
- opts = options.opts
19
+ update: (input) => {
20
+ data = input.data
21
+ aes = input.aes
22
+ type = input.type
23
+ opts = input.opts
23
24
  render()
24
25
  }
25
26
  }
package/src/lib/swatch.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { writable } from 'svelte/store'
2
2
  import palette from './palette.json'
3
+ // skipcq: JS-C1003 - Importing all patterns
3
4
  import * as patterns from '../patterns'
4
5
  import { shapes } from '../symbols'
5
6