@plenustech/design-system 0.2.2 → 0.2.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/dist/components/actions/ButtonTile/ButtonTile.cjs +2 -0
- package/dist/components/actions/ButtonTile/ButtonTile.cjs.map +1 -0
- package/dist/components/actions/ButtonTile/ButtonTile.js +23 -0
- package/dist/components/actions/ButtonTile/ButtonTile.js.map +1 -0
- package/dist/components/actions/ButtonTile/ButtonTile.module.css.cjs +2 -0
- package/dist/components/actions/ButtonTile/ButtonTile.module.css.cjs.map +1 -0
- package/dist/components/actions/ButtonTile/ButtonTile.module.css.js +16 -0
- package/dist/components/actions/ButtonTile/ButtonTile.module.css.js.map +1 -0
- package/dist/components/actions/Toolbar/Toolbar.cjs +2 -0
- package/dist/components/actions/Toolbar/Toolbar.cjs.map +1 -0
- package/dist/components/actions/Toolbar/Toolbar.js +118 -0
- package/dist/components/actions/Toolbar/Toolbar.js.map +1 -0
- package/dist/components/actions/Toolbar/Toolbar.module.css.cjs +2 -0
- package/dist/components/actions/Toolbar/Toolbar.module.css.cjs.map +1 -0
- package/dist/components/actions/Toolbar/Toolbar.module.css.js +20 -0
- package/dist/components/actions/Toolbar/Toolbar.module.css.js.map +1 -0
- package/dist/components/charts/ChartArea/ChartArea.cjs +1 -1
- package/dist/components/charts/ChartArea/ChartArea.cjs.map +1 -1
- package/dist/components/charts/ChartArea/ChartArea.js +196 -148
- package/dist/components/charts/ChartArea/ChartArea.js.map +1 -1
- package/dist/components/charts/ChartArea/ChartArea.module.css.cjs +1 -1
- package/dist/components/charts/ChartArea/ChartArea.module.css.js +12 -10
- package/dist/components/charts/ChartArea/ChartArea.module.css.js.map +1 -1
- package/dist/components/charts/ChartBar/ChartBar.cjs +1 -1
- package/dist/components/charts/ChartBar/ChartBar.cjs.map +1 -1
- package/dist/components/charts/ChartBar/ChartBar.js +168 -145
- package/dist/components/charts/ChartBar/ChartBar.js.map +1 -1
- package/dist/components/charts/ChartBar/ChartBar.module.css.cjs +1 -1
- package/dist/components/charts/ChartBar/ChartBar.module.css.js +12 -10
- package/dist/components/charts/ChartBar/ChartBar.module.css.js.map +1 -1
- package/dist/components/charts/ChartCombo/ChartCombo.cjs +1 -1
- package/dist/components/charts/ChartCombo/ChartCombo.cjs.map +1 -1
- package/dist/components/charts/ChartCombo/ChartCombo.js +179 -154
- package/dist/components/charts/ChartCombo/ChartCombo.js.map +1 -1
- package/dist/components/charts/ChartCombo/ChartCombo.module.css.cjs +1 -1
- package/dist/components/charts/ChartCombo/ChartCombo.module.css.js +16 -14
- package/dist/components/charts/ChartCombo/ChartCombo.module.css.js.map +1 -1
- package/dist/components/charts/ChartDonut/ChartDonut.cjs +1 -1
- package/dist/components/charts/ChartDonut/ChartDonut.cjs.map +1 -1
- package/dist/components/charts/ChartDonut/ChartDonut.js +72 -61
- package/dist/components/charts/ChartDonut/ChartDonut.js.map +1 -1
- package/dist/components/charts/ChartGauge/ChartGauge.cjs +2 -0
- package/dist/components/charts/ChartGauge/ChartGauge.cjs.map +1 -0
- package/dist/components/charts/ChartGauge/ChartGauge.js +307 -0
- package/dist/components/charts/ChartGauge/ChartGauge.js.map +1 -0
- package/dist/components/charts/ChartGauge/ChartGauge.module.css.cjs +2 -0
- package/dist/components/charts/ChartGauge/ChartGauge.module.css.cjs.map +1 -0
- package/dist/components/charts/ChartGauge/ChartGauge.module.css.js +76 -0
- package/dist/components/charts/ChartGauge/ChartGauge.module.css.js.map +1 -0
- package/dist/components/charts/ChartGauge/gaugeLayout.cjs +2 -0
- package/dist/components/charts/ChartGauge/gaugeLayout.cjs.map +1 -0
- package/dist/components/charts/ChartGauge/gaugeLayout.js +107 -0
- package/dist/components/charts/ChartGauge/gaugeLayout.js.map +1 -0
- package/dist/components/charts/ChartGauge/gaugeReading.cjs +2 -0
- package/dist/components/charts/ChartGauge/gaugeReading.cjs.map +1 -0
- package/dist/components/charts/ChartGauge/gaugeReading.js +112 -0
- package/dist/components/charts/ChartGauge/gaugeReading.js.map +1 -0
- package/dist/components/charts/ChartGauge/gaugeScale.cjs +2 -0
- package/dist/components/charts/ChartGauge/gaugeScale.cjs.map +1 -0
- package/dist/components/charts/ChartGauge/gaugeScale.js +57 -0
- package/dist/components/charts/ChartGauge/gaugeScale.js.map +1 -0
- package/dist/components/charts/ChartLine/ChartLine.cjs +1 -1
- package/dist/components/charts/ChartLine/ChartLine.cjs.map +1 -1
- package/dist/components/charts/ChartLine/ChartLine.js +196 -143
- package/dist/components/charts/ChartLine/ChartLine.js.map +1 -1
- package/dist/components/charts/ChartLine/ChartLine.module.css.cjs +1 -1
- package/dist/components/charts/ChartLine/ChartLine.module.css.js +16 -14
- package/dist/components/charts/ChartLine/ChartLine.module.css.js.map +1 -1
- package/dist/components/charts/ChartMap/ChartMap.cjs +2 -0
- package/dist/components/charts/ChartMap/ChartMap.cjs.map +1 -0
- package/dist/components/charts/ChartMap/ChartMap.js +523 -0
- package/dist/components/charts/ChartMap/ChartMap.js.map +1 -0
- package/dist/components/charts/ChartMap/ChartMap.module.css.cjs +2 -0
- package/dist/components/charts/ChartMap/ChartMap.module.css.cjs.map +1 -0
- package/dist/components/charts/ChartMap/ChartMap.module.css.js +124 -0
- package/dist/components/charts/ChartMap/ChartMap.module.css.js.map +1 -0
- package/dist/components/charts/ChartMap/ChartMapLegend.cjs +2 -0
- package/dist/components/charts/ChartMap/ChartMapLegend.cjs.map +1 -0
- package/dist/components/charts/ChartMap/ChartMapLegend.js +102 -0
- package/dist/components/charts/ChartMap/ChartMapLegend.js.map +1 -0
- package/dist/components/charts/ChartMap/ChartMapTable.cjs +2 -0
- package/dist/components/charts/ChartMap/ChartMapTable.cjs.map +1 -0
- package/dist/components/charts/ChartMap/ChartMapTable.js +118 -0
- package/dist/components/charts/ChartMap/ChartMapTable.js.map +1 -0
- package/dist/components/charts/ChartMap/mapGeometry.cjs +2 -0
- package/dist/components/charts/ChartMap/mapGeometry.cjs.map +1 -0
- package/dist/components/charts/ChartMap/mapGeometry.js +113 -0
- package/dist/components/charts/ChartMap/mapGeometry.js.map +1 -0
- package/dist/components/charts/ChartMap/mapLabels.cjs +2 -0
- package/dist/components/charts/ChartMap/mapLabels.cjs.map +1 -0
- package/dist/components/charts/ChartMap/mapLabels.js +80 -0
- package/dist/components/charts/ChartMap/mapLabels.js.map +1 -0
- package/dist/components/charts/ChartMap/mapScales.cjs +2 -0
- package/dist/components/charts/ChartMap/mapScales.cjs.map +1 -0
- package/dist/components/charts/ChartMap/mapScales.js +131 -0
- package/dist/components/charts/ChartMap/mapScales.js.map +1 -0
- package/dist/components/charts/ChartMap/polylabel.cjs +2 -0
- package/dist/components/charts/ChartMap/polylabel.cjs.map +1 -0
- package/dist/components/charts/ChartMap/polylabel.js +50 -0
- package/dist/components/charts/ChartMap/polylabel.js.map +1 -0
- package/dist/components/charts/ChartPie/ChartPie.cjs +1 -1
- package/dist/components/charts/ChartPie/ChartPie.cjs.map +1 -1
- package/dist/components/charts/ChartPie/ChartPie.js +71 -60
- package/dist/components/charts/ChartPie/ChartPie.js.map +1 -1
- package/dist/components/charts/ChartRadial/ChartRadial.cjs +1 -1
- package/dist/components/charts/ChartRadial/ChartRadial.cjs.map +1 -1
- package/dist/components/charts/ChartRadial/ChartRadial.js +101 -84
- package/dist/components/charts/ChartRadial/ChartRadial.js.map +1 -1
- package/dist/components/charts/ChartSankey/ChartSankey.cjs +1 -1
- package/dist/components/charts/ChartSankey/ChartSankey.cjs.map +1 -1
- package/dist/components/charts/ChartSankey/ChartSankey.js +148 -125
- package/dist/components/charts/ChartSankey/ChartSankey.js.map +1 -1
- package/dist/components/charts/ChartScatter/ChartScatter.cjs +1 -1
- package/dist/components/charts/ChartScatter/ChartScatter.cjs.map +1 -1
- package/dist/components/charts/ChartScatter/ChartScatter.js +138 -106
- package/dist/components/charts/ChartScatter/ChartScatter.js.map +1 -1
- package/dist/components/charts/ChartScatter/ChartScatter.module.css.cjs +1 -1
- package/dist/components/charts/ChartScatter/ChartScatter.module.css.js +3 -3
- package/dist/components/charts/ChartSunburst/ChartSunburst.cjs +1 -1
- package/dist/components/charts/ChartSunburst/ChartSunburst.cjs.map +1 -1
- package/dist/components/charts/ChartSunburst/ChartSunburst.js +115 -100
- package/dist/components/charts/ChartSunburst/ChartSunburst.js.map +1 -1
- package/dist/components/charts/ChartTimeline/ChartTimeline.cjs +2 -0
- package/dist/components/charts/ChartTimeline/ChartTimeline.cjs.map +1 -0
- package/dist/components/charts/ChartTimeline/ChartTimeline.js +703 -0
- package/dist/components/charts/ChartTimeline/ChartTimeline.js.map +1 -0
- package/dist/components/charts/ChartTimeline/ChartTimeline.module.css.cjs +2 -0
- package/dist/components/charts/ChartTimeline/ChartTimeline.module.css.cjs.map +1 -0
- package/dist/components/charts/ChartTimeline/ChartTimeline.module.css.js +124 -0
- package/dist/components/charts/ChartTimeline/ChartTimeline.module.css.js.map +1 -0
- package/dist/components/charts/ChartTimeline/ChartTimelineTable.cjs +2 -0
- package/dist/components/charts/ChartTimeline/ChartTimelineTable.cjs.map +1 -0
- package/dist/components/charts/ChartTimeline/ChartTimelineTable.js +42 -0
- package/dist/components/charts/ChartTimeline/ChartTimelineTable.js.map +1 -0
- package/dist/components/charts/ChartTimeline/timelineLayout.cjs +2 -0
- package/dist/components/charts/ChartTimeline/timelineLayout.cjs.map +1 -0
- package/dist/components/charts/ChartTimeline/timelineLayout.js +109 -0
- package/dist/components/charts/ChartTimeline/timelineLayout.js.map +1 -0
- package/dist/components/charts/ChartTimeline/timelineTime.cjs +2 -0
- package/dist/components/charts/ChartTimeline/timelineTime.cjs.map +1 -0
- package/dist/components/charts/ChartTimeline/timelineTime.js +91 -0
- package/dist/components/charts/ChartTimeline/timelineTime.js.map +1 -0
- package/dist/components/charts/ChartTimeline/timelineTooltip.cjs +2 -0
- package/dist/components/charts/ChartTimeline/timelineTooltip.cjs.map +1 -0
- package/dist/components/charts/ChartTimeline/timelineTooltip.js +77 -0
- package/dist/components/charts/ChartTimeline/timelineTooltip.js.map +1 -0
- package/dist/components/charts/ChartTooltip/ChartTooltip.cjs +1 -1
- package/dist/components/charts/ChartTooltip/ChartTooltip.cjs.map +1 -1
- package/dist/components/charts/ChartTooltip/ChartTooltip.js +1 -1
- package/dist/components/charts/ChartTooltip/ChartTooltip.js.map +1 -1
- package/dist/components/charts/ChartTreemap/ChartTreemap.cjs +1 -1
- package/dist/components/charts/ChartTreemap/ChartTreemap.cjs.map +1 -1
- package/dist/components/charts/ChartTreemap/ChartTreemap.js +100 -89
- package/dist/components/charts/ChartTreemap/ChartTreemap.js.map +1 -1
- package/dist/components/charts/ChartWaterfall/ChartWaterfall.cjs +1 -1
- package/dist/components/charts/ChartWaterfall/ChartWaterfall.cjs.map +1 -1
- package/dist/components/charts/ChartWaterfall/ChartWaterfall.js +125 -105
- package/dist/components/charts/ChartWaterfall/ChartWaterfall.js.map +1 -1
- package/dist/components/charts/ChartWaterfall/ChartWaterfall.module.css.cjs +1 -1
- package/dist/components/charts/ChartWaterfall/ChartWaterfall.module.css.js +8 -6
- package/dist/components/charts/ChartWaterfall/ChartWaterfall.module.css.js.map +1 -1
- package/dist/components/charts/core/CartesianFrame.cjs +1 -1
- package/dist/components/charts/core/CartesianFrame.cjs.map +1 -1
- package/dist/components/charts/core/CartesianFrame.js +61 -96
- package/dist/components/charts/core/CartesianFrame.js.map +1 -1
- package/dist/components/charts/core/Chart.module.css.cjs +1 -1
- package/dist/components/charts/core/Chart.module.css.js +52 -54
- package/dist/components/charts/core/Chart.module.css.js.map +1 -1
- package/dist/components/charts/core/ChartFrame.cjs +1 -1
- package/dist/components/charts/core/ChartFrame.cjs.map +1 -1
- package/dist/components/charts/core/ChartFrame.js +53 -47
- package/dist/components/charts/core/ChartFrame.js.map +1 -1
- package/dist/components/charts/core/ChartLegend.cjs +1 -1
- package/dist/components/charts/core/ChartLegend.cjs.map +1 -1
- package/dist/components/charts/core/ChartLegend.js +37 -25
- package/dist/components/charts/core/ChartLegend.js.map +1 -1
- package/dist/components/charts/core/PointBands.cjs +2 -0
- package/dist/components/charts/core/PointBands.cjs.map +1 -0
- package/dist/components/charts/core/PointBands.js +41 -0
- package/dist/components/charts/core/PointBands.js.map +1 -0
- package/dist/components/charts/core/cartesianLayout.cjs +1 -1
- package/dist/components/charts/core/cartesianLayout.cjs.map +1 -1
- package/dist/components/charts/core/cartesianLayout.js +49 -41
- package/dist/components/charts/core/cartesianLayout.js.map +1 -1
- package/dist/components/charts/core/hoverPath.cjs +2 -0
- package/dist/components/charts/core/hoverPath.cjs.map +1 -0
- package/dist/components/charts/core/hoverPath.js +7 -0
- package/dist/components/charts/core/hoverPath.js.map +1 -0
- package/dist/components/charts/core/pointLabels.cjs +2 -0
- package/dist/components/charts/core/pointLabels.cjs.map +1 -0
- package/dist/components/charts/core/pointLabels.js +12 -0
- package/dist/components/charts/core/pointLabels.js.map +1 -0
- package/dist/components/charts/core/tooltips.cjs +2 -0
- package/dist/components/charts/core/tooltips.cjs.map +1 -0
- package/dist/components/charts/core/tooltips.js +48 -0
- package/dist/components/charts/core/tooltips.js.map +1 -0
- package/dist/components/charts/core/useCartesianLayout.cjs +2 -0
- package/dist/components/charts/core/useCartesianLayout.cjs.map +1 -0
- package/dist/components/charts/core/useCartesianLayout.js +38 -0
- package/dist/components/charts/core/useCartesianLayout.js.map +1 -0
- package/dist/components/charts/core/useChartMetrics.cjs +1 -1
- package/dist/components/charts/core/useChartMetrics.cjs.map +1 -1
- package/dist/components/charts/core/useChartMetrics.js +20 -25
- package/dist/components/charts/core/useChartMetrics.js.map +1 -1
- package/dist/components/charts/core/useSeriesToggle.cjs +1 -1
- package/dist/components/charts/core/useSeriesToggle.cjs.map +1 -1
- package/dist/components/charts/core/useSeriesToggle.js +19 -12
- package/dist/components/charts/core/useSeriesToggle.js.map +1 -1
- package/dist/components/data-display/Accordion/Accordion.cjs +1 -1
- package/dist/components/data-display/Accordion/Accordion.cjs.map +1 -1
- package/dist/components/data-display/Accordion/Accordion.js +56 -46
- package/dist/components/data-display/Accordion/Accordion.js.map +1 -1
- package/dist/components/data-display/Accordion/Accordion.module.css.cjs +1 -1
- package/dist/components/data-display/Accordion/Accordion.module.css.js +16 -16
- package/dist/components/data-display/List/List.cjs.map +1 -1
- package/dist/components/data-display/List/List.js.map +1 -1
- package/dist/components/data-display/List/List.module.css.cjs +1 -1
- package/dist/components/data-display/List/List.module.css.js +34 -24
- package/dist/components/data-display/List/List.module.css.js.map +1 -1
- package/dist/components/data-display/List/ListingOptions.cjs +1 -1
- package/dist/components/data-display/List/ListingOptions.cjs.map +1 -1
- package/dist/components/data-display/List/ListingOptions.js +98 -74
- package/dist/components/data-display/List/ListingOptions.js.map +1 -1
- package/dist/components/data-display/List/useListing.cjs.map +1 -1
- package/dist/components/data-display/List/useListing.js.map +1 -1
- package/dist/components/data-display/SortableList/SortableList.cjs +2 -0
- package/dist/components/data-display/SortableList/SortableList.cjs.map +1 -0
- package/dist/components/data-display/SortableList/SortableList.js +168 -0
- package/dist/components/data-display/SortableList/SortableList.js.map +1 -0
- package/dist/components/data-display/SortableList/SortableList.module.css.cjs +2 -0
- package/dist/components/data-display/SortableList/SortableList.module.css.cjs.map +1 -0
- package/dist/components/data-display/SortableList/SortableList.module.css.js +34 -0
- package/dist/components/data-display/SortableList/SortableList.module.css.js.map +1 -0
- package/dist/components/data-display/Table/Table.cjs +1 -1
- package/dist/components/data-display/Table/Table.cjs.map +1 -1
- package/dist/components/data-display/Table/Table.js +86 -85
- package/dist/components/data-display/Table/Table.js.map +1 -1
- package/dist/components/data-display/Table/Table.module.css.cjs +1 -1
- package/dist/components/data-display/Table/Table.module.css.js +50 -51
- package/dist/components/data-display/Table/Table.module.css.js.map +1 -1
- package/dist/components/data-display/Tag/Tag.cjs +2 -0
- package/dist/components/data-display/Tag/Tag.cjs.map +1 -0
- package/dist/components/data-display/Tag/Tag.js +50 -0
- package/dist/components/data-display/Tag/Tag.js.map +1 -0
- package/dist/components/data-display/Tag/Tag.module.css.cjs +2 -0
- package/dist/components/data-display/Tag/Tag.module.css.cjs.map +1 -0
- package/dist/components/data-display/Tag/Tag.module.css.js +22 -0
- package/dist/components/data-display/Tag/Tag.module.css.js.map +1 -0
- package/dist/components/data-display/Timeline/Timeline.cjs +2 -0
- package/dist/components/data-display/Timeline/Timeline.cjs.map +1 -0
- package/dist/components/data-display/Timeline/Timeline.js +31 -0
- package/dist/components/data-display/Timeline/Timeline.js.map +1 -0
- package/dist/components/data-display/Timeline/Timeline.module.css.cjs +2 -0
- package/dist/components/data-display/Timeline/Timeline.module.css.cjs.map +1 -0
- package/dist/components/data-display/Timeline/Timeline.module.css.js +30 -0
- package/dist/components/data-display/Timeline/Timeline.module.css.js.map +1 -0
- package/dist/components/feedback/Skeleton/Skeleton.cjs +2 -0
- package/dist/components/feedback/Skeleton/Skeleton.cjs.map +1 -0
- package/dist/components/feedback/Skeleton/Skeleton.js +17 -0
- package/dist/components/feedback/Skeleton/Skeleton.js.map +1 -0
- package/dist/components/feedback/Skeleton/Skeleton.module.css.cjs +2 -0
- package/dist/components/feedback/Skeleton/Skeleton.module.css.cjs.map +1 -0
- package/dist/components/feedback/Skeleton/Skeleton.module.css.js +15 -0
- package/dist/components/feedback/Skeleton/Skeleton.module.css.js.map +1 -0
- package/dist/components/feedback/Toast/Toast.module.css.cjs +2 -0
- package/dist/components/feedback/Toast/Toast.module.css.cjs.map +1 -0
- package/dist/components/feedback/Toast/Toast.module.css.js +31 -0
- package/dist/components/feedback/Toast/Toast.module.css.js.map +1 -0
- package/dist/components/feedback/Toast/ToastRegion.cjs +2 -0
- package/dist/components/feedback/Toast/ToastRegion.cjs.map +1 -0
- package/dist/components/feedback/Toast/ToastRegion.js +62 -0
- package/dist/components/feedback/Toast/ToastRegion.js.map +1 -0
- package/dist/components/feedback/Toast/toastStore.cjs +2 -0
- package/dist/components/feedback/Toast/toastStore.cjs.map +1 -0
- package/dist/components/feedback/Toast/toastStore.js +33 -0
- package/dist/components/feedback/Toast/toastStore.js.map +1 -0
- package/dist/components/forms/Checkbox/Checkbox.cjs +1 -1
- package/dist/components/forms/Checkbox/Checkbox.cjs.map +1 -1
- package/dist/components/forms/Checkbox/Checkbox.js +43 -31
- package/dist/components/forms/Checkbox/Checkbox.js.map +1 -1
- package/dist/components/forms/Checkbox/Checkbox.module.css.cjs +1 -1
- package/dist/components/forms/Checkbox/Checkbox.module.css.js +1 -1
- package/dist/components/forms/CheckboxGroup/CheckboxGroup.cjs +2 -0
- package/dist/components/forms/CheckboxGroup/CheckboxGroup.cjs.map +1 -0
- package/dist/components/forms/CheckboxGroup/CheckboxGroup.js +54 -0
- package/dist/components/forms/CheckboxGroup/CheckboxGroup.js.map +1 -0
- package/dist/components/forms/CheckboxGroup/CheckboxGroup.module.css.cjs +2 -0
- package/dist/components/forms/CheckboxGroup/CheckboxGroup.module.css.cjs.map +1 -0
- package/dist/components/forms/CheckboxGroup/CheckboxGroup.module.css.js +22 -0
- package/dist/components/forms/CheckboxGroup/CheckboxGroup.module.css.js.map +1 -0
- package/dist/components/forms/ColorPicker/ColorPicker.cjs +2 -0
- package/dist/components/forms/ColorPicker/ColorPicker.cjs.map +1 -0
- package/dist/components/forms/ColorPicker/ColorPicker.js +57 -0
- package/dist/components/forms/ColorPicker/ColorPicker.js.map +1 -0
- package/dist/components/forms/ColorPicker/ColorPicker.module.css.cjs +2 -0
- package/dist/components/forms/ColorPicker/ColorPicker.module.css.cjs.map +1 -0
- package/dist/components/forms/ColorPicker/ColorPicker.module.css.js +22 -0
- package/dist/components/forms/ColorPicker/ColorPicker.module.css.js.map +1 -0
- package/dist/components/forms/ComboBox/ComboBox.cjs.map +1 -1
- package/dist/components/forms/ComboBox/ComboBox.js.map +1 -1
- package/dist/components/forms/ComboBox/ComboBox.module.css.cjs +1 -1
- package/dist/components/forms/ComboBox/ComboBox.module.css.js +20 -20
- package/dist/components/forms/Field/Field.cjs +1 -1
- package/dist/components/forms/Field/Field.cjs.map +1 -1
- package/dist/components/forms/Field/Field.js +21 -20
- package/dist/components/forms/Field/Field.js.map +1 -1
- package/dist/components/forms/Field/Field.module.css.cjs +1 -1
- package/dist/components/forms/Field/Field.module.css.js +18 -12
- package/dist/components/forms/Field/Field.module.css.js.map +1 -1
- package/dist/components/forms/FileUpload/FileUpload.cjs +2 -0
- package/dist/components/forms/FileUpload/FileUpload.cjs.map +1 -0
- package/dist/components/forms/FileUpload/FileUpload.js +142 -0
- package/dist/components/forms/FileUpload/FileUpload.js.map +1 -0
- package/dist/components/forms/FileUpload/FileUpload.module.css.cjs +2 -0
- package/dist/components/forms/FileUpload/FileUpload.module.css.cjs.map +1 -0
- package/dist/components/forms/FileUpload/FileUpload.module.css.js +46 -0
- package/dist/components/forms/FileUpload/FileUpload.module.css.js.map +1 -0
- package/dist/components/forms/InputPassword/InputPassword.module.css.cjs +1 -1
- package/dist/components/forms/InputPassword/InputPassword.module.css.js +12 -12
- package/dist/components/forms/InputText/InputText.cjs +1 -1
- package/dist/components/forms/InputText/InputText.cjs.map +1 -1
- package/dist/components/forms/InputText/InputText.js +55 -47
- package/dist/components/forms/InputText/InputText.js.map +1 -1
- package/dist/components/forms/InputText/InputText.module.css.cjs +1 -1
- package/dist/components/forms/InputText/InputText.module.css.js +10 -10
- package/dist/components/forms/RadioGroup/RadioGroup.module.css.cjs +1 -1
- package/dist/components/forms/RadioGroup/RadioGroup.module.css.js +4 -4
- package/dist/components/forms/SegmentedControl/SegmentedControl.cjs +2 -0
- package/dist/components/forms/SegmentedControl/SegmentedControl.cjs.map +1 -0
- package/dist/components/forms/SegmentedControl/SegmentedControl.js +52 -0
- package/dist/components/forms/SegmentedControl/SegmentedControl.js.map +1 -0
- package/dist/components/forms/SegmentedControl/SegmentedControl.module.css.cjs +2 -0
- package/dist/components/forms/SegmentedControl/SegmentedControl.module.css.cjs.map +1 -0
- package/dist/components/forms/SegmentedControl/SegmentedControl.module.css.js +22 -0
- package/dist/components/forms/SegmentedControl/SegmentedControl.module.css.js.map +1 -0
- package/dist/components/forms/Select/Select.module.css.cjs +1 -1
- package/dist/components/forms/Select/Select.module.css.js +13 -13
- package/dist/components/forms/Switch/Switch.module.css.cjs +1 -1
- package/dist/components/forms/Switch/Switch.module.css.js +2 -2
- package/dist/components/icons/icons.cjs +1 -1
- package/dist/components/icons/icons.cjs.map +1 -1
- package/dist/components/icons/icons.js +198 -40
- package/dist/components/icons/icons.js.map +1 -1
- package/dist/components/navigation/SkipLink/SkipLink.cjs +2 -0
- package/dist/components/navigation/SkipLink/SkipLink.cjs.map +1 -0
- package/dist/components/navigation/SkipLink/SkipLink.js +9 -0
- package/dist/components/navigation/SkipLink/SkipLink.js.map +1 -0
- package/dist/components/navigation/SkipLink/SkipLink.module.css.cjs +2 -0
- package/dist/components/navigation/SkipLink/SkipLink.module.css.cjs.map +1 -0
- package/dist/components/navigation/SkipLink/SkipLink.module.css.js +8 -0
- package/dist/components/navigation/SkipLink/SkipLink.module.css.js.map +1 -0
- package/dist/components/navigation/Steps/Steps.cjs +2 -0
- package/dist/components/navigation/Steps/Steps.cjs.map +1 -0
- package/dist/components/navigation/Steps/Steps.js +30 -0
- package/dist/components/navigation/Steps/Steps.js.map +1 -0
- package/dist/components/navigation/Steps/Steps.module.css.cjs +2 -0
- package/dist/components/navigation/Steps/Steps.module.css.cjs.map +1 -0
- package/dist/components/navigation/Steps/Steps.module.css.js +26 -0
- package/dist/components/navigation/Steps/Steps.module.css.js.map +1 -0
- package/dist/components/navigation/Tabs/Tabs.cjs +1 -1
- package/dist/components/navigation/Tabs/Tabs.cjs.map +1 -1
- package/dist/components/navigation/Tabs/Tabs.js +88 -79
- package/dist/components/navigation/Tabs/Tabs.js.map +1 -1
- package/dist/components/navigation/Tabs/Tabs.module.css.cjs +1 -1
- package/dist/components/navigation/Tabs/Tabs.module.css.js +18 -14
- package/dist/components/navigation/Tabs/Tabs.module.css.js.map +1 -1
- package/dist/components/navigation/TabsNav/TabsNav.cjs +2 -0
- package/dist/components/navigation/TabsNav/TabsNav.cjs.map +1 -0
- package/dist/components/navigation/TabsNav/TabsNav.js +21 -0
- package/dist/components/navigation/TabsNav/TabsNav.js.map +1 -0
- package/dist/components/navigation/TabsNav/TabsNav.module.css.cjs +2 -0
- package/dist/components/navigation/TabsNav/TabsNav.module.css.cjs.map +1 -0
- package/dist/components/navigation/TabsNav/TabsNav.module.css.js +18 -0
- package/dist/components/navigation/TabsNav/TabsNav.module.css.js.map +1 -0
- package/dist/components/overlays/Dialog/Dialog.cjs +1 -1
- package/dist/components/overlays/Dialog/Dialog.cjs.map +1 -1
- package/dist/components/overlays/Dialog/Dialog.js +11 -58
- package/dist/components/overlays/Dialog/Dialog.js.map +1 -1
- package/dist/components/overlays/Dialog/DialogFrame.cjs +2 -0
- package/dist/components/overlays/Dialog/DialogFrame.cjs.map +1 -0
- package/dist/components/overlays/Dialog/DialogFrame.js +65 -0
- package/dist/components/overlays/Dialog/DialogFrame.js.map +1 -0
- package/dist/components/overlays/Drawer/Drawer.cjs +2 -0
- package/dist/components/overlays/Drawer/Drawer.cjs.map +1 -0
- package/dist/components/overlays/Drawer/Drawer.js +17 -0
- package/dist/components/overlays/Drawer/Drawer.js.map +1 -0
- package/dist/components/overlays/Drawer/Drawer.module.css.cjs +2 -0
- package/dist/components/overlays/Drawer/Drawer.module.css.cjs.map +1 -0
- package/dist/components/overlays/Drawer/Drawer.module.css.js +23 -0
- package/dist/components/overlays/Drawer/Drawer.module.css.js.map +1 -0
- package/dist/components/overlays/Menu/Menu.cjs +1 -1
- package/dist/components/overlays/Menu/Menu.cjs.map +1 -1
- package/dist/components/overlays/Menu/Menu.js +105 -86
- package/dist/components/overlays/Menu/Menu.js.map +1 -1
- package/dist/components/overlays/Menu/Menu.module.css.cjs +1 -1
- package/dist/components/overlays/Menu/Menu.module.css.js +24 -6
- package/dist/components/overlays/Menu/Menu.module.css.js.map +1 -1
- package/dist/design-system.css +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +190 -118
- package/dist/index.js.map +1 -1
- package/dist/types/components/actions/ButtonTile/ButtonTile.d.ts +14 -0
- package/dist/types/components/actions/ButtonTile/index.d.ts +2 -0
- package/dist/types/components/actions/Toolbar/Toolbar.d.ts +27 -0
- package/dist/types/components/actions/Toolbar/index.d.ts +2 -0
- package/dist/types/components/charts/ChartArea/ChartArea.d.ts +15 -4
- package/dist/types/components/charts/ChartBar/ChartBar.d.ts +11 -4
- package/dist/types/components/charts/ChartCombo/ChartCombo.d.ts +16 -4
- package/dist/types/components/charts/ChartDonut/ChartDonut.d.ts +5 -1
- package/dist/types/components/charts/ChartGauge/ChartGauge.d.ts +83 -0
- package/dist/types/components/charts/ChartGauge/gaugeLayout.d.ts +64 -0
- package/dist/types/components/charts/ChartGauge/gaugeReading.d.ts +97 -0
- package/dist/types/components/charts/ChartGauge/gaugeScale.d.ts +38 -0
- package/dist/types/components/charts/ChartGauge/index.d.ts +2 -0
- package/dist/types/components/charts/ChartLine/ChartLine.d.ts +15 -4
- package/dist/types/components/charts/ChartMap/ChartMap.d.ts +104 -0
- package/dist/types/components/charts/ChartMap/ChartMapLegend.d.ts +44 -0
- package/dist/types/components/charts/ChartMap/ChartMapTable.d.ts +38 -0
- package/dist/types/components/charts/ChartMap/index.d.ts +4 -0
- package/dist/types/components/charts/ChartMap/mapGeometry.d.ts +56 -0
- package/dist/types/components/charts/ChartMap/mapLabels.d.ts +51 -0
- package/dist/types/components/charts/ChartMap/mapScales.d.ts +76 -0
- package/dist/types/components/charts/ChartMap/polylabel.d.ts +9 -0
- package/dist/types/components/charts/ChartPie/ChartPie.d.ts +5 -1
- package/dist/types/components/charts/ChartRadial/ChartRadial.d.ts +5 -1
- package/dist/types/components/charts/ChartSankey/ChartSankey.d.ts +5 -1
- package/dist/types/components/charts/ChartScatter/ChartScatter.d.ts +7 -1
- package/dist/types/components/charts/ChartSunburst/ChartSunburst.d.ts +11 -2
- package/dist/types/components/charts/ChartTimeline/ChartTimeline.d.ts +137 -0
- package/dist/types/components/charts/ChartTimeline/ChartTimelineTable.d.ts +25 -0
- package/dist/types/components/charts/ChartTimeline/index.d.ts +2 -0
- package/dist/types/components/charts/ChartTimeline/timelineLayout.d.ts +70 -0
- package/dist/types/components/charts/ChartTimeline/timelineTime.d.ts +16 -0
- package/dist/types/components/charts/ChartTimeline/timelineTooltip.d.ts +45 -0
- package/dist/types/components/charts/ChartTooltip/ChartTooltip.d.ts +2 -0
- package/dist/types/components/charts/ChartTreemap/ChartTreemap.d.ts +11 -2
- package/dist/types/components/charts/ChartWaterfall/ChartWaterfall.d.ts +8 -3
- package/dist/types/components/charts/core/CartesianFrame.d.ts +6 -1
- package/dist/types/components/charts/core/ChartFrame.d.ts +7 -1
- package/dist/types/components/charts/core/ChartLegend.d.ts +3 -1
- package/dist/types/components/charts/core/PointBands.d.ts +22 -0
- package/dist/types/components/charts/core/cartesianLayout.d.ts +10 -4
- package/dist/types/components/charts/core/hoverPath.d.ts +10 -0
- package/dist/types/components/charts/core/index.d.ts +13 -3
- package/dist/types/components/charts/core/pointLabels.d.ts +13 -0
- package/dist/types/components/charts/core/tooltips.d.ts +49 -0
- package/dist/types/components/charts/core/useCartesianLayout.d.ts +20 -0
- package/dist/types/components/charts/core/useSeriesToggle.d.ts +15 -1
- package/dist/types/components/data-display/Accordion/Accordion.d.ts +6 -1
- package/dist/types/components/data-display/Accordion/index.d.ts +1 -1
- package/dist/types/components/data-display/List/List.d.ts +1 -1
- package/dist/types/components/data-display/List/useListing.d.ts +7 -1
- package/dist/types/components/data-display/SortableList/SortableList.d.ts +22 -0
- package/dist/types/components/data-display/SortableList/index.d.ts +2 -0
- package/dist/types/components/data-display/Tag/Tag.d.ts +13 -0
- package/dist/types/components/data-display/Tag/index.d.ts +2 -0
- package/dist/types/components/data-display/Timeline/Timeline.d.ts +15 -0
- package/dist/types/components/data-display/Timeline/index.d.ts +2 -0
- package/dist/types/components/feedback/Skeleton/Skeleton.d.ts +13 -0
- package/dist/types/components/feedback/Skeleton/index.d.ts +2 -0
- package/dist/types/components/feedback/Toast/ToastRegion.d.ts +2 -0
- package/dist/types/components/feedback/Toast/index.d.ts +3 -0
- package/dist/types/components/feedback/Toast/toastStore.d.ts +24 -0
- package/dist/types/components/forms/CheckboxGroup/CheckboxGroup.d.ts +28 -0
- package/dist/types/components/forms/CheckboxGroup/index.d.ts +2 -0
- package/dist/types/components/forms/ColorPicker/ColorPicker.d.ts +26 -0
- package/dist/types/components/forms/ColorPicker/index.d.ts +2 -0
- package/dist/types/components/forms/ComboBox/ComboBox.d.ts +7 -1
- package/dist/types/components/forms/Field/Field.d.ts +6 -2
- package/dist/types/components/forms/Field/index.d.ts +1 -1
- package/dist/types/components/forms/FileUpload/FileUpload.d.ts +37 -0
- package/dist/types/components/forms/FileUpload/index.d.ts +2 -0
- package/dist/types/components/forms/InputText/InputText.d.ts +4 -2
- package/dist/types/components/forms/SegmentedControl/SegmentedControl.d.ts +23 -0
- package/dist/types/components/forms/SegmentedControl/index.d.ts +2 -0
- package/dist/types/components/icons/icons.d.ts +29 -0
- package/dist/types/components/icons/index.d.ts +1 -1
- package/dist/types/components/navigation/SkipLink/SkipLink.d.ts +7 -0
- package/dist/types/components/navigation/SkipLink/index.d.ts +2 -0
- package/dist/types/components/navigation/Steps/Steps.d.ts +16 -0
- package/dist/types/components/navigation/Steps/index.d.ts +2 -0
- package/dist/types/components/navigation/Tabs/Tabs.d.ts +5 -1
- package/dist/types/components/navigation/TabsNav/TabsNav.d.ts +20 -0
- package/dist/types/components/navigation/TabsNav/index.d.ts +2 -0
- package/dist/types/components/overlays/Dialog/Dialog.d.ts +21 -9
- package/dist/types/components/overlays/Dialog/DialogFrame.d.ts +13 -0
- package/dist/types/components/overlays/Drawer/Drawer.d.ts +9 -0
- package/dist/types/components/overlays/Drawer/index.d.ts +2 -0
- package/dist/types/components/overlays/Menu/Menu.d.ts +16 -2
- package/dist/types/components/overlays/Menu/index.d.ts +1 -1
- package/dist/types/index.d.ts +43 -7
- package/dist/types/utils/formatters/formatarDuracao.d.ts +5 -0
- package/dist/types/utils/formatters/formatarNumero.d.ts +6 -1
- package/dist/types/utils/formatters/formatarTamanhoDeArquivo.d.ts +7 -0
- package/dist/types/utils/formatters/index.d.ts +4 -1
- package/dist/utils/formatters/formatarDuracao.cjs +2 -0
- package/dist/utils/formatters/formatarDuracao.cjs.map +1 -0
- package/dist/utils/formatters/formatarDuracao.js +10 -0
- package/dist/utils/formatters/formatarDuracao.js.map +1 -0
- package/dist/utils/formatters/formatarNumero.cjs +1 -1
- package/dist/utils/formatters/formatarNumero.cjs.map +1 -1
- package/dist/utils/formatters/formatarNumero.js +42 -17
- package/dist/utils/formatters/formatarNumero.js.map +1 -1
- package/dist/utils/formatters/formatarTamanhoDeArquivo.cjs +2 -0
- package/dist/utils/formatters/formatarTamanhoDeArquivo.cjs.map +1 -0
- package/dist/utils/formatters/formatarTamanhoDeArquivo.js +17 -0
- package/dist/utils/formatters/formatarTamanhoDeArquivo.js.map +1 -0
- package/package.json +3 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChartMapTable.js","sources":["../../../../src/components/charts/ChartMap/ChartMapTable.tsx"],"sourcesContent":["import { useState } from 'react';\nimport { Button } from '../../actions/Button';\nimport { InputText } from '../../forms/InputText';\nimport { IconSearch } from '../../icons';\nimport styles from './ChartMap.module.css';\n\nexport interface MapTableRegionRow {\n classLabel?: string;\n id: string;\n name: string;\n rank?: number;\n selected: boolean;\n /** Parte do total, de 0 a 1. */\n share?: number;\n value: number | null;\n /** Valor formatado, ou a categoria; sem ele, a celula diz que nao ha dado. */\n valueText?: string;\n}\n\nexport interface MapTableMarkerRow {\n key: string;\n name: string;\n series: string;\n value: string;\n}\n\ntype SortKey = 'name' | 'value' | 'class' | 'share' | 'rank';\n\ninterface ChartMapTableProps {\n formatPercent: (ratio: number) => string;\n markerRows: readonly MapTableMarkerRow[];\n markerValueLabel: string;\n maxHeight?: number;\n noDataLabel: string;\n regionRows: readonly MapTableRegionRow[];\n showClasses: boolean;\n showRank: boolean;\n showShare: boolean;\n showValue: boolean;\n title: string;\n valueLabel: string;\n}\n\n/** Quantas linhas aparecem de cada vez: com 645 municipios, a tabela inteira de uma vez pesaria a pagina. */\nconst PAGE = 50;\n\n/** Ignora caixa e acento, para \"sao paulo\" achar \"São Paulo\". */\nfunction normalized(text: string) {\n return text.normalize('NFD').replace(/\\p{M}/gu, '').toLocaleLowerCase('pt-BR');\n}\n\n/**\n * Leitura completa do mapa: uma linha por regiao, com busca pelo nome e cabecalhos que ordenam. E o caminho ate as\n * regioes de poucos pixels, que o ponteiro e o dedo nao alcancam.\n */\nexport function ChartMapTable({\n formatPercent,\n markerRows,\n markerValueLabel,\n maxHeight,\n noDataLabel,\n regionRows,\n showClasses,\n showRank,\n showShare,\n showValue,\n title,\n valueLabel,\n}: ChartMapTableProps) {\n const numeric = showRank;\n const [query, setQuery] = useState('');\n const [sort, setSort] = useState<{ direction: 'ascending' | 'descending'; key: SortKey }>(\n numeric ? { direction: 'descending', key: 'value' } : { direction: 'ascending', key: 'name' },\n );\n const [limit, setLimit] = useState(PAGE);\n const term = normalized(query.trim());\n const matches = (name: string) => !term || normalized(name).includes(term);\n\n const sortValue = (row: MapTableRegionRow): number | string | undefined => {\n if (sort.key === 'name') {\n return row.name;\n }\n\n if (sort.key === 'value' && !numeric) {\n return row.valueText;\n }\n\n // Faixa, parte do total e posicao seguem o valor: ordenar por elas e ordenar por ele.\n return row.value ?? undefined;\n };\n const sign = sort.direction === 'ascending' ? 1 : -1;\n const rows = regionRows\n .filter((row) => matches(row.name))\n .sort((a, b) => {\n const [first, second] = [sortValue(a), sortValue(b)];\n\n if (first === undefined || second === undefined) {\n // Sem dado vai ao fim, nos dois sentidos.\n return first === second ? 0 : first === undefined ? 1 : -1;\n }\n\n const order =\n typeof first === 'number' && typeof second === 'number'\n ? first - second\n : String(first).localeCompare(String(second), 'pt-BR');\n\n return (sort.key === 'rank' ? -order : order) * sign;\n });\n const markers = markerRows.filter((row) => matches(row.name));\n\n const columns: { key: SortKey; label: string; numeric: boolean }[] = [\n { key: 'name', label: 'Nome', numeric: false },\n ...(showValue ? [{ key: 'value' as const, label: valueLabel, numeric }] : []),\n ...(showClasses ? [{ key: 'class' as const, label: 'Faixa', numeric: false }] : []),\n ...(showShare ? [{ key: 'share' as const, label: '% do total', numeric: true }] : []),\n ...(showRank ? [{ key: 'rank' as const, label: 'Posição', numeric: true }] : []),\n ];\n\n function sortBy(key: SortKey) {\n setSort((current) => ({\n direction: current.key === key && current.direction === 'descending' ? 'ascending' : 'descending',\n key,\n }));\n }\n\n return (\n <div className={styles.tableView}>\n <div className={styles.tableTools}>\n <InputText\n aria-label=\"Buscar pelo nome\"\n icon={<IconSearch />}\n onChange={(event) => {\n setQuery(event.target.value);\n setLimit(PAGE);\n }}\n placeholder=\"Buscar pelo nome\"\n size=\"sm\"\n type=\"search\"\n value={query}\n />\n <span aria-live=\"polite\" className={styles.tableCount}>\n {`${Math.min(limit, rows.length)} de ${rows.length} ${rows.length === 1 ? 'região' : 'regiões'}`}\n </span>\n </div>\n\n <div\n aria-label={`Tabela: ${title}`}\n className={styles.tableScroll}\n role=\"region\"\n style={{ maxHeight }}\n tabIndex={0}\n >\n <table className={styles.table}>\n <caption className={styles.visuallyHidden}>{title}</caption>\n <thead>\n <tr>\n {columns.map((column) => (\n <th\n aria-sort={sort.key === column.key ? sort.direction : undefined}\n className={column.numeric ? styles.numeric : undefined}\n key={column.key}\n scope=\"col\"\n >\n <button className={styles.sortButton} onClick={() => sortBy(column.key)} type=\"button\">\n {column.label}\n {sort.key === column.key && <span aria-hidden=\"true\">{sort.direction === 'ascending' ? ' ↑' : ' ↓'}</span>}\n </button>\n </th>\n ))}\n </tr>\n </thead>\n <tbody>\n {rows.slice(0, limit).map((row) => (\n <tr className={row.selected ? styles.tableSelected : undefined} key={row.id}>\n <th scope=\"row\">{row.name}</th>\n {showValue && (\n <td className={numeric ? styles.numeric : undefined}>\n {row.valueText ?? <span className={styles.tableMuted}>{noDataLabel}</span>}\n </td>\n )}\n {showClasses && <td>{row.classLabel ?? ''}</td>}\n {showShare && <td className={styles.numeric}>{row.share === undefined ? '' : formatPercent(row.share)}</td>}\n {showRank && <td className={styles.numeric}>{row.rank === undefined ? '' : `${row.rank}º`}</td>}\n </tr>\n ))}\n </tbody>\n </table>\n\n {markers.length > 0 && (\n <table className={styles.table}>\n <caption className={styles.tableCaption}>Marcadores</caption>\n <thead>\n <tr>\n <th scope=\"col\">Nome</th>\n <th scope=\"col\">Série</th>\n <th className={styles.numeric} scope=\"col\">\n {markerValueLabel}\n </th>\n </tr>\n </thead>\n <tbody>\n {markers.map((row) => (\n <tr key={row.key}>\n <th scope=\"row\">{row.name}</th>\n <td>{row.series}</td>\n <td className={styles.numeric}>{row.value}</td>\n </tr>\n ))}\n </tbody>\n </table>\n )}\n </div>\n\n {rows.length > limit && (\n <Button onClick={() => setLimit((current) => current + PAGE)} size=\"sm\" variant=\"secondary\">\n {`Mostrar mais ${Math.min(PAGE, rows.length - limit)}`}\n </Button>\n )}\n </div>\n );\n}\n"],"names":["PAGE","normalized","text","ChartMapTable","formatPercent","markerRows","markerValueLabel","maxHeight","noDataLabel","regionRows","showClasses","showRank","showShare","showValue","title","valueLabel","numeric","query","setQuery","useState","sort","setSort","limit","setLimit","term","matches","name","sortValue","row","sign","rows","a","b","first","second","order","markers","columns","sortBy","key","current","jsxs","styles","jsx","InputText","IconSearch","event","column","Button"],"mappings":";;;;;;AA4CA,MAAMA,IAAO;AAGb,SAASC,EAAWC,GAAc;AAChC,SAAOA,EAAK,UAAU,KAAK,EAAE,QAAQ,WAAA,UAAA,IAAA,GAAW,EAAE,EAAE,kBAAkB,OAAO;AAC/E;AAMO,SAASC,EAAc;AAAA,EAC5B,eAAAC;AAAA,EACA,YAAAC;AAAA,EACA,kBAAAC;AAAA,EACA,WAAAC;AAAA,EACA,aAAAC;AAAA,EACA,YAAAC;AAAA,EACA,aAAAC;AAAA,EACA,UAAAC;AAAA,EACA,WAAAC;AAAA,EACA,WAAAC;AAAA,EACA,OAAAC;AAAA,EACA,YAAAC;AACF,GAAu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CAAI,GAAG,MAAK,MAAK,SAAQ,aAC7E,UAAA,gBAAgB,KAAK,IAAIA,GAAM8B,EAAK,SAASR,CAAK,CAAC,GAAA,CACtD;AAAA,EAAA,GAEJ;AAEJ;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("d3-geo"),c=12,g=12,b=2*Math.PI;function l(t,r){return r.split(".").reduce((n,s)=>n!==null&&typeof n=="object"?n[s]:void 0,t)}function x(t){return(t==null?void 0:t.type)==="Polygon"?[t.coordinates]:(t==null?void 0:t.type)==="MultiPolygon"?t.coordinates:[]}function I(t){return x(t).flatMap(r=>{var e;if(!((((e=r[0])==null?void 0:e.length)??0)>=4))return[];const n=r.filter(i=>i.length>=4).map(i=>i.map(o=>[Number(o[0]),Number(o[1])]));return[p.geoArea({type:"Polygon",coordinates:n})>b?n.map(i=>[...i].reverse()):n]})}function O(t){let[r,n,s,e]=[1/0,1/0,-1/0,-1/0];for(const i of t)for(const[o,a]of i[0])[r,n]=[Math.min(r,o),Math.min(n,a)],[s,e]=[Math.max(s,o),Math.max(e,a)];return[[r,n],[s,e]]}function j(t,{idKey:r,labelKey:n,nameKey:s}){return t.features.flatMap(e=>{const i=l(e,r),o=I(e.geometry);if(typeof i!="string"&&typeof i!="number"||o.length===0)return[];const a=String(i),u=l(e,s),f=n===void 0?a:l(e,n);return[{bounds:O(o),feature:e,id:a,label:typeof f=="string"||typeof f=="number"?String(f):a,name:typeof u=="string"&&u?u:a,shape:{geometry:{coordinates:o,type:"MultiPolygon"},properties:null,type:"Feature"}}]})}function y(t){const[[r,n],[s,e]]=t.reduce(([[i,o],[a,u]],{bounds:[[f,M],[d,h]]})=>[[Math.min(i,f),Math.min(o,M)],[Math.max(a,d),Math.max(u,h)]],[[1/0,1/0],[-1/0,-1/0]]);return{coordinates:[[r,n],[s,e]],type:"MultiPoint"}}function v(t,r){const[[n,s],[e,i]]=t.bounds;return[r([n,i])??[0,0],r([e,s])??[0,0]]}function A(t,r){const n=y(t),s=p.geoMercator().fitWidth(Math.max(r-2*c,1),n),[[,e],[,i]]=n.coordinates.map(o=>s(o)??[0,0]);return Math.ceil(Math.abs(i-e)+2*c)}function S(t,r,n,s){const e=[[c,c],[Math.max(n-c,c+1),Math.max(s-c,c+1)]],i=y(t),o=p.geoMercator().fitExtent(e,i);if(t.length===r.length)return o;const a=p.geoMercator().fitExtent(e,y(r)).scale()*g;if(o.scale()>a){o.scale(a);const[[u,f],[M,d]]=i.coordinates.map(P=>o(P)??[0,0]),[h,m]=o.translate();o.translate([h+n/2-(u+M)/2,m+s/2-(f+d)/2])}return o}function _(t,r){return t.shape.geometry.coordinates.map(n=>n.map(s=>{const e=[];for(const i of s){const o=r(i),a=e.at(-1);o&&(!a||Math.abs(o[0]-a[0])+Math.abs(o[1]-a[1])>=1)&&e.push(o)}return e}))}exports.MAP_PADDING=c;exports.MAX_FOCUS_ZOOM=g;exports.fitProjection=S;exports.naturalHeight=A;exports.projectedBounds=v;exports.projectedParts=_;exports.regionsOf=j;exports.valueAt=l;
|
|
2
|
+
//# sourceMappingURL=mapGeometry.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mapGeometry.cjs","sources":["../../../../src/components/charts/ChartMap/mapGeometry.ts"],"sourcesContent":["import { geoArea, geoMercator, type GeoProjection } from 'd3-geo';\nimport type { Point, Ring } from './polylabel';\n\ntype Position = readonly number[];\ntype Polygon = readonly (readonly Position[])[];\n\n/** Feicao GeoJSON. So `Polygon` e `MultiPolygon` se desenham; os demais tipos ficam de fora. */\nexport interface ChartMapFeature {\n geometry: { coordinates?: unknown; type: string } | null;\n id?: string | number;\n properties?: Record<string, unknown> | null;\n}\n\nexport interface ChartMapFeatureCollection {\n features: readonly ChartMapFeature[];\n}\n\n/** A feicao como o d3-geo a desenha: sempre multipoligono, com os aneis validos e no sentido dele. */\nexport interface MapShape {\n geometry: { coordinates: number[][][][]; type: 'MultiPolygon' };\n properties: null;\n type: 'Feature';\n}\n\nexport interface MapRegion {\n /** Caixa em longitude e latitude: oeste-sul e leste-norte. */\n bounds: readonly [Point, Point];\n feature: ChartMapFeature;\n id: string;\n /** Texto curto do rotulo no desenho, como a sigla. */\n label: string;\n name: string;\n shape: MapShape;\n}\n\nexport interface MapKeys {\n idKey: string;\n labelKey?: string;\n nameKey: string;\n}\n\nexport const MAP_PADDING = 12;\n/** Teto do enquadramento do recorte, em vezes o do mapa inteiro: sozinho, o DF ocupava o palco. */\nexport const MAX_FOCUS_ZOOM = 12;\nconst HEMISPHERE = 2 * Math.PI;\n\n/** Le um caminho como `properties.sigla` na feicao. */\nexport function valueAt(source: unknown, path: string): unknown {\n return path\n .split('.')\n .reduce<unknown>(\n (node, key) => (node !== null && typeof node === 'object' ? (node as Record<string, unknown>)[key] : undefined),\n source,\n );\n}\n\nfunction polygonsOf(geometry: ChartMapFeature['geometry']): readonly Polygon[] {\n if (geometry?.type === 'Polygon') {\n return [geometry.coordinates as Polygon];\n }\n\n return geometry?.type === 'MultiPolygon' ? (geometry.coordinates as readonly Polygon[]) : [];\n}\n\n/**\n * Anel com menos de quatro posicoes nao fecha um poligono, e o d3-geo falha nele. O d3-geo le o anel externo no\n * sentido horario, o contrario da RFC 7946: no sentido dela, o poligono viraria o globo menos a regiao.\n */\nfunction validPolygons(geometry: ChartMapFeature['geometry']) {\n return polygonsOf(geometry).flatMap((polygon) => {\n // Sem o anel externo, um furo viraria a regiao.\n if (!((polygon[0]?.length ?? 0) >= 4)) {\n return [];\n }\n\n const rings = polygon\n .filter((ring) => ring.length >= 4)\n .map((ring) => ring.map((position) => [Number(position[0]), Number(position[1])]));\n const inverted = geoArea({ type: 'Polygon', coordinates: rings }) > HEMISPHERE;\n\n return [inverted ? rings.map((ring) => [...ring].reverse()) : rings];\n });\n}\n\nfunction boundsOf(polygons: readonly number[][][][]): readonly [Point, Point] {\n let [west, south, east, north] = [Infinity, Infinity, -Infinity, -Infinity];\n\n for (const polygon of polygons) {\n for (const [longitude, latitude] of polygon[0]) {\n [west, south] = [Math.min(west, longitude), Math.min(south, latitude)];\n [east, north] = [Math.max(east, longitude), Math.max(north, latitude)];\n }\n }\n\n return [\n [west, south],\n [east, north],\n ];\n}\n\n/** Regioes desenhaveis da colecao, cada uma com o identificador, o nome e o rotulo lidos pelos caminhos. */\nexport function regionsOf(collection: ChartMapFeatureCollection, { idKey, labelKey, nameKey }: MapKeys): MapRegion[] {\n return collection.features.flatMap((feature) => {\n const rawId = valueAt(feature, idKey);\n const coordinates = validPolygons(feature.geometry);\n\n if ((typeof rawId !== 'string' && typeof rawId !== 'number') || coordinates.length === 0) {\n return [];\n }\n\n const id = String(rawId);\n const name = valueAt(feature, nameKey);\n const label = labelKey === undefined ? id : valueAt(feature, labelKey);\n\n return [\n {\n bounds: boundsOf(coordinates),\n feature,\n id,\n label: typeof label === 'string' || typeof label === 'number' ? String(label) : id,\n name: typeof name === 'string' && name ? name : id,\n shape: { geometry: { coordinates, type: 'MultiPolygon' }, properties: null, type: 'Feature' },\n },\n ];\n });\n}\n\n/**\n * Os cantos da caixa das regioes. Na Mercator, longitude e latitude projetam cada uma num eixo, entao enquadrar os\n * cantos e enquadrar o desenho, sem percorrer de novo milhares de vertices.\n */\nfunction cornersOf(regions: readonly MapRegion[]) {\n const [[west, south], [east, north]] = regions.reduce<readonly [Point, Point]>(\n ([[w, s], [e, n]], { bounds: [[rw, rs], [re, rn]] }) => [\n [Math.min(w, rw), Math.min(s, rs)],\n [Math.max(e, re), Math.max(n, rn)],\n ],\n [\n [Infinity, Infinity],\n [-Infinity, -Infinity],\n ],\n );\n\n return {\n coordinates: [\n [west, south],\n [east, north],\n ],\n type: 'MultiPoint' as const,\n };\n}\n\n/** Caixa projetada da regiao: oeste-norte em cima a esquerda, leste-sul embaixo a direita. */\nexport function projectedBounds(region: MapRegion, projection: GeoProjection): readonly [Point, Point] {\n const [[west, south], [east, north]] = region.bounds;\n\n return [projection([west, north]) ?? [0, 0], projection([east, south]) ?? [0, 0]];\n}\n\n/** Altura que o desenho pede quando ocupa a largura toda: com ela, nao sobra faixa vazia acima e abaixo. */\nexport function naturalHeight(target: readonly MapRegion[], width: number) {\n const corners = cornersOf(target);\n const projection = geoMercator().fitWidth(Math.max(width - 2 * MAP_PADDING, 1), corners);\n const [[, top], [, bottom]] = corners.coordinates.map((corner) => projection(corner as [number, number]) ?? [0, 0]);\n\n return Math.ceil(Math.abs(bottom - top) + 2 * MAP_PADDING);\n}\n\n/** Projecao que enquadra o recorte na area, com teto de aproximacao relativo ao mapa inteiro. */\nexport function fitProjection(\n target: readonly MapRegion[],\n all: readonly MapRegion[],\n width: number,\n height: number,\n): GeoProjection {\n const extent: [[number, number], [number, number]] = [\n [MAP_PADDING, MAP_PADDING],\n [Math.max(width - MAP_PADDING, MAP_PADDING + 1), Math.max(height - MAP_PADDING, MAP_PADDING + 1)],\n ];\n const corners = cornersOf(target);\n const projection = geoMercator().fitExtent(extent, corners);\n\n if (target.length === all.length) {\n return projection;\n }\n\n const ceiling = geoMercator().fitExtent(extent, cornersOf(all)).scale() * MAX_FOCUS_ZOOM;\n\n if (projection.scale() > ceiling) {\n projection.scale(ceiling);\n const [[x0, y0], [x1, y1]] = corners.coordinates.map((corner) => projection(corner as [number, number]) ?? [0, 0]);\n const [tx, ty] = projection.translate();\n projection.translate([tx + width / 2 - (x0 + x1) / 2, ty + height / 2 - (y0 + y1) / 2]);\n }\n\n return projection;\n}\n\n/**\n * Partes da regiao na tela, sem os vertices a menos de um pixel do anterior: a busca do rotulo percorre centenas de\n * pontos, e nao os milhares da malha.\n */\nexport function projectedParts(region: MapRegion, projection: GeoProjection): Ring[][] {\n return region.shape.geometry.coordinates.map((polygon) =>\n polygon.map((ring) => {\n const points: Point[] = [];\n\n for (const position of ring) {\n const point = projection(position as [number, number]);\n const last = points.at(-1);\n\n if (point && (!last || Math.abs(point[0] - last[0]) + Math.abs(point[1] - last[1]) >= 1)) {\n points.push(point);\n }\n }\n\n return points;\n }),\n );\n}\n"],"names":["MAP_PADDING","MAX_FOCUS_ZOOM","HEMISPHERE","valueAt","source","path","node","key","polygonsOf","geometry","validPolygons","polygon","_a","rings","ring","position","geoArea","boundsOf","polygons","west","south","east","north","longitude","latitude","regionsOf","collection","idKey","labelKey","nameKey","feature","rawId","coordinates","id","name","label","cornersOf","regions","w","s","e","n","rw","rs","re","rn","projectedBounds","region","projection","naturalHeight","target","width","corners","geoMercator","top","bottom","corner","fitProjection","all","height","extent","ceiling","x0","y0","x1","y1","tx","ty","projectedParts","points","point","last"],"mappings":"0GAyCaA,EAAc,GAEdC,EAAiB,GACxBC,EAAa,EAAI,KAAK,GAGrB,SAASC,EAAQC,EAAiBC,EAAuB,CAC9D,OAAOA,EACJ,MAAM,GAAG,EACT,OACC,CAACC,EAAMC,IAASD,IAAS,MAAQ,OAAOA,GAAS,SAAYA,EAAiCC,CAAG,EAAI,OACrGH,CAAA,CAEN,CAEA,SAASI,EAAWC,EAA2D,CAC7E,OAAIA,GAAA,YAAAA,EAAU,QAAS,UACd,CAACA,EAAS,WAAsB,GAGlCA,GAAA,YAAAA,EAAU,QAAS,eAAkBA,EAAS,YAAqC,CAAA,CAC5F,CAMA,SAASC,EAAcD,EAAuC,CAC5D,OAAOD,EAAWC,CAAQ,EAAE,QAASE,GAAY,OAE/C,GAAI,KAAGC,EAAAD,EAAQ,CAAC,IAAT,YAAAC,EAAY,SAAU,IAAM,GACjC,MAAO,CAAA,EAGT,MAAMC,EAAQF,EACX,OAAQG,GAASA,EAAK,QAAU,CAAC,EACjC,IAAKA,GAASA,EAAK,IAAKC,GAAa,CAAC,OAAOA,EAAS,CAAC,CAAC,EAAG,OAAOA,EAAS,CAAC,CAAC,CAAC,CAAC,CAAC,EAGnF,MAAO,CAFUC,EAAAA,QAAQ,CAAE,KAAM,UAAW,YAAaH,CAAA,CAAO,EAAIX,EAEjDW,EAAM,IAAKC,GAAS,CAAC,GAAGA,CAAI,EAAE,QAAA,CAAS,EAAID,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OD,CACT,CAAC,CAAA,CAEL"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { geoArea as x, geoMercator as d } from "d3-geo";
|
|
2
|
+
const c = 12, g = 12, I = 2 * Math.PI;
|
|
3
|
+
function M(t, i) {
|
|
4
|
+
return i.split(".").reduce(
|
|
5
|
+
(n, s) => n !== null && typeof n == "object" ? n[s] : void 0,
|
|
6
|
+
t
|
|
7
|
+
);
|
|
8
|
+
}
|
|
9
|
+
function P(t) {
|
|
10
|
+
return (t == null ? void 0 : t.type) === "Polygon" ? [t.coordinates] : (t == null ? void 0 : t.type) === "MultiPolygon" ? t.coordinates : [];
|
|
11
|
+
}
|
|
12
|
+
function v(t) {
|
|
13
|
+
return P(t).flatMap((i) => {
|
|
14
|
+
var e;
|
|
15
|
+
if (!((((e = i[0]) == null ? void 0 : e.length) ?? 0) >= 4))
|
|
16
|
+
return [];
|
|
17
|
+
const n = i.filter((r) => r.length >= 4).map((r) => r.map((o) => [Number(o[0]), Number(o[1])]));
|
|
18
|
+
return [x({ type: "Polygon", coordinates: n }) > I ? n.map((r) => [...r].reverse()) : n];
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
function O(t) {
|
|
22
|
+
let [i, n, s, e] = [1 / 0, 1 / 0, -1 / 0, -1 / 0];
|
|
23
|
+
for (const r of t)
|
|
24
|
+
for (const [o, a] of r[0])
|
|
25
|
+
[i, n] = [Math.min(i, o), Math.min(n, a)], [s, e] = [Math.max(s, o), Math.max(e, a)];
|
|
26
|
+
return [
|
|
27
|
+
[i, n],
|
|
28
|
+
[s, e]
|
|
29
|
+
];
|
|
30
|
+
}
|
|
31
|
+
function A(t, { idKey: i, labelKey: n, nameKey: s }) {
|
|
32
|
+
return t.features.flatMap((e) => {
|
|
33
|
+
const r = M(e, i), o = v(e.geometry);
|
|
34
|
+
if (typeof r != "string" && typeof r != "number" || o.length === 0)
|
|
35
|
+
return [];
|
|
36
|
+
const a = String(r), u = M(e, s), f = n === void 0 ? a : M(e, n);
|
|
37
|
+
return [
|
|
38
|
+
{
|
|
39
|
+
bounds: O(o),
|
|
40
|
+
feature: e,
|
|
41
|
+
id: a,
|
|
42
|
+
label: typeof f == "string" || typeof f == "number" ? String(f) : a,
|
|
43
|
+
name: typeof u == "string" && u ? u : a,
|
|
44
|
+
shape: { geometry: { coordinates: o, type: "MultiPolygon" }, properties: null, type: "Feature" }
|
|
45
|
+
}
|
|
46
|
+
];
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
function y(t) {
|
|
50
|
+
const [[i, n], [s, e]] = t.reduce(
|
|
51
|
+
([[r, o], [a, u]], { bounds: [[f, l], [p, h]] }) => [
|
|
52
|
+
[Math.min(r, f), Math.min(o, l)],
|
|
53
|
+
[Math.max(a, p), Math.max(u, h)]
|
|
54
|
+
],
|
|
55
|
+
[
|
|
56
|
+
[1 / 0, 1 / 0],
|
|
57
|
+
[-1 / 0, -1 / 0]
|
|
58
|
+
]
|
|
59
|
+
);
|
|
60
|
+
return {
|
|
61
|
+
coordinates: [
|
|
62
|
+
[i, n],
|
|
63
|
+
[s, e]
|
|
64
|
+
],
|
|
65
|
+
type: "MultiPoint"
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
function E(t, i) {
|
|
69
|
+
const [[n, s], [e, r]] = t.bounds;
|
|
70
|
+
return [i([n, r]) ?? [0, 0], i([e, s]) ?? [0, 0]];
|
|
71
|
+
}
|
|
72
|
+
function S(t, i) {
|
|
73
|
+
const n = y(t), s = d().fitWidth(Math.max(i - 2 * c, 1), n), [[, e], [, r]] = n.coordinates.map((o) => s(o) ?? [0, 0]);
|
|
74
|
+
return Math.ceil(Math.abs(r - e) + 2 * c);
|
|
75
|
+
}
|
|
76
|
+
function w(t, i, n, s) {
|
|
77
|
+
const e = [
|
|
78
|
+
[c, c],
|
|
79
|
+
[Math.max(n - c, c + 1), Math.max(s - c, c + 1)]
|
|
80
|
+
], r = y(t), o = d().fitExtent(e, r);
|
|
81
|
+
if (t.length === i.length)
|
|
82
|
+
return o;
|
|
83
|
+
const a = d().fitExtent(e, y(i)).scale() * g;
|
|
84
|
+
if (o.scale() > a) {
|
|
85
|
+
o.scale(a);
|
|
86
|
+
const [[u, f], [l, p]] = r.coordinates.map((b) => o(b) ?? [0, 0]), [h, m] = o.translate();
|
|
87
|
+
o.translate([h + n / 2 - (u + l) / 2, m + s / 2 - (f + p) / 2]);
|
|
88
|
+
}
|
|
89
|
+
return o;
|
|
90
|
+
}
|
|
91
|
+
function H(t, i) {
|
|
92
|
+
return t.shape.geometry.coordinates.map(
|
|
93
|
+
(n) => n.map((s) => {
|
|
94
|
+
const e = [];
|
|
95
|
+
for (const r of s) {
|
|
96
|
+
const o = i(r), a = e.at(-1);
|
|
97
|
+
o && (!a || Math.abs(o[0] - a[0]) + Math.abs(o[1] - a[1]) >= 1) && e.push(o);
|
|
98
|
+
}
|
|
99
|
+
return e;
|
|
100
|
+
})
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
export {
|
|
104
|
+
c as MAP_PADDING,
|
|
105
|
+
g as MAX_FOCUS_ZOOM,
|
|
106
|
+
w as fitProjection,
|
|
107
|
+
S as naturalHeight,
|
|
108
|
+
E as projectedBounds,
|
|
109
|
+
H as projectedParts,
|
|
110
|
+
A as regionsOf,
|
|
111
|
+
M as valueAt
|
|
112
|
+
};
|
|
113
|
+
//# sourceMappingURL=mapGeometry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mapGeometry.js","sources":["../../../../src/components/charts/ChartMap/mapGeometry.ts"],"sourcesContent":["import { geoArea, geoMercator, type GeoProjection } from 'd3-geo';\nimport type { Point, Ring } from './polylabel';\n\ntype Position = readonly number[];\ntype Polygon = readonly (readonly Position[])[];\n\n/** Feicao GeoJSON. So `Polygon` e `MultiPolygon` se desenham; os demais tipos ficam de fora. */\nexport interface ChartMapFeature {\n geometry: { coordinates?: unknown; type: string } | null;\n id?: string | number;\n properties?: Record<string, unknown> | null;\n}\n\nexport interface ChartMapFeatureCollection {\n features: readonly ChartMapFeature[];\n}\n\n/** A feicao como o d3-geo a desenha: sempre multipoligono, com os aneis validos e no sentido dele. */\nexport interface MapShape {\n geometry: { coordinates: number[][][][]; type: 'MultiPolygon' };\n properties: null;\n type: 'Feature';\n}\n\nexport interface MapRegion {\n /** Caixa em longitude e latitude: oeste-sul e leste-norte. */\n bounds: readonly [Point, Point];\n feature: ChartMapFeature;\n id: string;\n /** Texto curto do rotulo no desenho, como a sigla. */\n label: string;\n name: string;\n shape: MapShape;\n}\n\nexport interface MapKeys {\n idKey: string;\n labelKey?: string;\n nameKey: string;\n}\n\nexport const MAP_PADDING = 12;\n/** Teto do enquadramento do recorte, em vezes o do mapa inteiro: sozinho, o DF ocupava o palco. */\nexport const MAX_FOCUS_ZOOM = 12;\nconst HEMISPHERE = 2 * Math.PI;\n\n/** Le um caminho como `properties.sigla` na feicao. */\nexport function valueAt(source: unknown, path: string): unknown {\n return path\n .split('.')\n .reduce<unknown>(\n (node, key) => (node !== null && typeof node === 'object' ? (node as Record<string, unknown>)[key] : undefined),\n source,\n );\n}\n\nfunction polygonsOf(geometry: ChartMapFeature['geometry']): readonly Polygon[] {\n if (geometry?.type === 'Polygon') {\n return [geometry.coordinates as Polygon];\n }\n\n return geometry?.type === 'MultiPolygon' ? (geometry.coordinates as readonly Polygon[]) : [];\n}\n\n/**\n * Anel com menos de quatro posicoes nao fecha um poligono, e o d3-geo falha nele. O d3-geo le o anel externo no\n * sentido horario, o contrario da RFC 7946: no sentido dela, o poligono viraria o globo menos a regiao.\n */\nfunction validPolygons(geometry: ChartMapFeature['geometry']) {\n return polygonsOf(geometry).flatMap((polygon) => {\n // Sem o anel externo, um furo viraria a regiao.\n if (!((polygon[0]?.length ?? 0) >= 4)) {\n return [];\n }\n\n const rings = polygon\n .filter((ring) => ring.length >= 4)\n .map((ring) => ring.map((position) => [Number(position[0]), Number(position[1])]));\n const inverted = geoArea({ type: 'Polygon', coordinates: rings }) > HEMISPHERE;\n\n return [inverted ? rings.map((ring) => [...ring].reverse()) : rings];\n });\n}\n\nfunction boundsOf(polygons: readonly number[][][][]): readonly [Point, Point] {\n let [west, south, east, north] = [Infinity, Infinity, -Infinity, -Infinity];\n\n for (const polygon of polygons) {\n for (const [longitude, latitude] of polygon[0]) {\n [west, south] = [Math.min(west, longitude), Math.min(south, latitude)];\n [east, north] = [Math.max(east, longitude), Math.max(north, latitude)];\n }\n }\n\n return [\n [west, south],\n [east, north],\n ];\n}\n\n/** Regioes desenhaveis da colecao, cada uma com o identificador, o nome e o rotulo lidos pelos caminhos. */\nexport function regionsOf(collection: ChartMapFeatureCollection, { idKey, labelKey, nameKey }: MapKeys): MapRegion[] {\n return collection.features.flatMap((feature) => {\n const rawId = valueAt(feature, idKey);\n const coordinates = validPolygons(feature.geometry);\n\n if ((typeof rawId !== 'string' && typeof rawId !== 'number') || coordinates.length === 0) {\n return [];\n }\n\n const id = String(rawId);\n const name = valueAt(feature, nameKey);\n const label = labelKey === undefined ? id : valueAt(feature, labelKey);\n\n return [\n {\n bounds: boundsOf(coordinates),\n feature,\n id,\n label: typeof label === 'string' || typeof label === 'number' ? String(label) : id,\n name: typeof name === 'string' && name ? name : id,\n shape: { geometry: { coordinates, type: 'MultiPolygon' }, properties: null, type: 'Feature' },\n },\n ];\n });\n}\n\n/**\n * Os cantos da caixa das regioes. Na Mercator, longitude e latitude projetam cada uma num eixo, entao enquadrar os\n * cantos e enquadrar o desenho, sem percorrer de novo milhares de vertices.\n */\nfunction cornersOf(regions: readonly MapRegion[]) {\n const [[west, south], [east, north]] = regions.reduce<readonly [Point, Point]>(\n ([[w, s], [e, n]], { bounds: [[rw, rs], [re, rn]] }) => [\n [Math.min(w, rw), Math.min(s, rs)],\n [Math.max(e, re), Math.max(n, rn)],\n ],\n [\n [Infinity, Infinity],\n [-Infinity, -Infinity],\n ],\n );\n\n return {\n coordinates: [\n [west, south],\n [east, north],\n ],\n type: 'MultiPoint' as const,\n };\n}\n\n/** Caixa projetada da regiao: oeste-norte em cima a esquerda, leste-sul embaixo a direita. */\nexport function projectedBounds(region: MapRegion, projection: GeoProjection): readonly [Point, Point] {\n const [[west, south], [east, north]] = region.bounds;\n\n return [projection([west, north]) ?? [0, 0], projection([east, south]) ?? [0, 0]];\n}\n\n/** Altura que o desenho pede quando ocupa a largura toda: com ela, nao sobra faixa vazia acima e abaixo. */\nexport function naturalHeight(target: readonly MapRegion[], width: number) {\n const corners = cornersOf(target);\n const projection = geoMercator().fitWidth(Math.max(width - 2 * MAP_PADDING, 1), corners);\n const [[, top], [, bottom]] = corners.coordinates.map((corner) => projection(corner as [number, number]) ?? [0, 0]);\n\n return Math.ceil(Math.abs(bottom - top) + 2 * MAP_PADDING);\n}\n\n/** Projecao que enquadra o recorte na area, com teto de aproximacao relativo ao mapa inteiro. */\nexport function fitProjection(\n target: readonly MapRegion[],\n all: readonly MapRegion[],\n width: number,\n height: number,\n): GeoProjection {\n const extent: [[number, number], [number, number]] = [\n [MAP_PADDING, MAP_PADDING],\n [Math.max(width - MAP_PADDING, MAP_PADDING + 1), Math.max(height - MAP_PADDING, MAP_PADDING + 1)],\n ];\n const corners = cornersOf(target);\n const projection = geoMercator().fitExtent(extent, corners);\n\n if (target.length === all.length) {\n return projection;\n }\n\n const ceiling = geoMercator().fitExtent(extent, cornersOf(all)).scale() * MAX_FOCUS_ZOOM;\n\n if (projection.scale() > ceiling) {\n projection.scale(ceiling);\n const [[x0, y0], [x1, y1]] = corners.coordinates.map((corner) => projection(corner as [number, number]) ?? [0, 0]);\n const [tx, ty] = projection.translate();\n projection.translate([tx + width / 2 - (x0 + x1) / 2, ty + height / 2 - (y0 + y1) / 2]);\n }\n\n return projection;\n}\n\n/**\n * Partes da regiao na tela, sem os vertices a menos de um pixel do anterior: a busca do rotulo percorre centenas de\n * pontos, e nao os milhares da malha.\n */\nexport function projectedParts(region: MapRegion, projection: GeoProjection): Ring[][] {\n return region.shape.geometry.coordinates.map((polygon) =>\n polygon.map((ring) => {\n const points: Point[] = [];\n\n for (const position of ring) {\n const point = projection(position as [number, number]);\n const last = points.at(-1);\n\n if (point && (!last || Math.abs(point[0] - last[0]) + Math.abs(point[1] - last[1]) >= 1)) {\n points.push(point);\n }\n }\n\n return points;\n }),\n );\n}\n"],"names":["MAP_PADDING","MAX_FOCUS_ZOOM","HEMISPHERE","valueAt","source","path","node","key","polygonsOf","geometry","validPolygons","polygon","_a","rings","ring","position","geoArea","boundsOf","polygons","west","south","east","north","longitude","latitude","regionsOf","collection","idKey","labelKey","nameKey","feature","rawId","coordinates","id","name","label","cornersOf","regions","w","s","e","n","rw","rs","re","rn","projectedBounds","region","projection","naturalHeight","target","width","corners","geoMercator","top","bottom","corner","fitProjection","all","height","extent","ceiling","x0","y0","x1","y1","tx","ty","projectedParts","points","point","last"],"mappings":";AAyCO,MAAMA,IAAc,IAEdC,IAAiB,IACxBC,IAAa,IAAI,KAAK;AAGrB,SAASC,EAAQC,GAAiBC,GAAuB;AAC9D,SAAOA,EACJ,MAAM,GAAG,EACT;AAAA,IACC,CAACC,GAAMC,MAASD,MAAS,QAAQ,OAAOA,KAAS,WAAYA,EAAiCC,CAAG,IAAI;AAAA,IACrGH;AAAA,EAAA;AAEN;AAEA,SAASI,EAAWC,GAA2D;AAC7E,UAAIA,KAAA,gBAAAA,EAAU,UAAS,YACd,CAACA,EAAS,WAAsB,KAGlCA,KAAA,gBAAAA,EAAU,UAAS,iBAAkBA,EAAS,cAAqC,CAAA;AAC5F;AAMA,SAASC,EAAcD,GAAuC;AAC5D,SAAOD,EAAWC,CAAQ,EAAE,QAAQ,CAACE,MAAY;;AAE/C,QAAI,KAAGC,IAAAD,EAAQ,CAAC,MAAT,gBAAAC,EAAY,WAAU,MAAM;AACjC,aAAO,CAAA;AAGT,UAAMC,IAAQF,EACX,OAAO,CAACG,MAASA,EAAK,UAAU,CAAC,EACjC,IAAI,CAACA,MAASA,EAAK,IAAI,CAACC,MAAa,CAAC,OAAOA,EAAS,CAAC,CAAC,GA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,EAAerB,GAAmBC,GAAqC;AACrF,SAAOD,EAAO,MAAM,SAAS,YAAY;AAAA,IAAI,CAACpC,MAC5CA,EAAQ,IAAI,CAACG,MAAS;AACpB,YAAMuD,IAAkB,CAAA;AAExB,iBAAWtD,KAAYD,GAAM;AAC3B,cAAMwD,IAAQtB,EAAWjC,CAA4B,GAC/CwD,IAAOF,EAAO,GAAG,EAAE;AAEzB,QAAIC,MAAU,CAACC,KAAQ,KAAK,IAAID,EAAM,CAAC,IAAIC,EAAK,CAAC,CAAC,IAAI,KAAK,IAAID,EAAM,CAAC,IAAIC,EAAK,CAAC,CAAC,KAAK,MACpFF,EAAO,KAAKC,CAAK;AAAA,MAErB;AAEA,aAAOD;AAAA,IACT,CAAC;AAAA,EAAA;AAEL;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _=require("./polylabel.cjs"),c=2,U=16,I=5,O=8;function T(o){const e=s=>Math.abs(s.reduce((h,[u,a],f)=>{const[p,y]=s[(f+1)%s.length];return h+u*y-p*a},0))/2;return o.reduce((s,h)=>e(h[0]??[])>e(s[0]??[])?h:s,o[0]??[])}function j(o,e){return e(o.title)+(o.value?I+e(o.value):0)}function q(o,e){const[s,h]=_.polylabel(o.map(u=>u.map(([a,f])=>[a,f*e])));return[s,h/e]}function B(o,e){return o.x<e.x+e.width&&o.x+o.width>e.x&&o.y<e.y+e.height&&o.y+o.height>e.y}function H(o,e){const{lineHeight:s,measure:h}=e,u=new Map,a=t=>(u.has(t)||u.set(t,T(t.parts)),u.get(t)),f=(t,n,l)=>t.parts.some(i=>_.signedDistance(n,l,i)>=0),p=({bounds:[[t,n],[l,i]]})=>(l-t)*(i-n),y=[],g=[],v=[],w=([t,n],l,i)=>({height:s*i+c,width:l+c*2,x:t-l/2-c,y:n-s*i/2-c/2}),C=(t,n)=>{const[l,i]=[t.x+c,t.y+c/2],[d,A]=[t.x+t.width-c,t.y+t.height-c/2];return!y.some(r=>B(t,r))&&[[l,i],[d,i],[l,A],[d,A]].every(([r,m])=>f(n,r,m))};for(const t of[...o].sort((n,l)=>p(l)-p(n))){const n=h(t.title),[[l,i],[d,A]]=t.bounds;if(d-l<n+c*2||A-i<s+c){v.push({candidate:t});continue}const r=q(a(t),(n+c*2)/(s+c)),m=t.value?w(r,Math.max(n,h(t.value)),2):void 0,G=w(r,n,1);m&&C(m,t)?(y.push(m),g.push({id:t.id,title:t.title,value:t.value,x:r[0],y:r[1]})):C(G,t)?(y.push(G),g.push({id:t.id,title:t.title,x:r[0],y:r[1]})):v.push({candidate:t,center:r})}const x=e.calloutStep,D=Math.floor((e.height-O*2)/x);if(!e.callouts||v.length===0)return{callouts:[],inside:g};const[S,W]=o.reduce(([t,n],{bounds:l})=>[Math.min(t,l[0][0]),Math.max(n,l[1][0])],[1/0,-1/0]),L=v.filter(({candidate:{bounds:t}})=>t[0][0]+t[1][0]>=S+W);if(L.length===0||L.length>D)return{callouts:[],inside:g};const V=o.reduce((t,n)=>(a(n)[0]??[]).reduce((l,[i])=>Math.max(l,i),t),-1/0),X=Math.min(e.right,V)+U,M=L.map(({candidate:t,center:n})=>({anchor:n??_.polylabel(a(t)),id:t.id,title:t.title,value:t.value,x:X,y:0})).sort((t,n)=>t.anchor[1]-n.anchor[1]);let P=-1/0;M.forEach(t=>{t.y=Math.max(t.anchor[1],P+x,O+x/2),P=t.y});const E=P-(e.height-O-x/2);return E>0&&M.forEach(t=>{t.y-=E}),{callouts:M,inside:g}}exports.CALLOUT_GAP=U;exports.CALLOUT_VALUE_GAP=I;exports.calloutWidth=j;exports.largestPart=T;exports.planLabels=H;
|
|
2
|
+
//# sourceMappingURL=mapLabels.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mapLabels.cjs","sources":["../../../../src/components/charts/ChartMap/mapLabels.ts"],"sourcesContent":["import { polylabel, signedDistance, type Point, type Ring } from './polylabel';\n\nexport interface LabelCandidate {\n /** Caixa da regiao na tela; as maiores rotulam primeiro. */\n bounds: readonly [Point, Point];\n id: string;\n /** Partes da regiao na tela, cada uma com o anel externo e os furos. So e lida quando a caixa comporta o rotulo. */\n parts: readonly (readonly Ring[])[];\n title: string;\n value?: string;\n}\n\nexport interface LabelPlanOptions {\n /** Leva para a coluna junto ao desenho o rotulo que nao cabe na regiao. */\n callouts: boolean;\n /** Distancia entre dois rotulos seguidos na coluna. */\n calloutStep: number;\n /** Altura do desenho, que limita quantos rotulos a coluna comporta. */\n height: number;\n /** Altura de uma linha de texto do rotulo dentro da regiao. */\n lineHeight: number;\n measure: (text: string) => number;\n /** Borda direita da area de desenho; a coluna nunca passa dela. */\n right: number;\n}\n\nexport interface InsideLabel {\n id: string;\n title: string;\n value?: string;\n x: number;\n y: number;\n}\n\nexport interface CalloutLabel extends InsideLabel {\n anchor: Point;\n}\n\nexport interface LabelPlan {\n callouts: CalloutLabel[];\n inside: InsideLabel[];\n}\n\ninterface Box {\n height: number;\n width: number;\n x: number;\n y: number;\n}\n\nconst BOX_PADDING = 2;\nexport const CALLOUT_GAP = 16;\n/** Espaco entre a sigla e o valor na coluna. */\nexport const CALLOUT_VALUE_GAP = 5;\nconst EDGE = 8;\n\n/** A maior parte da regiao, pela area do anel externo: ilhas, como Fernando de Noronha, nao deslocam o rotulo. */\nexport function largestPart(parts: readonly (readonly Ring[])[]): readonly Ring[] {\n const areaOf = (ring: Ring) =>\n Math.abs(ring.reduce((sum, [x, y], index) => {\n const [nx, ny] = ring[(index + 1) % ring.length];\n return sum + x * ny - nx * y;\n }, 0)) / 2;\n\n return parts.reduce((largest, part) => (areaOf(part[0] ?? []) > areaOf(largest[0] ?? []) ? part : largest), parts[0] ?? []);\n}\n\n/** Largura do rotulo na coluna: a sigla e, ao lado, o valor. */\nexport function calloutWidth(label: Pick<InsideLabel, 'title' | 'value'>, measure: (text: string) => number) {\n return measure(label.title) + (label.value ? CALLOUT_VALUE_GAP + measure(label.value) : 0);\n}\n\n/**\n * Centro visual para um rotulo largo: o poligono e achatado na proporcao do rotulo antes da busca, e o maior circulo\n * interno vira a maior elipse daquela proporcao. Numa cunha como o Acre, o circulo deixava os cantos de fora.\n */\nfunction labelCenter(rings: readonly Ring[], aspect: number): Point {\n const [x, y] = polylabel(rings.map((ring) => ring.map(([px, py]): Point => [px, py * aspect])));\n return [x, y / aspect];\n}\n\nfunction overlaps(a: Box, b: Box) {\n return a.x < b.x + b.width && a.x + a.width > b.x && a.y < b.y + b.height && a.y + a.height > b.y;\n}\n\n/**\n * Onde vai cada rotulo. Da maior regiao para a menor, entra quem cabe inteiro dentro da propria regiao, pelos quatro\n * cantos, sem tocar outro rotulo; sem espaco para o valor, fica so a sigla; sem espaco nem para ela, o rotulo vai para\n * uma coluna junto ao desenho, com linha guia, se a regiao esta na metade junto a ela. Quando a coluna nao comporta\n * todos, como nos municipios, nenhum vai.\n */\nexport function planLabels(candidates: readonly LabelCandidate[], options: LabelPlanOptions): LabelPlan {\n const { lineHeight, measure } = options;\n const mainParts = new Map<LabelCandidate, readonly Ring[]>();\n const mainPartOf = (candidate: LabelCandidate) => {\n if (!mainParts.has(candidate)) {\n mainParts.set(candidate, largestPart(candidate.parts));\n }\n\n return mainParts.get(candidate)!;\n };\n const contains = (candidate: LabelCandidate, x: number, y: number) =>\n candidate.parts.some((part) => signedDistance(x, y, part) >= 0);\n const areaOf = ({ bounds: [[x0, y0], [x1, y1]] }: LabelCandidate) => (x1 - x0) * (y1 - y0);\n const occupied: Box[] = [];\n const inside: InsideLabel[] = [];\n const small: { candidate: LabelCandidate; center?: Point }[] = [];\n\n const boxAt = ([x, y]: Point, width: number, lines: number): Box => ({\n height: lineHeight * lines + BOX_PADDING,\n width: width + BOX_PADDING * 2,\n x: x - width / 2 - BOX_PADDING,\n y: y - (lineHeight * lines) / 2 - BOX_PADDING / 2,\n });\n // A folga separa um rotulo do outro; dentro da regiao basta o texto.\n const fits = (box: Box, candidate: LabelCandidate) => {\n const [left, top] = [box.x + BOX_PADDING, box.y + BOX_PADDING / 2];\n const [right, bottom] = [box.x + box.width - BOX_PADDING, box.y + box.height - BOX_PADDING / 2];\n\n return (\n !occupied.some((other) => overlaps(box, other)) &&\n [\n [left, top],\n [right, top],\n [left, bottom],\n [right, bottom],\n ].every(([x, y]) => contains(candidate, x, y))\n );\n };\n\n for (const candidate of [...candidates].sort((a, b) => areaOf(b) - areaOf(a))) {\n const titleWidth = measure(candidate.title);\n const [[x0, y0], [x1, y1]] = candidate.bounds;\n\n // A caixa da regiao menor que a do rotulo dispensa a busca do centro.\n if (x1 - x0 < titleWidth + BOX_PADDING * 2 || y1 - y0 < lineHeight + BOX_PADDING) {\n small.push({ candidate });\n continue;\n }\n\n const center = labelCenter(mainPartOf(candidate), (titleWidth + BOX_PADDING * 2) / (lineHeight + BOX_PADDING));\n const full = candidate.value\n ? boxAt(center, Math.max(titleWidth, measure(candidate.value)), 2)\n : undefined;\n const short = boxAt(center, titleWidth, 1);\n\n if (full && fits(full, candidate)) {\n occupied.push(full);\n inside.push({ id: candidate.id, title: candidate.title, value: candidate.value, x: center[0], y: center[1] });\n } else if (fits(short, candidate)) {\n occupied.push(short);\n inside.push({ id: candidate.id, title: candidate.title, x: center[0], y: center[1] });\n } else {\n small.push({ candidate, center });\n }\n }\n\n const step = options.calloutStep;\n const capacity = Math.floor((options.height - EDGE * 2) / step);\n\n if (!options.callouts || small.length === 0) {\n return { callouts: [], inside };\n }\n\n // So a metade do desenho junto a coluna vai para ela: do lado oposto, a linha guia cruzaria o mapa inteiro.\n const [left, right] = candidates.reduce(\n ([low, high], { bounds }) => [Math.min(low, bounds[0][0]), Math.max(high, bounds[1][0])],\n [Infinity, -Infinity],\n );\n const nearColumn = small.filter(({ candidate: { bounds } }) => bounds[0][0] + bounds[1][0] >= left + right);\n\n if (nearColumn.length === 0 || nearColumn.length > capacity) {\n return { callouts: [], inside };\n }\n\n // A coluna encosta no desenho pela maior parte das regioes, e nao pelas ilhas nem pela borda do conteiner.\n const drawingRight = candidates.reduce(\n (right, candidate) => (mainPartOf(candidate)[0] ?? []).reduce((edge, [x]) => Math.max(edge, x), right),\n -Infinity,\n );\n const columnX = Math.min(options.right, drawingRight) + CALLOUT_GAP;\n const callouts = nearColumn\n .map(({ candidate, center }) => ({\n anchor: center ?? polylabel(mainPartOf(candidate)),\n id: candidate.id,\n title: candidate.title,\n value: candidate.value,\n x: columnX,\n y: 0,\n }))\n .sort((a, b) => a.anchor[1] - b.anchor[1]);\n\n let previous = -Infinity;\n callouts.forEach((callout) => {\n callout.y = Math.max(callout.anchor[1], previous + step, EDGE + step / 2);\n previous = callout.y;\n });\n\n const overflow = previous - (options.height - EDGE - step / 2);\n if (overflow > 0) {\n callouts.forEach((callout) => {\n callout.y -= overflow;\n });\n }\n\n return { callouts, inside };\n}\n"],"names":["BOX_PADDING","CALLOUT_GAP","CALLOUT_VALUE_GAP","EDGE","largestPart","parts","areaOf","ring","sum","x","y","index","nx","ny","largest","part","calloutWidth","label","measure","labelCenter","rings","aspect","polylabel","px","py","overlaps","a","b","planLabels","candidates","options","lineHeight","mainParts","mainPartOf","candidate","contains","signedDistance","x0","y0","x1","y1","occupied","inside","small","boxAt","width","lines","fits","box","left","top","right","bottom","other","titleWidth","center","full","short","step","capacity","low","high","bounds","nearColumn","drawingRight","edge","columnX","callouts","previous","callout","overflow"],"mappings":"mHAkDMA,EAAc,EACPC,EAAc,GAEdC,EAAoB,EAC3BC,EAAO,EAGN,SAASC,EAAYC,EAAsD,CAChF,MAAMC,EAAUC,GACd,KAAK,IAAIA,EAAK,OAAO,CAACC,EAAK,CAACC,EAAGC,CAAC,EAAGC,IAAU,CAC3C,KAAM,CAACC,EAAIC,CAAE,EAAIN,GAAMI,EAAQ,GAAKJ,EAAK,MAAM,EAC/C,OAAOC,EAAMC,EAAII,EAAKD,EAAKF,CAC7B,EAAG,CAAC,CAAC,EAAI,EAEX,OAAOL,EAAM,OAAO,CAACS,EAASC,IAAUT,EAAOS,EAAK,CAAC,GAAK,EAAE,EAA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AAW,OAC9B,CAACsB,EAAOjB,KAAeD,EAAWC,CAAS,EAAE,CAAC,GAAK,IAAI,OAAO,CAAC+B,EAAM,CAACxD,CAAC,IAAM,KAAK,IAAIwD,EAAMxD,CAAC,EAAG0C,CAAK,EACrG,IAAA,EAEIe,EAAU,KAAK,IAAIpC,EAAQ,MAAOkC,CAAY,EAAI/D,EAClDkE,EAAWJ,EACd,IAAI,CAAC,CAAE,UAAA7B,EAAW,OAAAqB,MAAc,CAC/B,OAAQA,GAAUjC,EAAAA,UAAUW,EAAWC,CAAS,CAAC,EACjD,GAAIA,EAAU,GACd,MAAOA,EAAU,MACjB,MAAOA,EAAU,MACjB,EAAGgC,EACH,EAAG,CAAA,EACH,EACD,KAAK,CAACxC,EAAGC,IAAMD,EAAE,OAAO,CAAC,EAAIC,EAAE,OAAO,CAAC,CAAC,EAE3C,IAAIyC,EAAW,KACfD,EAAS,QAASE,GAAY,CAC5BA,EAAQ,EAAI,KAAK,IAAIA,EAAQ,OAAO,CAAC,EAAGD,EAAWV,EAAMvD,EAAOuD,EAAO,CAAC,EACxEU,EAAWC,EAAQ,CACrB,CAAC,EAED,MAAMC,EAAWF,GAAYtC,EAAQ,OAAS3B,EAAOuD,EAAO,GAC5D,OAAIY,EAAW,GACbH,EAAS,QAASE,GAAY,CAC5BA,EAAQ,GAAKC,CACf,CAAC,EAGI,CAAE,SAAAH,EAAU,OAAAzB,CAAA,CACrB"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { polylabel as D, signedDistance as X } from "./polylabel.js";
|
|
2
|
+
const r = 2, B = 16, H = 5, O = 8;
|
|
3
|
+
function N(o) {
|
|
4
|
+
const n = (s) => Math.abs(s.reduce((l, [u, a], f) => {
|
|
5
|
+
const [p, y] = s[(f + 1) % s.length];
|
|
6
|
+
return l + u * y - p * a;
|
|
7
|
+
}, 0)) / 2;
|
|
8
|
+
return o.reduce((s, l) => n(l[0] ?? []) > n(s[0] ?? []) ? l : s, o[0] ?? []);
|
|
9
|
+
}
|
|
10
|
+
function j(o, n) {
|
|
11
|
+
return n(o.title) + (o.value ? H + n(o.value) : 0);
|
|
12
|
+
}
|
|
13
|
+
function R(o, n) {
|
|
14
|
+
const [s, l] = D(o.map((u) => u.map(([a, f]) => [a, f * n])));
|
|
15
|
+
return [s, l / n];
|
|
16
|
+
}
|
|
17
|
+
function S(o, n) {
|
|
18
|
+
return o.x < n.x + n.width && o.x + o.width > n.x && o.y < n.y + n.height && o.y + o.height > n.y;
|
|
19
|
+
}
|
|
20
|
+
function k(o, n) {
|
|
21
|
+
const { lineHeight: s, measure: l } = n, u = /* @__PURE__ */ new Map(), a = (t) => (u.has(t) || u.set(t, N(t.parts)), u.get(t)), f = (t, e, i) => t.parts.some((c) => X(e, i, c) >= 0), p = ({ bounds: [[t, e], [i, c]] }) => (i - t) * (c - e), y = [], m = [], x = [], P = ([t, e], i, c) => ({
|
|
22
|
+
height: s * c + r,
|
|
23
|
+
width: i + r * 2,
|
|
24
|
+
x: t - i / 2 - r,
|
|
25
|
+
y: e - s * c / 2 - r / 2
|
|
26
|
+
}), E = (t, e) => {
|
|
27
|
+
const [i, c] = [t.x + r, t.y + r / 2], [d, M] = [t.x + t.width - r, t.y + t.height - r / 2];
|
|
28
|
+
return !y.some((h) => S(t, h)) && [
|
|
29
|
+
[i, c],
|
|
30
|
+
[d, c],
|
|
31
|
+
[i, M],
|
|
32
|
+
[d, M]
|
|
33
|
+
].every(([h, g]) => f(e, h, g));
|
|
34
|
+
};
|
|
35
|
+
for (const t of [...o].sort((e, i) => p(i) - p(e))) {
|
|
36
|
+
const e = l(t.title), [[i, c], [d, M]] = t.bounds;
|
|
37
|
+
if (d - i < e + r * 2 || M - c < s + r) {
|
|
38
|
+
x.push({ candidate: t });
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
const h = R(a(t), (e + r * 2) / (s + r)), g = t.value ? P(h, Math.max(e, l(t.value)), 2) : void 0, C = P(h, e, 1);
|
|
42
|
+
g && E(g, t) ? (y.push(g), m.push({ id: t.id, title: t.title, value: t.value, x: h[0], y: h[1] })) : E(C, t) ? (y.push(C), m.push({ id: t.id, title: t.title, x: h[0], y: h[1] })) : x.push({ candidate: t, center: h });
|
|
43
|
+
}
|
|
44
|
+
const v = n.calloutStep, G = Math.floor((n.height - O * 2) / v);
|
|
45
|
+
if (!n.callouts || x.length === 0)
|
|
46
|
+
return { callouts: [], inside: m };
|
|
47
|
+
const [_, U] = o.reduce(
|
|
48
|
+
([t, e], { bounds: i }) => [Math.min(t, i[0][0]), Math.max(e, i[1][0])],
|
|
49
|
+
[1 / 0, -1 / 0]
|
|
50
|
+
), A = x.filter(({ candidate: { bounds: t } }) => t[0][0] + t[1][0] >= _ + U);
|
|
51
|
+
if (A.length === 0 || A.length > G)
|
|
52
|
+
return { callouts: [], inside: m };
|
|
53
|
+
const T = o.reduce(
|
|
54
|
+
(t, e) => (a(e)[0] ?? []).reduce((i, [c]) => Math.max(i, c), t),
|
|
55
|
+
-1 / 0
|
|
56
|
+
), W = Math.min(n.right, T) + B, w = A.map(({ candidate: t, center: e }) => ({
|
|
57
|
+
anchor: e ?? D(a(t)),
|
|
58
|
+
id: t.id,
|
|
59
|
+
title: t.title,
|
|
60
|
+
value: t.value,
|
|
61
|
+
x: W,
|
|
62
|
+
y: 0
|
|
63
|
+
})).sort((t, e) => t.anchor[1] - e.anchor[1]);
|
|
64
|
+
let L = -1 / 0;
|
|
65
|
+
w.forEach((t) => {
|
|
66
|
+
t.y = Math.max(t.anchor[1], L + v, O + v / 2), L = t.y;
|
|
67
|
+
});
|
|
68
|
+
const I = L - (n.height - O - v / 2);
|
|
69
|
+
return I > 0 && w.forEach((t) => {
|
|
70
|
+
t.y -= I;
|
|
71
|
+
}), { callouts: w, inside: m };
|
|
72
|
+
}
|
|
73
|
+
export {
|
|
74
|
+
B as CALLOUT_GAP,
|
|
75
|
+
H as CALLOUT_VALUE_GAP,
|
|
76
|
+
j as calloutWidth,
|
|
77
|
+
N as largestPart,
|
|
78
|
+
k as planLabels
|
|
79
|
+
};
|
|
80
|
+
//# sourceMappingURL=mapLabels.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mapLabels.js","sources":["../../../../src/components/charts/ChartMap/mapLabels.ts"],"sourcesContent":["import { polylabel, signedDistance, type Point, type Ring } from './polylabel';\n\nexport interface LabelCandidate {\n /** Caixa da regiao na tela; as maiores rotulam primeiro. */\n bounds: readonly [Point, Point];\n id: string;\n /** Partes da regiao na tela, cada uma com o anel externo e os furos. So e lida quando a caixa comporta o rotulo. */\n parts: readonly (readonly Ring[])[];\n title: string;\n value?: string;\n}\n\nexport interface LabelPlanOptions {\n /** Leva para a coluna junto ao desenho o rotulo que nao cabe na regiao. */\n callouts: boolean;\n /** Distancia entre dois rotulos seguidos na coluna. */\n calloutStep: number;\n /** Altura do desenho, que limita quantos rotulos a coluna comporta. */\n height: number;\n /** Altura de uma linha de texto do rotulo dentro da regiao. */\n lineHeight: number;\n measure: (text: string) => number;\n /** Borda direita da area de desenho; a coluna nunca passa dela. */\n right: number;\n}\n\nexport interface InsideLabel {\n id: string;\n title: string;\n value?: string;\n x: number;\n y: number;\n}\n\nexport interface CalloutLabel extends InsideLabel {\n anchor: Point;\n}\n\nexport interface LabelPlan {\n callouts: CalloutLabel[];\n inside: InsideLabel[];\n}\n\ninterface Box {\n height: number;\n width: number;\n x: number;\n y: number;\n}\n\nconst BOX_PADDING = 2;\nexport const CALLOUT_GAP = 16;\n/** Espaco entre a sigla e o valor na coluna. */\nexport const CALLOUT_VALUE_GAP = 5;\nconst EDGE = 8;\n\n/** A maior parte da regiao, pela area do anel externo: ilhas, como Fernando de Noronha, nao deslocam o rotulo. */\nexport function largestPart(parts: readonly (readonly Ring[])[]): readonly Ring[] {\n const areaOf = (ring: Ring) =>\n Math.abs(ring.reduce((sum, [x, y], index) => {\n const [nx, ny] = ring[(index + 1) % ring.length];\n return sum + x * ny - nx * y;\n }, 0)) / 2;\n\n return parts.reduce((largest, part) => (areaOf(part[0] ?? []) > areaOf(largest[0] ?? []) ? part : largest), parts[0] ?? []);\n}\n\n/** Largura do rotulo na coluna: a sigla e, ao lado, o valor. */\nexport function calloutWidth(label: Pick<InsideLabel, 'title' | 'value'>, measure: (text: string) => number) {\n return measure(label.title) + (label.value ? CALLOUT_VALUE_GAP + measure(label.value) : 0);\n}\n\n/**\n * Centro visual para um rotulo largo: o poligono e achatado na proporcao do rotulo antes da busca, e o maior circulo\n * interno vira a maior elipse daquela proporcao. Numa cunha como o Acre, o circulo deixava os cantos de fora.\n */\nfunction labelCenter(rings: readonly Ring[], aspect: number): Point {\n const [x, y] = polylabel(rings.map((ring) => ring.map(([px, py]): Point => [px, py * aspect])));\n return [x, y / aspect];\n}\n\nfunction overlaps(a: Box, b: Box) {\n return a.x < b.x + b.width && a.x + a.width > b.x && a.y < b.y + b.height && a.y + a.height > b.y;\n}\n\n/**\n * Onde vai cada rotulo. Da maior regiao para a menor, entra quem cabe inteiro dentro da propria regiao, pelos quatro\n * cantos, sem tocar outro rotulo; sem espaco para o valor, fica so a sigla; sem espaco nem para ela, o rotulo vai para\n * uma coluna junto ao desenho, com linha guia, se a regiao esta na metade junto a ela. Quando a coluna nao comporta\n * todos, como nos municipios, nenhum vai.\n */\nexport function planLabels(candidates: readonly LabelCandidate[], options: LabelPlanOptions): LabelPlan {\n const { lineHeight, measure } = options;\n const mainParts = new Map<LabelCandidate, readonly Ring[]>();\n const mainPartOf = (candidate: LabelCandidate) => {\n if (!mainParts.has(candidate)) {\n mainParts.set(candidate, largestPart(candidate.parts));\n }\n\n return mainParts.get(candidate)!;\n };\n const contains = (candidate: LabelCandidate, x: number, y: number) =>\n candidate.parts.some((part) => signedDistance(x, y, part) >= 0);\n const areaOf = ({ bounds: [[x0, y0], [x1, y1]] }: LabelCandidate) => (x1 - x0) * (y1 - y0);\n const occupied: Box[] = [];\n const inside: InsideLabel[] = [];\n const small: { candidate: LabelCandidate; center?: Point }[] = [];\n\n const boxAt = ([x, y]: Point, width: number, lines: number): Box => ({\n height: lineHeight * lines + BOX_PADDING,\n width: width + BOX_PADDING * 2,\n x: x - width / 2 - BOX_PADDING,\n y: y - (lineHeight * lines) / 2 - BOX_PADDING / 2,\n });\n // A folga separa um rotulo do outro; dentro da regiao basta o texto.\n const fits = (box: Box, candidate: LabelCandidate) => {\n const [left, top] = [box.x + BOX_PADDING, box.y + BOX_PADDING / 2];\n const [right, bottom] = [box.x + box.width - BOX_PADDING, box.y + box.height - BOX_PADDING / 2];\n\n return (\n !occupied.some((other) => overlaps(box, other)) &&\n [\n [left, top],\n [right, top],\n [left, bottom],\n [right, bottom],\n ].every(([x, y]) => contains(candidate, x, y))\n );\n };\n\n for (const candidate of [...candidates].sort((a, b) => areaOf(b) - areaOf(a))) {\n const titleWidth = measure(candidate.title);\n const [[x0, y0], [x1, y1]] = candidate.bounds;\n\n // A caixa da regiao menor que a do rotulo dispensa a busca do centro.\n if (x1 - x0 < titleWidth + BOX_PADDING * 2 || y1 - y0 < lineHeight + BOX_PADDING) {\n small.push({ candidate });\n continue;\n }\n\n const center = labelCenter(mainPartOf(candidate), (titleWidth + BOX_PADDING * 2) / (lineHeight + BOX_PADDING));\n const full = candidate.value\n ? boxAt(center, Math.max(titleWidth, measure(candidate.value)), 2)\n : undefined;\n const short = boxAt(center, titleWidth, 1);\n\n if (full && fits(full, candidate)) {\n occupied.push(full);\n inside.push({ id: candidate.id, title: candidate.title, value: candidate.value, x: center[0], y: center[1] });\n } else if (fits(short, candidate)) {\n occupied.push(short);\n inside.push({ id: candidate.id, title: candidate.title, x: center[0], y: center[1] });\n } else {\n small.push({ candidate, center });\n }\n }\n\n const step = options.calloutStep;\n const capacity = Math.floor((options.height - EDGE * 2) / step);\n\n if (!options.callouts || small.length === 0) {\n return { callouts: [], inside };\n }\n\n // So a metade do desenho junto a coluna vai para ela: do lado oposto, a linha guia cruzaria o mapa inteiro.\n const [left, right] = candidates.reduce(\n ([low, high], { bounds }) => [Math.min(low, bounds[0][0]), Math.max(high, bounds[1][0])],\n [Infinity, -Infinity],\n );\n const nearColumn = small.filter(({ candidate: { bounds } }) => bounds[0][0] + bounds[1][0] >= left + right);\n\n if (nearColumn.length === 0 || nearColumn.length > capacity) {\n return { callouts: [], inside };\n }\n\n // A coluna encosta no desenho pela maior parte das regioes, e nao pelas ilhas nem pela borda do conteiner.\n const drawingRight = candidates.reduce(\n (right, candidate) => (mainPartOf(candidate)[0] ?? []).reduce((edge, [x]) => Math.max(edge, x), right),\n -Infinity,\n );\n const columnX = Math.min(options.right, drawingRight) + CALLOUT_GAP;\n const callouts = nearColumn\n .map(({ candidate, center }) => ({\n anchor: center ?? polylabel(mainPartOf(candidate)),\n id: candidate.id,\n title: candidate.title,\n value: candidate.value,\n x: columnX,\n y: 0,\n }))\n .sort((a, b) => a.anchor[1] - b.anchor[1]);\n\n let previous = -Infinity;\n callouts.forEach((callout) => {\n callout.y = Math.max(callout.anchor[1], previous + step, EDGE + step / 2);\n previous = callout.y;\n });\n\n const overflow = previous - (options.height - EDGE - step / 2);\n if (overflow > 0) {\n callouts.forEach((callout) => {\n callout.y -= overflow;\n });\n }\n\n return { callouts, inside };\n}\n"],"names":["BOX_PADDING","CALLOUT_GAP","CALLOUT_VALUE_GAP","EDGE","largestPart","parts","areaOf","ring","sum","x","y","index","nx","ny","largest","part","calloutWidth","label","measure","labelCenter","rings","aspect","polylabel","px","py","overlaps","a","b","planLabels","candidates","options","lineHeight","mainParts","mainPartOf","candidate","contains","signedDistance","x0","y0","x1","y1","occupied","inside","small","boxAt","width","lines","fits","box","left","top","right","bottom","other","titleWidth","center","full","short","step","capacity","low","high","bounds","nearColumn","drawingRight","edge","columnX","callouts","previous","callout","overflow"],"mappings":";AAkDA,MAAMA,IAAc,GACPC,IAAc,IAEdC,IAAoB,GAC3BC,IAAO;AAGN,SAASC,EAAYC,GAAsD;AAChF,QAAMC,IAAS,CAACC,MACd,KAAK,IAAIA,EAAK,OAAO,CAACC,GAAK,CAACC,GAAG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W,KACbH,EAAS,QAAQ,CAACE,MAAY;AAC5B,IAAAA,EAAQ,KAAKC;AAAA,EACf,CAAC,GAGI,EAAE,UAAAH,GAAU,QAAAzB,EAAA;AACrB;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("d3-array"),O=require("../palette/seriesColor.cjs"),S=[1,2,3,4,5,6,7].map(t=>`var(--pl-chart-sequential-${t})`),f=["negative-3","negative-2","negative-1","center","positive-1","positive-2","positive-3"].map(t=>`var(--pl-chart-diverging-${t})`);function b(t){const l=[15,32,55,78].map(e=>`color-mix(in oklab, ${t} ${e}%, white)`),i=[22,42].map(e=>`color-mix(in oklab, ${t}, black ${e}%)`);return[...l,t,...i]}const y="var(--pl-color-surface-muted)",E=4,$=5,m=t=>Math.min(1,Math.max(0,t));function v(t,l){const i=m(l)*(t.length-1),e=Math.min(Math.floor(i),t.length-2),n=Math.round((i-e)*1e3)/10;return n<=0?t[e]:n>=100?t[e+1]:`color-mix(in oklab, ${t[e+1]} ${n}%, ${t[e]})`}function k(t,l){return t===1?[l[E]]:Array.from({length:t},(i,e)=>l[Math.round(e*6/(t-1))])}function T(t,l){return Array.from({length:t.length+1},(i,e)=>e===0?`Menos de ${l(t[0])}`:e===t.length?`${l(t[e-1])} ou mais`:`${l(t[e-1])} a ${l(t[e])}`)}function M(t,l,i=$){const e=[...l].sort((s,o)=>s-o),n=new Set(e).size,r=Math.min(Math.max(Math.round(i),2),S.length,n),[a=0,c=0]=[e[0],e.at(-1)],u=Array.from({length:Math.max(r-1,0)},(s,o)=>t==="quantile"?h.quantileSorted(e,(o+1)/r):a+(c-a)*(o+1)/r);return[...new Set(u)].filter(s=>s>a)}function p(t,l,i,e,n){const r=k(t.length+1,n),[a,c]=i,u=t.length===0?[l[0]??(a===c?e(a):`${e(a)} a ${e(c)}`)]:T(t,e).map((o,d)=>l[d]??o),s=o=>h.bisectRight(t,o);return{entries:u.map((o,d)=>({color:r[d],key:String(d),label:o})),fillOf:({value:o})=>o===null?void 0:r[s(o)],keyOf:({value:o})=>o===null?void 0:String(s(o)),labelOf:({value:o})=>o===null?void 0:u[s(o)],numeric:!0}}function g(t,l,i){return{entries:[],fillOf:({value:e})=>e===null?void 0:v(t,l(e)),gradient:i,keyOf:()=>{},labelOf:()=>{},numeric:!0}}function w(t,l,i){const[e=0,n=0]=h.extent(l),[r,a]=t.domain??[e,n],c=r>0?r:l.reduce((s,o)=>o>0?Math.min(s,o):s,a),u=t.log?s=>s<=0||a<=c?0:m((Math.log(s)-Math.log(c))/(Math.log(a)-Math.log(c))):s=>a===r?1:m((s-r)/(a-r));return g(i,u,{log:t.log===!0,position:u,stops:i,ticks:[{position:0,value:t.log?c:r},{position:1,value:a}]})}function L(t,l){const i=t.center??0,[e=i,n=i]=t.domain??h.extent(l),r=Math.max(Math.abs(e-i),Math.abs(n-i))||1,a=c=>m((c-i)/r/2+.5);return g(f,a,{log:!1,position:a,stops:f,ticks:[{position:0,value:i-r},{position:.5,value:i},{position:1,value:i+r}]})}function N(t,l){const i=O.resolveSeriesColors(t,{accent:l}),e=new Map(t.map((n,r)=>[n.id,{color:i[r],label:n.label}]));return{entries:t.map((n,r)=>({color:i[r],key:n.id,label:n.label})),fillOf:({category:n})=>{var r;return n===null||(r=e.get(n))==null?void 0:r.color},keyOf:({category:n})=>n!==null&&e.has(n)?n:void 0,labelOf:({category:n})=>{var r;return n===null||(r=e.get(n))==null?void 0:r.label},numeric:!1}}function _(t,l,i,e){if(t.type==="none")return{entries:[],fillOf:()=>y,keyOf:()=>{},labelOf:()=>{},numeric:!1};if(t.type==="categorical")return N(t.categories,e);const n=t.type!=="diverging"&&t.color?b(t.color):S;if(l.length===0)return{entries:[],fillOf:()=>{},keyOf:()=>{},labelOf:()=>{},numeric:!0};const[r=0,a=0]=h.extent(l),c=t.type==="classes"&&"thresholds"in t;if(r===a&&t.type!=="diverging"&&!c)return p([],[],[r,a],i,n);if(t.type==="sequential")return w(t,l,n);if(t.type==="diverging")return L(t,l);if("thresholds"in t){const u=[...new Set(t.thresholds.filter(Number.isFinite))].sort((s,o)=>s-o);return p(u,t.labels??[],[r,a],i,n)}return p(M(t.method,l,t.count),[],[r,a],i,n)}exports.DIVERGING_TOKENS=f;exports.SEQUENTIAL_TOKENS=S;exports.buildMapScale=_;exports.classThresholds=M;exports.rampColor=v;exports.rampFrom=b;
|
|
2
|
+
//# sourceMappingURL=mapScales.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mapScales.cjs","sources":["../../../../src/components/charts/ChartMap/mapScales.ts"],"sourcesContent":["import { bisectRight, extent, quantileSorted } from 'd3-array';\nimport { resolveSeriesColors, type SeriesAppearance } from '../palette';\n\nexport interface ChartMapCategory extends SeriesAppearance {\n id: string;\n label: string;\n}\n\n/** `color` troca o azul da rampa por outra cor, de que saem os sete tons: mais escuro é maior, nos dois temas. */\nexport type ChartMapColorScale =\n | { color?: string; domain?: readonly [number, number]; log?: boolean; type: 'sequential' }\n | { center?: number; domain?: readonly [number, number]; type: 'diverging' }\n | { color?: string; count?: number; method: 'quantile' | 'equalInterval'; type: 'classes' }\n | { color?: string; labels?: readonly string[]; thresholds: readonly number[]; type: 'classes' }\n | { categories: readonly ChartMapCategory[]; type: 'categorical' }\n | { type: 'none' };\n\nexport interface MapDatum {\n category: string | null;\n value: number | null;\n}\n\n/** Uma faixa ou categoria da legenda, que liga e desliga as regioes dela pela chave. */\nexport interface MapScaleEntry {\n color: string;\n key: string;\n label: string;\n}\n\nexport interface MapGradient {\n log: boolean;\n /** Posicao do valor na barra, de 0 a 1. */\n position: (value: number) => number;\n stops: readonly string[];\n ticks: readonly { position: number; value: number }[];\n}\n\nexport interface MapScale {\n entries: readonly MapScaleEntry[];\n /** Cor da regiao; `undefined` quando ela fica sem dado. */\n fillOf: (datum: MapDatum) => string | undefined;\n gradient?: MapGradient;\n /** Chave da faixa ou da categoria da regiao, quando a legenda as controla. */\n keyOf: (datum: MapDatum) => string | undefined;\n /** Nome da faixa ou da categoria, para o balao e a tabela. */\n labelOf: (datum: MapDatum) => string | undefined;\n /** A cor mede um valor; na categorica e na nenhuma, ela so nomeia ou nao diz nada. */\n numeric: boolean;\n}\n\nexport const SEQUENTIAL_TOKENS = [1, 2, 3, 4, 5, 6, 7].map((step) => `var(--pl-chart-sequential-${step})`);\nexport const DIVERGING_TOKENS = ['negative-3', 'negative-2', 'negative-1', 'center', 'positive-1', 'positive-2', 'positive-3'].map(\n (step) => `var(--pl-chart-diverging-${step})`,\n);\n\n/** Os sete tons a partir de uma cor: clareada até ela, depois escurecida. A mistura acompanha a cor, token ou não. */\nexport function rampFrom(color: string) {\n const lighter = [15, 32, 55, 78].map((share) => `color-mix(in oklab, ${color} ${share}%, white)`);\n const darker = [22, 42].map((share) => `color-mix(in oklab, ${color}, black ${share}%)`);\n\n return [...lighter, color, ...darker];\n}\n\nconst NEUTRAL_FILL = 'var(--pl-color-surface-muted)';\nconst SINGLE_VALUE_STEP = 4;\nconst DEFAULT_CLASS_COUNT = 5;\n\nconst clamp01 = (value: number) => Math.min(1, Math.max(0, value));\n\n/** Cor na posicao da rampa de tokens; entre dois passos, a mistura deles, que segue o tema sozinha. */\nexport function rampColor(stops: readonly string[], position: number) {\n const scaled = clamp01(position) * (stops.length - 1);\n const index = Math.min(Math.floor(scaled), stops.length - 2);\n const share = Math.round((scaled - index) * 1000) / 10;\n\n if (share <= 0) {\n return stops[index];\n }\n\n if (share >= 100) {\n return stops[index + 1];\n }\n\n return `color-mix(in oklab, ${stops[index + 1]} ${share}%, ${stops[index]})`;\n}\n\n/** Passo da rampa de cada classe, espalhado do primeiro ao ultimo. */\nfunction classColors(count: number, stops: readonly string[]) {\n if (count === 1) {\n return [stops[SINGLE_VALUE_STEP]];\n }\n\n return Array.from({ length: count }, (_, index) => stops[Math.round((index * 6) / (count - 1))]);\n}\n\nfunction classLabels(thresholds: readonly number[], format: (value: number) => string) {\n return Array.from({ length: thresholds.length + 1 }, (_, index) => {\n if (index === 0) {\n return `Menos de ${format(thresholds[0])}`;\n }\n\n if (index === thresholds.length) {\n return `${format(thresholds[index - 1])} ou mais`;\n }\n\n return `${format(thresholds[index - 1])} a ${format(thresholds[index])}`;\n });\n}\n\n/** Limites das faixas calculadas. Com menos valores distintos que faixas, elas diminuem, em vez de sobrar vazias. */\nexport function classThresholds(\n method: 'quantile' | 'equalInterval',\n values: readonly number[],\n requested = DEFAULT_CLASS_COUNT,\n) {\n const sorted = [...values].sort((a, b) => a - b);\n const distinct = new Set(sorted).size;\n const count = Math.min(Math.max(Math.round(requested), 2), SEQUENTIAL_TOKENS.length, distinct);\n const [low = 0, high = 0] = [sorted[0], sorted.at(-1)];\n const cuts = Array.from({ length: Math.max(count - 1, 0) }, (_, index) =>\n method === 'quantile' ? quantileSorted(sorted, (index + 1) / count)! : low + ((high - low) * (index + 1)) / count,\n );\n\n // O limite igual ao menor valor deixaria a primeira faixa vazia; repetido, deixaria a do meio.\n return [...new Set(cuts)].filter((cut) => cut > low);\n}\n\nfunction classScale(\n thresholds: readonly number[],\n labels: readonly string[],\n range: readonly [number, number],\n format: (value: number) => string,\n stops: readonly string[],\n): MapScale {\n const colors = classColors(thresholds.length + 1, stops);\n const [low, high] = range;\n const names =\n thresholds.length === 0\n ? [labels[0] ?? (low === high ? format(low) : `${format(low)} a ${format(high)}`)]\n : classLabels(thresholds, format).map((label, index) => labels[index] ?? label);\n const classOf = (value: number) => bisectRight(thresholds, value);\n\n return {\n entries: names.map((label, index) => ({ color: colors[index], key: String(index), label })),\n fillOf: ({ value }) => (value === null ? undefined : colors[classOf(value)]),\n keyOf: ({ value }) => (value === null ? undefined : String(classOf(value))),\n labelOf: ({ value }) => (value === null ? undefined : names[classOf(value)]),\n numeric: true,\n };\n}\n\nfunction continuousScale(stops: readonly string[], position: (value: number) => number, gradient: MapGradient): MapScale {\n return {\n entries: [],\n fillOf: ({ value }) => (value === null ? undefined : rampColor(stops, position(value))),\n gradient,\n keyOf: () => undefined,\n labelOf: () => undefined,\n numeric: true,\n };\n}\n\nfunction sequentialScale(\n config: Extract<ChartMapColorScale, { type: 'sequential' }>,\n values: readonly number[],\n stops: readonly string[],\n): MapScale {\n const [dataLow = 0, dataHigh = 0] = extent(values);\n const [low, high] = config.domain ?? [dataLow, dataHigh];\n // Na logaritmica, o que nao for positivo encosta no primeiro passo.\n const logLow = low > 0 ? low : values.reduce((least, value) => (value > 0 ? Math.min(least, value) : least), high);\n const position = config.log\n ? (value: number) =>\n value <= 0 || high <= logLow ? 0 : clamp01((Math.log(value) - Math.log(logLow)) / (Math.log(high) - Math.log(logLow)))\n : (value: number) => (high === low ? 1 : clamp01((value - low) / (high - low)));\n\n return continuousScale(stops, position, {\n log: config.log === true,\n position,\n stops,\n ticks: [\n { position: 0, value: config.log ? logLow : low },\n { position: 1, value: high },\n ],\n });\n}\n\nfunction divergingScale(\n config: Extract<ChartMapColorScale, { type: 'diverging' }>,\n values: readonly number[],\n): MapScale {\n const center = config.center ?? 0;\n const [low = center, high = center] = config.domain ?? extent(values);\n // O dominio e simetrico em torno do centro: a mesma distancia pinta a mesma intensidade dos dois lados.\n const reach = Math.max(Math.abs(low - center), Math.abs(high - center)) || 1;\n const position = (value: number) => clamp01((value - center) / reach / 2 + 0.5);\n\n return continuousScale(DIVERGING_TOKENS, position, {\n log: false,\n position,\n stops: DIVERGING_TOKENS,\n ticks: [\n { position: 0, value: center - reach },\n { position: 0.5, value: center },\n { position: 1, value: center + reach },\n ],\n });\n}\n\nfunction categoricalScale(categories: readonly ChartMapCategory[], accent?: string): MapScale {\n const colors = resolveSeriesColors(categories, { accent });\n const byId = new Map(categories.map((category, index) => [category.id, { color: colors[index], label: category.label }]));\n\n return {\n entries: categories.map((category, index) => ({ color: colors[index], key: category.id, label: category.label })),\n fillOf: ({ category }) => (category === null ? undefined : byId.get(category)?.color),\n keyOf: ({ category }) => (category !== null && byId.has(category) ? category : undefined),\n labelOf: ({ category }) => (category === null ? undefined : byId.get(category)?.label),\n numeric: false,\n };\n}\n\n/**\n * Escala de cor das regioes, sobre os valores validos das regioes em jogo. As cores sao tokens, ou a mistura de dois\n * deles: a troca de tema repinta o mapa sem calculo algum.\n */\nexport function buildMapScale(\n config: ChartMapColorScale,\n values: readonly number[],\n format: (value: number) => string,\n accent?: string,\n): MapScale {\n if (config.type === 'none') {\n return {\n entries: [],\n fillOf: () => NEUTRAL_FILL,\n keyOf: () => undefined,\n labelOf: () => undefined,\n numeric: false,\n };\n }\n\n if (config.type === 'categorical') {\n return categoricalScale(config.categories, accent);\n }\n\n const stops = config.type !== 'diverging' && config.color ? rampFrom(config.color) : SEQUENTIAL_TOKENS;\n\n if (values.length === 0) {\n return { entries: [], fillOf: () => undefined, keyOf: () => undefined, labelOf: () => undefined, numeric: true };\n }\n\n const [low = 0, high = 0] = extent(values);\n const fixedClasses = config.type === 'classes' && 'thresholds' in config;\n\n // Um valor so nao forma escala: uma cor e uma entrada na legenda.\n if (low === high && config.type !== 'diverging' && !fixedClasses) {\n return classScale([], [], [low, high], format, stops);\n }\n\n if (config.type === 'sequential') {\n return sequentialScale(config, values, stops);\n }\n\n if (config.type === 'diverging') {\n return divergingScale(config, values);\n }\n\n if ('thresholds' in config) {\n const thresholds = [...new Set(config.thresholds.filter(Number.isFinite))].sort((a, b) => a - b);\n return classScale(thresholds, config.labels ?? [], [low, high], format, stops);\n }\n\n return classScale(classThresholds(config.method, values, config.count), [], [low, high], format, stops);\n}\n"],"names":["SEQUENTIAL_TOKENS","step","DIVERGING_TOKENS","rampFrom","color","lighter","share","darker","NEUTRAL_FILL","SINGLE_VALUE_STEP","DEFAULT_CLASS_COUNT","clamp01","value","rampColor","stops","position","scaled","index","classColors","count","_","classLabels","thresholds","format","classThresholds","method","values","requested","sorted","a","b","distinct","low","high","cuts","quantileSorted","cut","classScale","labels","range","colors","names","label","classOf","bisectRight","continuousScale","gradient","sequentialScale","config","dataLow","dataHigh","extent","logLow","least","divergingScale","center","reach","categoricalScale","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I,GAAI,CAACL,EAAKC,CAAI,EAAGV,EAAQT,CAAK,EAGtD,GAAIkC,EAAO,OAAS,aAClB,OAAOD,EAAgBC,EAAQtB,EAAQZ,CAAK,EAG9C,GAAIkC,EAAO,OAAS,YAClB,OAAOM,EAAeN,EAAQtB,CAAM,EAGtC,GAAI,eAAgBsB,EAAQ,CAC1B,MAAM1B,EAAa,CAAC,GAAG,IAAI,IAAI0B,EAAO,WAAW,OAAO,OAAO,QAAQ,CAAC,CAAC,EAAE,KAAK,CAACnB,EAAGC,IAAMD,EAAIC,CAAC,EAC/F,OAAOO,EAAWf,EAAY0B,EAAO,QAAU,CAAA,EAAI,CAAChB,EAAKC,CAAI,EAAGV,EAAQT,CAAK,CAC/E,CAEA,OAAOuB,EAAWb,EAAgBwB,EAAO,OAAQtB,EAAQsB,EAAO,KAAK,EAAG,CAAA,EAAI,CAAChB,EAAKC,CAAI,EAAGV,EAAQT,CAAK,CACxG"}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { extent as p, quantileSorted as M, bisectRight as g } from "d3-array";
|
|
2
|
+
import { resolveSeriesColors as S } from "../palette/seriesColor.js";
|
|
3
|
+
const v = [1, 2, 3, 4, 5, 6, 7].map((t) => `var(--pl-chart-sequential-${t})`), f = ["negative-3", "negative-2", "negative-1", "center", "positive-1", "positive-2", "positive-3"].map(
|
|
4
|
+
(t) => `var(--pl-chart-diverging-${t})`
|
|
5
|
+
);
|
|
6
|
+
function O(t) {
|
|
7
|
+
const r = [15, 32, 55, 78].map((e) => `color-mix(in oklab, ${t} ${e}%, white)`), i = [22, 42].map((e) => `color-mix(in oklab, ${t}, black ${e}%)`);
|
|
8
|
+
return [...r, t, ...i];
|
|
9
|
+
}
|
|
10
|
+
const $ = "var(--pl-color-surface-muted)", k = 4, w = 5, m = (t) => Math.min(1, Math.max(0, t));
|
|
11
|
+
function y(t, r) {
|
|
12
|
+
const i = m(r) * (t.length - 1), e = Math.min(Math.floor(i), t.length - 2), n = Math.round((i - e) * 1e3) / 10;
|
|
13
|
+
return n <= 0 ? t[e] : n >= 100 ? t[e + 1] : `color-mix(in oklab, ${t[e + 1]} ${n}%, ${t[e]})`;
|
|
14
|
+
}
|
|
15
|
+
function L(t, r) {
|
|
16
|
+
return t === 1 ? [r[k]] : Array.from({ length: t }, (i, e) => r[Math.round(e * 6 / (t - 1))]);
|
|
17
|
+
}
|
|
18
|
+
function E(t, r) {
|
|
19
|
+
return Array.from({ length: t.length + 1 }, (i, e) => e === 0 ? `Menos de ${r(t[0])}` : e === t.length ? `${r(t[e - 1])} ou mais` : `${r(t[e - 1])} a ${r(t[e])}`);
|
|
20
|
+
}
|
|
21
|
+
function _(t, r, i = w) {
|
|
22
|
+
const e = [...r].sort((s, o) => s - o), n = new Set(e).size, l = Math.min(Math.max(Math.round(i), 2), v.length, n), [a = 0, c = 0] = [e[0], e.at(-1)], u = Array.from(
|
|
23
|
+
{ length: Math.max(l - 1, 0) },
|
|
24
|
+
(s, o) => t === "quantile" ? M(e, (o + 1) / l) : a + (c - a) * (o + 1) / l
|
|
25
|
+
);
|
|
26
|
+
return [...new Set(u)].filter((s) => s > a);
|
|
27
|
+
}
|
|
28
|
+
function d(t, r, i, e, n) {
|
|
29
|
+
const l = L(t.length + 1, n), [a, c] = i, u = t.length === 0 ? [r[0] ?? (a === c ? e(a) : `${e(a)} a ${e(c)}`)] : E(t, e).map((o, h) => r[h] ?? o), s = (o) => g(t, o);
|
|
30
|
+
return {
|
|
31
|
+
entries: u.map((o, h) => ({ color: l[h], key: String(h), label: o })),
|
|
32
|
+
fillOf: ({ value: o }) => o === null ? void 0 : l[s(o)],
|
|
33
|
+
keyOf: ({ value: o }) => o === null ? void 0 : String(s(o)),
|
|
34
|
+
labelOf: ({ value: o }) => o === null ? void 0 : u[s(o)],
|
|
35
|
+
numeric: !0
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function b(t, r, i) {
|
|
39
|
+
return {
|
|
40
|
+
entries: [],
|
|
41
|
+
fillOf: ({ value: e }) => e === null ? void 0 : y(t, r(e)),
|
|
42
|
+
gradient: i,
|
|
43
|
+
keyOf: () => {
|
|
44
|
+
},
|
|
45
|
+
labelOf: () => {
|
|
46
|
+
},
|
|
47
|
+
numeric: !0
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
function A(t, r, i) {
|
|
51
|
+
const [e = 0, n = 0] = p(r), [l, a] = t.domain ?? [e, n], c = l > 0 ? l : r.reduce((s, o) => o > 0 ? Math.min(s, o) : s, a), u = t.log ? (s) => s <= 0 || a <= c ? 0 : m((Math.log(s) - Math.log(c)) / (Math.log(a) - Math.log(c))) : (s) => a === l ? 1 : m((s - l) / (a - l));
|
|
52
|
+
return b(i, u, {
|
|
53
|
+
log: t.log === !0,
|
|
54
|
+
position: u,
|
|
55
|
+
stops: i,
|
|
56
|
+
ticks: [
|
|
57
|
+
{ position: 0, value: t.log ? c : l },
|
|
58
|
+
{ position: 1, value: a }
|
|
59
|
+
]
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
function N(t, r) {
|
|
63
|
+
const i = t.center ?? 0, [e = i, n = i] = t.domain ?? p(r), l = Math.max(Math.abs(e - i), Math.abs(n - i)) || 1, a = (c) => m((c - i) / l / 2 + 0.5);
|
|
64
|
+
return b(f, a, {
|
|
65
|
+
log: !1,
|
|
66
|
+
position: a,
|
|
67
|
+
stops: f,
|
|
68
|
+
ticks: [
|
|
69
|
+
{ position: 0, value: i - l },
|
|
70
|
+
{ position: 0.5, value: i },
|
|
71
|
+
{ position: 1, value: i + l }
|
|
72
|
+
]
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
function T(t, r) {
|
|
76
|
+
const i = S(t, { accent: r }), e = new Map(t.map((n, l) => [n.id, { color: i[l], label: n.label }]));
|
|
77
|
+
return {
|
|
78
|
+
entries: t.map((n, l) => ({ color: i[l], key: n.id, label: n.label })),
|
|
79
|
+
fillOf: ({ category: n }) => {
|
|
80
|
+
var l;
|
|
81
|
+
return n === null || (l = e.get(n)) == null ? void 0 : l.color;
|
|
82
|
+
},
|
|
83
|
+
keyOf: ({ category: n }) => n !== null && e.has(n) ? n : void 0,
|
|
84
|
+
labelOf: ({ category: n }) => {
|
|
85
|
+
var l;
|
|
86
|
+
return n === null || (l = e.get(n)) == null ? void 0 : l.label;
|
|
87
|
+
},
|
|
88
|
+
numeric: !1
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
function q(t, r, i, e) {
|
|
92
|
+
if (t.type === "none")
|
|
93
|
+
return {
|
|
94
|
+
entries: [],
|
|
95
|
+
fillOf: () => $,
|
|
96
|
+
keyOf: () => {
|
|
97
|
+
},
|
|
98
|
+
labelOf: () => {
|
|
99
|
+
},
|
|
100
|
+
numeric: !1
|
|
101
|
+
};
|
|
102
|
+
if (t.type === "categorical")
|
|
103
|
+
return T(t.categories, e);
|
|
104
|
+
const n = t.type !== "diverging" && t.color ? O(t.color) : v;
|
|
105
|
+
if (r.length === 0)
|
|
106
|
+
return { entries: [], fillOf: () => {
|
|
107
|
+
}, keyOf: () => {
|
|
108
|
+
}, labelOf: () => {
|
|
109
|
+
}, numeric: !0 };
|
|
110
|
+
const [l = 0, a = 0] = p(r), c = t.type === "classes" && "thresholds" in t;
|
|
111
|
+
if (l === a && t.type !== "diverging" && !c)
|
|
112
|
+
return d([], [], [l, a], i, n);
|
|
113
|
+
if (t.type === "sequential")
|
|
114
|
+
return A(t, r, n);
|
|
115
|
+
if (t.type === "diverging")
|
|
116
|
+
return N(t, r);
|
|
117
|
+
if ("thresholds" in t) {
|
|
118
|
+
const u = [...new Set(t.thresholds.filter(Number.isFinite))].sort((s, o) => s - o);
|
|
119
|
+
return d(u, t.labels ?? [], [l, a], i, n);
|
|
120
|
+
}
|
|
121
|
+
return d(_(t.method, r, t.count), [], [l, a], i, n);
|
|
122
|
+
}
|
|
123
|
+
export {
|
|
124
|
+
f as DIVERGING_TOKENS,
|
|
125
|
+
v as SEQUENTIAL_TOKENS,
|
|
126
|
+
q as buildMapScale,
|
|
127
|
+
_ as classThresholds,
|
|
128
|
+
y as rampColor,
|
|
129
|
+
O as rampFrom
|
|
130
|
+
};
|
|
131
|
+
//# sourceMappingURL=mapScales.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mapScales.js","sources":["../../../../src/components/charts/ChartMap/mapScales.ts"],"sourcesContent":["import { bisectRight, extent, quantileSorted } from 'd3-array';\nimport { resolveSeriesColors, type SeriesAppearance } from '../palette';\n\nexport interface ChartMapCategory extends SeriesAppearance {\n id: string;\n label: string;\n}\n\n/** `color` troca o azul da rampa por outra cor, de que saem os sete tons: mais escuro é maior, nos dois temas. */\nexport type ChartMapColorScale =\n | { color?: string; domain?: readonly [number, number]; log?: boolean; type: 'sequential' }\n | { center?: number; domain?: readonly [number, number]; type: 'diverging' }\n | { color?: string; count?: number; method: 'quantile' | 'equalInterval'; type: 'classes' }\n | { color?: string; labels?: readonly string[]; thresholds: readonly number[]; type: 'classes' }\n | { categories: readonly ChartMapCategory[]; type: 'categorical' }\n | { type: 'none' };\n\nexport interface MapDatum {\n category: string | null;\n value: number | null;\n}\n\n/** Uma faixa ou categoria da legenda, que liga e desliga as regioes dela pela chave. */\nexport interface MapScaleEntry {\n color: string;\n key: string;\n label: string;\n}\n\nexport interface MapGradient {\n log: boolean;\n /** Posicao do valor na barra, de 0 a 1. */\n position: (value: number) => number;\n stops: readonly string[];\n ticks: readonly { position: number; value: number }[];\n}\n\nexport interface MapScale {\n entries: readonly MapScaleEntry[];\n /** Cor da regiao; `undefined` quando ela fica sem dado. */\n fillOf: (datum: MapDatum) => string | undefined;\n gradient?: MapGradient;\n /** Chave da faixa ou da categoria da regiao, quando a legenda as controla. */\n keyOf: (datum: MapDatum) => string | undefined;\n /** Nome da faixa ou da categoria, para o balao e a tabela. */\n labelOf: (datum: MapDatum) => string | undefined;\n /** A cor mede um valor; na categorica e na nenhuma, ela so nomeia ou nao diz nada. */\n numeric: boolean;\n}\n\nexport const SEQUENTIAL_TOKENS = [1, 2, 3, 4, 5, 6, 7].map((step) => `var(--pl-chart-sequential-${step})`);\nexport const DIVERGING_TOKENS = ['negative-3', 'negative-2', 'negative-1', 'center', 'positive-1', 'positive-2', 'positive-3'].map(\n (step) => `var(--pl-chart-diverging-${step})`,\n);\n\n/** Os sete tons a partir de uma cor: clareada até ela, depois escurecida. A mistura acompanha a cor, token ou não. */\nexport function rampFrom(color: string) {\n const lighter = [15, 32, 55, 78].map((share) => `color-mix(in oklab, ${color} ${share}%, white)`);\n const darker = [22, 42].map((share) => `color-mix(in oklab, ${color}, black ${share}%)`);\n\n return [...lighter, color, ...darker];\n}\n\nconst NEUTRAL_FILL = 'var(--pl-color-surface-muted)';\nconst SINGLE_VALUE_STEP = 4;\nconst DEFAULT_CLASS_COUNT = 5;\n\nconst clamp01 = (value: number) => Math.min(1, Math.max(0, value));\n\n/** Cor na posicao da rampa de tokens; entre dois passos, a mistura deles, que segue o tema sozinha. */\nexport function rampColor(stops: readonly string[], position: number) {\n const scaled = clamp01(position) * (stops.length - 1);\n const index = Math.min(Math.floor(scaled), stops.length - 2);\n const share = Math.round((scaled - index) * 1000) / 10;\n\n if (share <= 0) {\n return stops[index];\n }\n\n if (share >= 100) {\n return stops[index + 1];\n }\n\n return `color-mix(in oklab, ${stops[index + 1]} ${share}%, ${stops[index]})`;\n}\n\n/** Passo da rampa de cada classe, espalhado do primeiro ao ultimo. */\nfunction classColors(count: number, stops: readonly string[]) {\n if (count === 1) {\n return [stops[SINGLE_VALUE_STEP]];\n }\n\n return Array.from({ length: count }, (_, index) => stops[Math.round((index * 6) / (count - 1))]);\n}\n\nfunction classLabels(thresholds: readonly number[], format: (value: number) => string) {\n return Array.from({ length: thresholds.length + 1 }, (_, index) => {\n if (index === 0) {\n return `Menos de ${format(thresholds[0])}`;\n }\n\n if (index === thresholds.length) {\n return `${format(thresholds[index - 1])} ou mais`;\n }\n\n return `${format(thresholds[index - 1])} a ${format(thresholds[index])}`;\n });\n}\n\n/** Limites das faixas calculadas. Com menos valores distintos que faixas, elas diminuem, em vez de sobrar vazias. */\nexport function classThresholds(\n method: 'quantile' | 'equalInterval',\n values: readonly number[],\n requested = DEFAULT_CLASS_COUNT,\n) {\n const sorted = [...values].sort((a, b) => a - b);\n const distinct = new Set(sorted).size;\n const count = Math.min(Math.max(Math.round(requested), 2), SEQUENTIAL_TOKENS.length, distinct);\n const [low = 0, high = 0] = [sorted[0], sorted.at(-1)];\n const cuts = Array.from({ length: Math.max(count - 1, 0) }, (_, index) =>\n method === 'quantile' ? quantileSorted(sorted, (index + 1) / count)! : low + ((high - low) * (index + 1)) / count,\n );\n\n // O limite igual ao menor valor deixaria a primeira faixa vazia; repetido, deixaria a do meio.\n return [...new Set(cuts)].filter((cut) => cut > low);\n}\n\nfunction classScale(\n thresholds: readonly number[],\n labels: readonly string[],\n range: readonly [number, number],\n format: (value: number) => string,\n stops: readonly string[],\n): MapScale {\n const colors = classColors(thresholds.length + 1, stops);\n const [low, high] = range;\n const names =\n thresholds.length === 0\n ? [labels[0] ?? (low === high ? format(low) : `${format(low)} a ${format(high)}`)]\n : classLabels(thresholds, format).map((label, index) => labels[index] ?? label);\n const classOf = (value: number) => bisectRight(thresholds, value);\n\n return {\n entries: names.map((label, index) => ({ color: colors[index], key: String(index), label })),\n fillOf: ({ value }) => (value === null ? undefined : colors[classOf(value)]),\n keyOf: ({ value }) => (value === null ? undefined : String(classOf(value))),\n labelOf: ({ value }) => (value === null ? undefined : names[classOf(value)]),\n numeric: true,\n };\n}\n\nfunction continuousScale(stops: readonly string[], position: (value: number) => number, gradient: MapGradient): MapScale {\n return {\n entries: [],\n fillOf: ({ value }) => (value === null ? undefined : rampColor(stops, position(value))),\n gradient,\n keyOf: () => undefined,\n labelOf: () => undefined,\n numeric: true,\n };\n}\n\nfunction sequentialScale(\n config: Extract<ChartMapColorScale, { type: 'sequential' }>,\n values: readonly number[],\n stops: readonly string[],\n): MapScale {\n const [dataLow = 0, dataHigh = 0] = extent(values);\n const [low, high] = config.domain ?? [dataLow, dataHigh];\n // Na logaritmica, o que nao for positivo encosta no primeiro passo.\n const logLow = low > 0 ? low : values.reduce((least, value) => (value > 0 ? Math.min(least, value) : least), high);\n const position = config.log\n ? (value: number) =>\n value <= 0 || high <= logLow ? 0 : clamp01((Math.log(value) - Math.log(logLow)) / (Math.log(high) - Math.log(logLow)))\n : (value: number) => (high === low ? 1 : clamp01((value - low) / (high - low)));\n\n return continuousScale(stops, position, {\n log: config.log === true,\n position,\n stops,\n ticks: [\n { position: 0, value: config.log ? logLow : low },\n { position: 1, value: high },\n ],\n });\n}\n\nfunction divergingScale(\n config: Extract<ChartMapColorScale, { type: 'diverging' }>,\n values: readonly number[],\n): MapScale {\n const center = config.center ?? 0;\n const [low = center, high = center] = config.domain ?? extent(values);\n // O dominio e simetrico em torno do centro: a mesma distancia pinta a mesma intensidade dos dois lados.\n const reach = Math.max(Math.abs(low - center), Math.abs(high - center)) || 1;\n const position = (value: number) => clamp01((value - center) / reach / 2 + 0.5);\n\n return continuousScale(DIVERGING_TOKENS, position, {\n log: false,\n position,\n stops: DIVERGING_TOKENS,\n ticks: [\n { position: 0, value: center - reach },\n { position: 0.5, value: center },\n { position: 1, value: center + reach },\n ],\n });\n}\n\nfunction categoricalScale(categories: readonly ChartMapCategory[], accent?: string): MapScale {\n const colors = resolveSeriesColors(categories, { accent });\n const byId = new Map(categories.map((category, index) => [category.id, { color: colors[index], label: category.label }]));\n\n return {\n entries: categories.map((category, index) => ({ color: colors[index], key: category.id, label: category.label })),\n fillOf: ({ category }) => (category === null ? undefined : byId.get(category)?.color),\n keyOf: ({ category }) => (category !== null && byId.has(category) ? category : undefined),\n labelOf: ({ category }) => (category === null ? undefined : byId.get(category)?.label),\n numeric: false,\n };\n}\n\n/**\n * Escala de cor das regioes, sobre os valores validos das regioes em jogo. As cores sao tokens, ou a mistura de dois\n * deles: a troca de tema repinta o mapa sem calculo algum.\n */\nexport function buildMapScale(\n config: ChartMapColorScale,\n values: readonly number[],\n format: (value: number) => string,\n accent?: string,\n): MapScale {\n if (config.type === 'none') {\n return {\n entries: [],\n fillOf: () => NEUTRAL_FILL,\n keyOf: () => undefined,\n labelOf: () => undefined,\n numeric: false,\n };\n }\n\n if (config.type === 'categorical') {\n return categoricalScale(config.categories, accent);\n }\n\n const stops = config.type !== 'diverging' && config.color ? rampFrom(config.color) : SEQUENTIAL_TOKENS;\n\n if (values.length === 0) {\n return { entries: [], fillOf: () => undefined, keyOf: () => undefined, labelOf: () => undefined, numeric: true };\n }\n\n const [low = 0, high = 0] = extent(values);\n const fixedClasses = config.type === 'classes' && 'thresholds' in config;\n\n // Um valor so nao forma escala: uma cor e uma entrada na legenda.\n if (low === high && config.type !== 'diverging' && !fixedClasses) {\n return classScale([], [], [low, high], format, stops);\n }\n\n if (config.type === 'sequential') {\n return sequentialScale(config, values, stops);\n }\n\n if (config.type === 'diverging') {\n return divergingScale(config, values);\n }\n\n if ('thresholds' in config) {\n const thresholds = [...new Set(config.thresholds.filter(Number.isFinite))].sort((a, b) => a - b);\n return classScale(thresholds, config.labels ?? [], [low, high], format, stops);\n }\n\n return classScale(classThresholds(config.method, values, config.count), [], [low, high], format, stops);\n}\n"],"names":["SEQUENTIAL_TOKENS","step","DIVERGING_TOKENS","rampFrom","color","lighter","share","darker","NEUTRAL_FILL","SINGLE_VALUE_STEP","DEFAULT_CLASS_COUNT","clamp01","value","rampColor","stops","position","scaled","index","classColors","count","_","classLabels","thresholds","format","classThresholds","method","values","requested","sorted","a","b","distinct","low","high","cuts","quantileSorted","cut","classScale","labels","range","colors","names","label","classOf","bisectRight","continuousScale","gradient","sequentialScale","config","dataLow","dataHigh","extent","logLow","least","divergingScale","center","reach","categoricalScale","categories","accent","resolveSeriesColors","byId","category","_a","buildMapScale","fixedClasses"],"mappings":";;AAkDO,MAAMA,IAAoB,CAAC,GAAG,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC,EAAE,IAAI,CAACC,MAAS,6BAA6BA,CAAI,GAAG,G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M,GAAGC,IAAO,CAAC,IAAIkB,EAAOzB,CAAM,GACnCuC,IAAejB,EAAO,SAAS,aAAa,gBAAgBA;AAGlE,MAAIhB,MAAQC,KAAQe,EAAO,SAAS,eAAe,CAACiB;AAClD,WAAO5B,EAAW,CAAA,GAAI,IAAI,CAACL,GAAKC,CAAI,GAAGV,GAAQT,CAAK;AAGtD,MAAIkC,EAAO,SAAS;AAClB,WAAOD,EAAgBC,GAAQtB,GAAQZ,CAAK;AAG9C,MAAIkC,EAAO,SAAS;AAClB,WAAOM,EAAeN,GAAQtB,CAAM;AAGtC,MAAI,gBAAgBsB,GAAQ;AAC1B,UAAM1B,IAAa,CAAC,GAAG,IAAI,IAAI0B,EAAO,WAAW,OAAO,OAAO,QAAQ,CAAC,CAAC,EAAE,KAAK,CAACnB,GAAGC,MAAMD,IAAIC,CAAC;AAC/F,WAAOO,EAAWf,GAAY0B,EAAO,UAAU,CAAA,GAAI,CAAChB,GAAKC,CAAI,GAAGV,GAAQT,CAAK;AAAA,EAC/E;AAEA,SAAOuB,EAAWb,EAAgBwB,EAAO,QAAQtB,GAAQsB,EAAO,KAAK,GAAG,CAAA,GAAI,CAAChB,GAAKC,CAAI,GAAGV,GAAQT,CAAK;AACxG;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function p(i,f,[o,l],[s,a]){const e=s-o,c=a-l,h=e===0&&c===0?0:Math.max(0,Math.min(1,((i-o)*e+(f-l)*c)/(e*e+c*c))),u=o+e*h,n=l+c*h;return(i-u)**2+(f-n)**2}function m(i,f,o){let l=!1,s=1/0;for(const a of o)for(let e=0,c=a.length-1;e<a.length;c=e,e+=1){const[h,u]=a[e],[n,t]=a[c];u>f!=t>f&&i<(n-h)*(f-u)/(t-u)+h&&(l=!l),s=Math.min(s,p(i,f,a[e],a[c]))}return(l?1:-1)*Math.sqrt(s)}function r(i,f,o,l){const s=m(i,f,l);return{distance:s,half:o,potential:s+o*Math.SQRT2,x:i,y:f}}function x(i,f=1){let[o,l,s,a]=[1/0,1/0,-1/0,-1/0];for(const[n,t]of i[0]??[])[o,l,s,a]=[Math.min(o,n),Math.min(l,t),Math.max(s,n),Math.max(a,t)];const e=Math.min(s-o,a-l);if(!(e>0))return Number.isFinite(o)?[o,l]:[0,0];const c=[],h=n=>{let t=0,d=c.length;for(;t<d;){const y=t+d>>1;c[y].potential<n.potential?t=y+1:d=y}c.splice(t,0,n)};for(let n=o;n<s;n+=e)for(let t=l;t<a;t+=e)h(r(n+e/2,t+e/2,e/2,i));let u=r((o+s)/2,(l+a)/2,0,i);for(;c.length>0;){const n=c.pop();if(n.distance>u.distance&&(u=n),n.potential-u.distance<=f)continue;const t=n.half/2;h(r(n.x-t,n.y-t,t,i)),h(r(n.x+t,n.y-t,t,i)),h(r(n.x-t,n.y+t,t,i)),h(r(n.x+t,n.y+t,t,i))}return[u.x,u.y]}exports.polylabel=x;exports.signedDistance=m;
|
|
2
|
+
//# sourceMappingURL=polylabel.cjs.map
|