Integrating D3.js with React by Elad Elrom

Integrating D3.js with React by Elad Elrom

Author:Elad Elrom
Language: eng
Format: epub
ISBN: 9781484270523
Publisher: Apress


const RotatingRoundWorldMapWithCoordinates = () => {

const [geographies, setGeographies] = useState<[] | Array<Feature<Geometry | null>>>([])

const [rotation, setRotation] = useState<number>(initRotation)

const [isRotate, setIsRotate] = useState<Boolean>(false)

useEffect(() => {

if (geographies.length === 0) {

fetch('/data/world-110m.json').then((response) => {

if (response.status !== 200) {

// eslint-disable-next-line no-console

console.log(`Houston we have a problem: ${response.status}`)

return

}

response.json().then((worldData) => {

const mapFeatures: Array<Feature<Geometry | null>> = ((feature(worldData, worldData.objects.countries) as unknown) as FeatureCollection).features

setGeographies(mapFeatures)

})

})

}

}, [])



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.