@ta-interaktiv/react-swissmap
v2.2.0
Published
A d3 map of Switzerland. Useful for showing data for all municipalities
Downloads
22
Readme
@ta-interaktiv/react-swissmap
A choropleth map of switzerland. Using @ta-interaktiv/react-municipality-search
Usage
const reactSwissmap = require('@ta-interaktiv/react-swissmap');
const [hoveredData, setHoveredData] = useState()
const [activeMunicipalityId, setActiveMunicipalityId] = useState<number>(261)
const ToolTip: React.FC = ({ activeData }): ReactElement => {
return (
<div>
{activeData && (
<div>
<h4>{activeData.Gemeindename}</h4>
<div>Belastung: {activeData.Belastung + '%'}</div>
<div>Belastung: {(activeData.Belastung / 100) * currentIncome}</div>
</div>
)}
</div>
)
}
...
// inside your JSX
{dummyData && (
<SwissMap
municipalityData={dummyData.municipalities}
propertyNameToCompare='Belastung'
minValue={dummyData.extent[0]}
maxValue={dummyData.extent[1]}
municipalitySearchYear="2020"
topoJsonYear={2020}
hoverHandler={newData => {
setHoveredData(newData)
}}
newActiveMunicipalityIdHandler={newID => {
setActiveMunicipalityId(newID)
}}
activeMunicipalityId={activeMunicipalityId}
ToolTip={ToolTip}
/>
)
}