@columenlabs/lumen-ui 0.1.0 → 0.1.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.
@@ -15,6 +15,20 @@ const FULL_TURN = 360;
15
15
  const HEIGHT = 260;
16
16
  /** Country borders, thin enough to read small countries at 110m. */
17
17
  const BORDER = 0.5;
18
+ /**
19
+ * A CSS colour as `rgb(r, g, b)`. ECharts blends a visual map's colours itself and reads only hex
20
+ * and rgb, so a theme colour in another form (`oklch(…)`, `color-mix(…)`) blends to black. The
21
+ * browser paints it on one pixel and the pixel is read back.
22
+ */
23
+ function toRgb(color) {
24
+ const ctx = document.createElement('canvas').getContext('2d', { willReadFrequently: true });
25
+ if (!ctx)
26
+ return color;
27
+ ctx.fillStyle = color;
28
+ ctx.fillRect(0, 0, 1, 1);
29
+ const [r, g, b] = ctx.getImageData(0, 0, 1, 1).data;
30
+ return `rgb(${r}, ${g}, ${b})`;
31
+ }
18
32
  /** Moves every far-west longitude in nested GeoJSON coordinates one turn east, in place. */
19
33
  function unwrap(c) {
20
34
  if (!Array.isArray(c))
@@ -94,7 +108,7 @@ export function LumenGeoMap({ values, label, unit, height = HEIGHT, }) {
94
108
  show: false,
95
109
  min: 0,
96
110
  max,
97
- inRange: { color: [t.border, t.primary] },
111
+ inRange: { color: [toRgb(t.border), toRgb(t.primary)] },
98
112
  },
99
113
  series: [
100
114
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@columenlabs/lumen-ui",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Lumen: shared React components (frame, views, widgets, charts, drawers).",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -41,7 +41,7 @@
41
41
  "@codemirror/lang-javascript": "6.2.5",
42
42
  "@codemirror/lang-json": "6.0.2",
43
43
  "@codemirror/lang-sql": "6.10.0",
44
- "@columenlabs/lumen-ui-types": "0.1.0",
44
+ "@columenlabs/lumen-ui-types": "0.1.1",
45
45
  "@dnd-kit/core": "6.3.1",
46
46
  "@dnd-kit/sortable": "10.0.0",
47
47
  "@dnd-kit/utilities": "3.2.2",