layerchart 0.41.1 → 0.41.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.
@@ -1,5 +1,5 @@
1
1
  <script>import { createEventDispatcher, getContext } from 'svelte';
2
- import {} from 'd3-geo';
2
+ import { geoTransform as d3geoTransform, } from 'd3-geo';
3
3
  import { cls } from 'svelte-ux';
4
4
  import { geoContext } from './GeoContext.svelte';
5
5
  import { curveLinearClosed } from 'd3-shape';
@@ -30,7 +30,13 @@ const dispatch = createEventDispatcher();
30
30
  const { width, height } = getContext('LayerCake');
31
31
  const canvas = getContext('canvas');
32
32
  const geo = geoContext();
33
- $: geoPath = geoCurvePath($geo, curve);
33
+ /**
34
+ * Apply geo transform to projection. Useful to draw straight lines with `geoMercator` projection.
35
+ * See: https://d3js.org/d3-geo/projection#geoTransform and https://stackoverflow.com/a/56409480/191902
36
+ **/
37
+ export let geoTransform = undefined;
38
+ $: _projection = geoTransform ? d3geoTransform(geoTransform($geo)) : $geo;
39
+ $: geoPath = geoCurvePath(_projection, curve);
34
40
  const DEFAULT_FILL = 'rgb(0, 0, 0)';
35
41
  $: renderContext = canvas ? 'canvas' : 'svg';
36
42
  $: ctx = canvas?.ctx;
@@ -44,13 +50,13 @@ $: if (renderContext === 'canvas' && $ctx) {
44
50
  // console.count('render');
45
51
  $ctx.clearRect(0, 0, $width, $height);
46
52
  if (render) {
47
- geoPath = geoCurvePath($geo, curve, $ctx);
53
+ geoPath = geoCurvePath(_projection, curve, $ctx);
48
54
  render($ctx, { geoPath });
49
55
  }
50
56
  else {
51
57
  $ctx.beginPath();
52
58
  // Set the context here since setting it in `$: geoPath` is a circular reference
53
- geoPath = geoCurvePath($geo, curve, $ctx);
59
+ geoPath = geoCurvePath(_projection, curve, $ctx);
54
60
  geoPath(geojson);
55
61
  $ctx.fillStyle =
56
62
  fill ??
@@ -1,5 +1,5 @@
1
1
  import { SvelteComponentTyped } from "svelte";
2
- import { type GeoPath, type GeoPermissibleObjects } from 'd3-geo';
2
+ import { type GeoIdentityTransform, type GeoPath, type GeoPermissibleObjects, type GeoProjection, type GeoTransformPrototype } from 'd3-geo';
3
3
  import type { TooltipContextValue } from './TooltipContext.svelte';
4
4
  import { type CurveFactory, type CurveFactoryLineOnly } from 'd3-shape';
5
5
  declare const __propDef: {
@@ -13,6 +13,7 @@ declare const __propDef: {
13
13
  tooltip?: TooltipContextValue | undefined;
14
14
  curve?: CurveFactory | CurveFactoryLineOnly | undefined;
15
15
  class?: string | undefined;
16
+ geoTransform?: ((projection: GeoProjection | GeoIdentityTransform) => GeoTransformPrototype) | undefined;
16
17
  };
17
18
  events: {
18
19
  pointerenter: PointerEvent;
@@ -20,7 +20,7 @@ import { writable } from 'svelte/store';
20
20
  import { bisector, max, min } from 'd3-array';
21
21
  import { quadtree as d3Quadtree } from 'd3-quadtree';
22
22
  import { cls, sortFunc } from 'svelte-ux';
23
- import { Svg, Html } from './Chart.svelte';
23
+ import { Svg } from './Chart.svelte';
24
24
  import ChartClipPath from './ChartClipPath.svelte';
25
25
  import Voronoi from './Voronoi.svelte';
26
26
  import { localPoint } from '../utils/event.js';
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "author": "Sean Lynch <techniq35@gmail.com>",
5
5
  "license": "MIT",
6
6
  "repository": "techniq/layerchart",
7
- "version": "0.41.1",
7
+ "version": "0.41.2",
8
8
  "devDependencies": {
9
9
  "@changesets/cli": "^2.27.5",
10
10
  "@mdi/js": "^7.4.47",
@@ -35,10 +35,10 @@
35
35
  "@types/topojson-client": "^3.1.4",
36
36
  "@types/topojson-simplify": "^3.0.3",
37
37
  "autoprefixer": "^10.4.19",
38
- "marked": "^12.0.2",
38
+ "marked": "^13.0.0",
39
39
  "mdsvex": "^0.11.2",
40
40
  "posthog-js": "^1.95.1",
41
- "prettier": "^3.3.1",
41
+ "prettier": "^3.3.2",
42
42
  "prettier-plugin-svelte": "^3.2.4",
43
43
  "prism-svelte": "^0.5.0",
44
44
  "prism-themes": "^1.9.0",
@@ -49,7 +49,7 @@
49
49
  "svelte": "^4.2.18",
50
50
  "svelte-check": "^3.8.0",
51
51
  "svelte-json-tree": "^2.2.0",
52
- "svelte-preprocess": "^5.1.4",
52
+ "svelte-preprocess": "^6.0.0",
53
53
  "svelte2tsx": "^0.7.9",
54
54
  "tailwindcss": "^3.4.4",
55
55
  "topojson-client": "^3.1.0",
@@ -85,9 +85,9 @@
85
85
  "date-fns": "^3.6.0",
86
86
  "layercake": "^8.3.0",
87
87
  "lodash-es": "^4.17.21",
88
- "posthog-js": "^1.138.3",
88
+ "posthog-js": "^1.139.1",
89
89
  "shapefile": "^0.6.6",
90
- "svelte-ux": "^0.66.6",
90
+ "svelte-ux": "^0.66.7",
91
91
  "topojson-client": "^3.1.0"
92
92
  },
93
93
  "peerDependencies": {