@cfasim-ui/docs 0.7.3 → 0.7.5

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.
@@ -104,6 +104,17 @@ export function savePng(svg: SVGSVGElement, filename: string) {
104
104
  img.src = url;
105
105
  }
106
106
 
107
+ /**
108
+ * Downloads a rendering canvas's current contents as a PNG — no SVG
109
+ * round-trip. The canvas backing store is already sized at
110
+ * devicePixelRatio, so the export is naturally high-resolution.
111
+ */
112
+ export function saveCanvasPng(canvas: HTMLCanvasElement, filename: string) {
113
+ canvas.toBlob((blob) => {
114
+ if (blob) downloadBlob(blob, `${filename}.png`);
115
+ }, "image/png");
116
+ }
117
+
107
118
  export function downloadCsv(csv: string, filename: string) {
108
119
  downloadBlob(new Blob([csv], { type: "text/csv" }), `${filename}.csv`);
109
120
  }
@@ -279,10 +279,10 @@ hide it.
279
279
  full extent.
280
280
  - **Touch:** a **double tap** expands the map to fill the window, zoomed
281
281
  in on the tapped point; single taps select features inline. Inside the
282
- expanded view, one finger pans, a pinch zooms, and a tap selects; the
283
- +/−/reset controls sit top-left and a close (✕) button top-right returns
284
- to the inline map at full extent. A single finger over the inline map
285
- still scrolls the page.
282
+ expanded view, one finger pans, a pinch zooms, and a tap selects — its
283
+ tooltip slides up as a bottom sheet; the +/−/reset controls sit top-left
284
+ and a close (✕) button top-right returns to the inline map at full
285
+ extent. A single finger over the inline map still scrolls the page.
286
286
 
287
287
  Filling the window is always an activated state: whether entered via the
288
288
  menu's **Fullscreen** item or a double tap, pan/zoom works immediately and
@@ -319,11 +319,16 @@ pans, and touch gestures work inline with no tap-to-expand step. The
319
319
 
320
320
  Set `geoType="counties"` to render county-level data using 5-digit FIPS codes. State borders are drawn on top for context. Double-click (or double-tap on touch) to explore — useful for dense county data.
321
321
 
322
+ This demo also wires up an interactive tooltip (`tooltip-trigger="hover"`):
323
+ hover a county on desktop, or tap one on touch, and it works the same
324
+ before and after zooming in.
325
+
322
326
  <ComponentDemo>
323
327
  <ChoroplethMap
324
328
  :topology="countiesTopo"
325
329
  geo-type="counties"
326
330
  zoom
331
+ tooltip-trigger="hover"
327
332
  :data="[
328
333
  { id: '06037', value: 100 },
329
334
  { id: '06073', value: 80 },
@@ -348,6 +353,7 @@ Set `geoType="counties"` to render county-level data using 5-digit FIPS codes. S
348
353
  :topology="countiesTopo"
349
354
  geo-type="counties"
350
355
  zoom
356
+ tooltip-trigger="hover"
351
357
  :data="[
352
358
  { id: '06037', value: 100 },
353
359
  { id: '36061', value: 90 },
@@ -368,11 +374,15 @@ Set `geoType="counties"` to render county-level data using 5-digit FIPS codes. S
368
374
 
369
375
  Set `geoType="hsas"` to render Health Service Area boundaries. HSAs are dissolved from county boundaries using a built-in FIPS-to-HSA mapping. Use 6-digit HSA codes as IDs. State borders are overlaid for context.
370
376
 
377
+ This demo pairs `tooltip-trigger="hover"` with a custom `#tooltip` slot —
378
+ hover an HSA on desktop, or tap one on touch, before or after zooming in.
379
+
371
380
  <ComponentDemo>
372
381
  <ChoroplethMap
373
382
  :topology="countiesTopo"
374
383
  geo-type="hsas"
375
384
  zoom
385
+ tooltip-trigger="hover"
376
386
  :data="[
377
387
  { id: '010259', value: 100 },
378
388
  { id: '060766', value: 90 },
@@ -388,7 +398,14 @@ Set `geoType="hsas"` to render Health Service Area boundaries. HSAs are dissolve
388
398
  title="Cases by HSA"
389
399
  :legend-title="'Cases'"
390
400
  :height="400"
391
- />
401
+ >
402
+ <template #tooltip="{ id, name, value }">
403
+ <div style="font-weight: 600">{{ name }}</div>
404
+ <div style="opacity: 0.7; font-size: 0.85em">HSA {{ id }}</div>
405
+ <div v-if="value != null">Cases: {{ value }}</div>
406
+ <div v-else style="opacity: 0.6">No data</div>
407
+ </template>
408
+ </ChoroplethMap>
392
409
 
393
410
  <template #code>
394
411
 
@@ -397,6 +414,7 @@ Set `geoType="hsas"` to render Health Service Area boundaries. HSAs are dissolve
397
414
  :topology="countiesTopo"
398
415
  geo-type="hsas"
399
416
  zoom
417
+ tooltip-trigger="hover"
400
418
  :data="[
401
419
  { id: '010259', value: 100 },
402
420
  { id: '060766', value: 90 },
@@ -407,7 +425,14 @@ Set `geoType="hsas"` to render Health Service Area boundaries. HSAs are dissolve
407
425
  title="Cases by HSA"
408
426
  :legend-title="'Cases'"
409
427
  :height="400"
410
- />
428
+ >
429
+ <template #tooltip="{ id, name, value }">
430
+ <div style="font-weight: 600">{{ name }}</div>
431
+ <div style="opacity: 0.7; font-size: 0.85em">HSA {{ id }}</div>
432
+ <div v-if="value != null">Cases: {{ value }}</div>
433
+ <div v-else style="opacity: 0.6">No data</div>
434
+ </template>
435
+ </ChoroplethMap>
411
436
  ```
412
437
 
413
438
  </template>
@@ -499,8 +524,9 @@ Selection works the same on touch: a single-finger **tap** on a feature
499
524
  emits `stateClick` and toggles focus, inline or inside the expanded view.
500
525
  (Inline with `zoom` on, the selection fires after the brief double-tap
501
526
  window.) A tap also stands in for hover — it applies the hover highlight,
502
- emits `stateHover`, and shows the feature's tooltip at the tapped point;
503
- only continuous hover _tracking_ is off on touch, for performance.
527
+ emits `stateHover`, and shows the feature's tooltip (anchored to the
528
+ feature inline; sliding up as a bottom sheet in the expanded view); only
529
+ continuous hover _tracking_ is off on touch, for performance.
504
530
 
505
531
  Click-to-focus interactions usually pair best with `:touch-expand="false"`,
506
532
  as in the demos below — a double tap zooms in place while taps keep
@@ -581,6 +607,7 @@ on top with a `FocusItem`.
581
607
  geo-type="counties"
582
608
  data-geo-type="hsas"
583
609
  zoom
610
+ renderer="canvas"
584
611
  :touch-expand="false"
585
612
  :data="[
586
613
  { id: '060737', value: 80 },
@@ -608,6 +635,7 @@ on top with a `FocusItem`.
608
635
  geo-type="counties"
609
636
  data-geo-type="hsas"
610
637
  zoom
638
+ renderer="canvas"
611
639
  :touch-expand="false"
612
640
  :data="hsaData"
613
641
  :focus="[{ id: '06043' }, { id: '060737', geoType: 'hsas', style: 'dashed' }]"
@@ -733,9 +761,31 @@ Pass `tooltip-value-format` to format numeric values shown in the tooltip
733
761
  </template>
734
762
  </ComponentDemo>
735
763
 
764
+ ### Canvas rendering (`renderer="canvas"`)
765
+
766
+ For dense maps — every US county, HSAs, or anything that feels sluggish on
767
+ mobile — set `renderer="canvas"`. Instead of one DOM path per feature, the
768
+ whole map paints into a single `<canvas>`: zooming, panning, and hover/tap
769
+ highlights redraw in a few milliseconds regardless of feature count, and
770
+ DOM memory stays flat. Interactions are identical (hover, click/tap
771
+ selection, `focus`, every zoom mode and touch flow); hit-testing runs
772
+ through an offscreen picking bitmap, so it stays pixel-accurate.
773
+
774
+ Differences from the default SVG renderer:
775
+
776
+ - The menu offers **Fullscreen** and **Save as PNG** only (there is no SVG
777
+ DOM to serialize; the PNG exports straight off the rendering canvas).
778
+ - There is no per-feature `<title>` fallback or per-feature DOM for
779
+ assistive tech — configure an interactive tooltip (`tooltip-trigger` or
780
+ the `#tooltip` slot), or stay on SVG where that fallback matters.
781
+ - `renderer` is fixed at mount.
782
+
783
+ The dense county demo below uses it.
784
+
736
785
  ### Dense county map
737
786
 
738
- Renders every US county with a value and a custom tooltip slot.
787
+ Renders every US county with a value and a custom tooltip slot, on the
788
+ canvas backend.
739
789
 
740
790
  <ComponentDemo>
741
791
  <ChoroplethMap
@@ -743,6 +793,7 @@ Renders every US county with a value and a custom tooltip slot.
743
793
  geo-type="counties"
744
794
  :data="denseCountyData"
745
795
  zoom
796
+ renderer="canvas"
746
797
  :color-scale="{ min: '#f0f5ff', max: '#08306b' }"
747
798
  title="All US counties — tooltip perf demo"
748
799
  :height="500"
@@ -767,7 +818,13 @@ const data = countiesTopo.objects.counties.geometries.map((g, i) => ({
767
818
  }));
768
819
  </script>
769
820
 
770
- <ChoroplethMap :topology="countiesTopo" geo-type="counties" :data="data" zoom>
821
+ <ChoroplethMap
822
+ :topology="countiesTopo"
823
+ geo-type="counties"
824
+ :data="data"
825
+ zoom
826
+ renderer="canvas"
827
+ >
771
828
  <template #tooltip="{ id, name, value }">
772
829
  <div style="font-weight: 600">{{ name }}</div>
773
830
  <div style="opacity: 0.7; font-size: 0.85em">FIPS {{ id }}</div>
@@ -887,6 +944,7 @@ tech).
887
944
  | `focus` | `FocusValue` | No | — |
888
945
  | `focusZoomLevel` | `number` | No | `4` |
889
946
  | `focusZoom` | `boolean` | No | `true` |
947
+ | `renderer` | `"svg" \| "canvas"` | No | `"svg"` |
890
948
  | `fullscreenTarget` | `string \| HTMLElement` | No | — |
891
949
 
892
950