From 34162c0c2a49cb2085f3296bca38249417bba301 Mon Sep 17 00:00:00 2001
From: Chris Manciero
Date: Thu, 23 May 2024 13:11:31 -0400
Subject: [PATCH 001/350] basic 2d map
---
src/app.jsx | 3 ++
src/pages/dashboard/index.js | 61 ++++++++++++++++++++++++++++++++
src/pages/dashboard/selectors.js | 35 ++++++++++++++++++
src/router.ts | 5 +++
4 files changed, 104 insertions(+)
create mode 100644 src/pages/dashboard/index.js
create mode 100644 src/pages/dashboard/selectors.js
diff --git a/src/app.jsx b/src/app.jsx
index cd31b4268..bbabbff37 100644
--- a/src/app.jsx
+++ b/src/app.jsx
@@ -31,6 +31,7 @@ const FeaturedGlobe = loadable(() => import('pages/featured-globe'));
const NationalReportCard = loadable(() => import('pages/nrc'));
const NationalReportCardLanding = loadable(() => import('pages/nrc-landing'));
const AreaOfInterest = loadable(() => import('pages/aoi'));
+const DashboardComponent = loadable(() => import('pages/dashboard'));
const mapStateToProps = ({ location }) => ({
route: location.routesMap[location.type],
@@ -62,6 +63,8 @@ function AppLayout(props) {
);
case 'aoi':
return ;
+ case 'dashboard':
+ return ;
default:
return isMobile ? : ;
}
diff --git a/src/pages/dashboard/index.js b/src/pages/dashboard/index.js
new file mode 100644
index 000000000..df5ca8c5a
--- /dev/null
+++ b/src/pages/dashboard/index.js
@@ -0,0 +1,61 @@
+import React, { useEffect, useState } from 'react';
+import { connect } from 'react-redux';
+
+import { loadModules } from 'esri-loader';
+
+import * as urlActions from 'actions/url-actions';
+
+import Logo from 'components/half-earth-logo';
+
+import { SATELLITE_BASEMAP_LAYER } from 'constants/layers-slugs';
+
+import uiStyles from 'styles/ui.module.scss';
+
+import mapStateToProps from './selectors';
+
+const actions = { ...urlActions };
+
+const { REACT_APP_ARGISJS_API_VERSION: API_VERSION } = process.env;
+
+function DashboardComponent(props) {
+ const [map, setMap] = useState(null);
+ const [view, setView] = useState(null);
+
+ useEffect(() => {
+ loadModules(['esri/Map', 'esri/views/MapView'], {
+ url: `https://js.arcgis.com/${API_VERSION}`,
+ })
+ .then(([Map, MapView]) => {
+ const myMap = new Map({
+ basemap: SATELLITE_BASEMAP_LAYER,
+ });
+
+ const myView = new MapView({
+ map: myMap,
+ center: [-118.805, 34.027], // Longitude, latitude
+ zoom: 13, // Zoom level
+ container: 'map',
+ });
+ setView(myView);
+ setMap(myMap);
+ console.log(map);
+ console.log(view);
+ })
+ .catch((err) => {
+ console.error(err);
+ });
+ }, []);
+
+ console.log(props);
+ return (
+ <>
+
+
+ >
+ );
+}
+
+export default connect(mapStateToProps, actions)(DashboardComponent);
diff --git a/src/pages/dashboard/selectors.js b/src/pages/dashboard/selectors.js
new file mode 100644
index 000000000..e6865f665
--- /dev/null
+++ b/src/pages/dashboard/selectors.js
@@ -0,0 +1,35 @@
+import { createSelector, createStructuredSelector } from 'reselect';
+
+const selectCountryIso = ({ location }) => location.payload.iso.toUpperCase();
+const selectCountriesData = ({ countryData }) =>
+ countryData && countryData.data;
+
+const getCountryData = createSelector(
+ [selectCountriesData, selectCountryIso],
+ (countriesData, countryISO) => {
+ if (!countriesData || !countryISO) {
+ return null;
+ }
+ return countriesData[countryISO];
+ }
+);
+
+const getCountryName = createSelector([getCountryData], (countryData) => {
+ if (!countryData) {
+ return null;
+ }
+ return countryData.NAME_0;
+});
+
+const getCountryId = createSelector([getCountryData], (countryData) => {
+ if (!countryData) {
+ return null;
+ }
+ return countryData.OBJECTID;
+});
+
+export default createStructuredSelector({
+ countryISO: selectCountryIso,
+ countryId: getCountryId,
+ countryName: getCountryName,
+});
diff --git a/src/router.ts b/src/router.ts
index deac323f4..13fa460e5 100644
--- a/src/router.ts
+++ b/src/router.ts
@@ -11,6 +11,7 @@ export const NATIONAL_REPORT_CARD_LANDING =
'location/NATIONAL_REPORT_CARD_LANDING';
export const AREA_OF_INTEREST = 'location/AREA_OF_INTEREST';
export const MAP_IFRAME = 'location/MAP_IFRAME';
+export const DASHBOARD = 'location/DASHBOARD';
export const routes: RoutesMap<{ path: string; page?: string }> = {
[LANDING]: {
@@ -37,6 +38,10 @@ export const routes: RoutesMap<{ path: string; page?: string }> = {
path: '/aoi/:id?',
page: 'aoi',
},
+ [DASHBOARD]: {
+ path: '/dashboard/:iso',
+ page: 'dashboard',
+ },
[NOT_FOUND]: {
path: '/404',
thunk: (dispatch) => dispatch(redirect({ type: LANDING })),
From 2f8c342260e15232734d4b15eeeaac41c272e60b Mon Sep 17 00:00:00 2001
From: Chris Manciero
Date: Tue, 28 May 2024 10:38:44 -0400
Subject: [PATCH 002/350] display map with click
---
src/pages/dashboard/index.js | 188 ++++++++++++++++++++++++++++++-----
1 file changed, 164 insertions(+), 24 deletions(-)
diff --git a/src/pages/dashboard/index.js b/src/pages/dashboard/index.js
index df5ca8c5a..7a7568700 100644
--- a/src/pages/dashboard/index.js
+++ b/src/pages/dashboard/index.js
@@ -1,4 +1,4 @@
-import React, { useEffect, useState } from 'react';
+import React, { useEffect } from 'react';
import { connect } from 'react-redux';
import { loadModules } from 'esri-loader';
@@ -7,7 +7,7 @@ import * as urlActions from 'actions/url-actions';
import Logo from 'components/half-earth-logo';
-import { SATELLITE_BASEMAP_LAYER } from 'constants/layers-slugs';
+// import { SATELLITE_BASEMAP_LAYER } from 'constants/layers-slugs';
import uiStyles from 'styles/ui.module.scss';
@@ -17,30 +17,170 @@ const actions = { ...urlActions };
const { REACT_APP_ARGISJS_API_VERSION: API_VERSION } = process.env;
+const mapViewConstraints = {
+ minZoom: 3,
+ rotationEnabled: false,
+ snapToZoom: false,
+ minScale: 147914381,
+};
+
function DashboardComponent(props) {
- const [map, setMap] = useState(null);
- const [view, setView] = useState(null);
+ // const [map, setMap] = useState(null);
+ // const [view, setView] = useState(null);
+
+ const highlightCountry = async (query, zoomGeometry, layers, view) => {
+ const { countries, graphicsLayer, worldImagery, groupLayer } = layers;
+ console.log(layers);
+ // country symbol - when user clicks on a country
+ // we will query the country from the countries featurelayer
+ // add the country feature to the graphics layer.
+ const symbol = {
+ type: 'simple-fill',
+ color: 'rgba(255, 255, 255, 1)',
+ outline: null,
+ };
+
+ // query the countries layer for a country that intersects the clicked point
+ const {
+ features: [feature],
+ } = await countries.queryFeatures(query);
+ // user clicked on a country and the feature is returned
+ if (feature) {
+ console.log('feature', feature);
+ graphicsLayer.graphics.removeAll();
+ feature.symbol = symbol;
+ // add the country to the graphics layer
+ graphicsLayer.graphics.add(feature);
+ // zoom to the highlighted country
+ view.goTo(
+ {
+ target: zoomGeometry,
+ extent: feature.geometry.clone(),
+ },
+ { duration: 1000 }
+ );
+ // blur the world imagery basemap so that the clicked country can be highlighted
+ worldImagery.effect = 'blur(8px) brightness(1.2) grayscale(0.8)';
+ // set the group layer opacity to 1
+ // also increase the layer brightness and add drop-shadow to make the clicked country stand out.
+ groupLayer.effect = 'brightness(1.5) drop-shadow(0, 0px, 12px)';
+ groupLayer.opacity = 1;
+ }
+ };
useEffect(() => {
- loadModules(['esri/Map', 'esri/views/MapView'], {
- url: `https://js.arcgis.com/${API_VERSION}`,
- })
- .then(([Map, MapView]) => {
- const myMap = new Map({
- basemap: SATELLITE_BASEMAP_LAYER,
- });
-
- const myView = new MapView({
- map: myMap,
- center: [-118.805, 34.027], // Longitude, latitude
- zoom: 13, // Zoom level
- container: 'map',
- });
- setView(myView);
- setMap(myMap);
- console.log(map);
- console.log(view);
- })
+ loadModules(
+ [
+ 'esri/Map',
+ 'esri/views/MapView',
+ 'esri/layers/TileLayer',
+ // 'esri/Graphic',
+ 'esri/layers/FeatureLayer',
+ 'esri/layers/GraphicsLayer',
+ 'esri/layers/GroupLayer',
+ ],
+ {
+ url: `https://js.arcgis.com/${API_VERSION}`,
+ }
+ )
+ .then(
+ ([
+ Map,
+ MapView,
+ TileLayer,
+ // Graphic,
+ FeatureLayer,
+ GraphicsLayer,
+ GroupLayer,
+ ]) => {
+ const worldImagery = new TileLayer({
+ portalItem: {
+ id: '10df2279f9684e4a9f6a7f08febac2a9', // world imagery
+ },
+ });
+
+ worldImagery.when(() => {
+ worldImagery.sublayers.forEach((layer) => {
+ if (layer.popupEnabled === true) {
+ layer.popupEnabled = false;
+ }
+ });
+ });
+
+ const countries = new FeatureLayer({
+ portalItem: {
+ id: '53a1e68de7e4499cad77c80daba46a94',
+ },
+ });
+
+ // clicked country feature will be added to this layer
+ const graphicsLayer = new GraphicsLayer({
+ blendMode: 'destination-in',
+ title: 'layer',
+ });
+
+ const tileLayer = new TileLayer({
+ portalItem: {
+ // bottom layer in the group layer
+ id: '10df2279f9684e4a9f6a7f08febac2a9', // world imagery
+ },
+ });
+ tileLayer.when(() => {
+ tileLayer.sublayers.forEach((layer) => {
+ if (layer.popupEnabled === true) {
+ layer.popupEnabled = false;
+ }
+ });
+ });
+
+ // this grouplayer has two layers
+ // destination-in blendMode set on the graphics layer
+ // country from the world imagery layer will show when user clicks on a country
+ const groupLayer = new GroupLayer({
+ layers: [
+ tileLayer,
+ // world imagery layer will show where it overlaps with the graphicslayer
+ graphicsLayer,
+ ],
+ opacity: 0, // initially this layer will be transparent
+ });
+
+ const layers = { countries, worldImagery, graphicsLayer, groupLayer };
+
+ const myMap = new Map({
+ // basemap: SATELLITE_BASEMAP_LAYER,
+ layers: [worldImagery, groupLayer],
+ });
+
+ const myView = new MapView({
+ map: myMap,
+ zoom: 6, // Zoom level
+ center: [2, 46],
+ popup: null,
+ constraints: mapViewConstraints,
+ container: 'map',
+ });
+
+ myView.when(async () => {
+ const query = {
+ geometry: myView.center,
+ returnGeometry: true,
+ outFields: ['*'],
+ };
+ await highlightCountry(query, myView.center, layers, myView);
+ });
+
+ // listen to the view's click event
+ myView.on('click', async (event) => {
+ const query = {
+ geometry: myView.toMap(event),
+ returnGeometry: true,
+ outFields: ['*'],
+ };
+ await highlightCountry(query, query.geometry, layers, myView);
+ });
+ }
+ )
.catch((err) => {
console.error(err);
});
@@ -52,7 +192,7 @@ function DashboardComponent(props) {
>
);
From 60049c213ed4a2b85ef3232c764d6fb59839aa04 Mon Sep 17 00:00:00 2001
From: Chris Manciero
Date: Thu, 30 May 2024 14:24:00 -0400
Subject: [PATCH 003/350] updated and cleaned up dashboard load
---
src/components/map-view/component.jsx | 34 +++
src/components/map-view/index.js | 245 +++++++++++++++++++
src/components/map-view/selectors.js | 0
src/containers/views/dashboard/component.jsx | 16 ++
src/containers/views/dashboard/index.js | 9 +
src/pages/dashboard/component.jsx | 20 ++
src/pages/dashboard/index.js | 198 +--------------
7 files changed, 328 insertions(+), 194 deletions(-)
create mode 100644 src/components/map-view/component.jsx
create mode 100644 src/components/map-view/index.js
create mode 100644 src/components/map-view/selectors.js
create mode 100644 src/containers/views/dashboard/component.jsx
create mode 100644 src/containers/views/dashboard/index.js
create mode 100644 src/pages/dashboard/component.jsx
diff --git a/src/components/map-view/component.jsx b/src/components/map-view/component.jsx
new file mode 100644
index 000000000..6e8079514
--- /dev/null
+++ b/src/components/map-view/component.jsx
@@ -0,0 +1,34 @@
+import React from 'react';
+
+export default function ViewComponent(props) {
+ const { map, view, mapName, mapId, children, loadState = 'loaded' } = props;
+ // if (loadState === 'loading') {
+ // return (
+ // <>
+ //
+ //
+ // >
+ // );
+ // }
+ if (loadState === 'loaded') {
+ return (
+
+ {React.Children.map(children || null, (child, i) => {
+ return (
+ child && (
+ // eslint-disable-next-line react/no-array-index-key
+
+ )
+ );
+ })}
+
+ );
+ }
+}
diff --git a/src/components/map-view/index.js b/src/components/map-view/index.js
new file mode 100644
index 000000000..926138b19
--- /dev/null
+++ b/src/components/map-view/index.js
@@ -0,0 +1,245 @@
+import React, { useEffect, useState } from 'react';
+
+import { loadModules } from 'esri-loader';
+
+import { SATELLITE_BASEMAP_LAYER } from 'constants/layers-slugs';
+
+import Component from './component';
+
+const { REACT_APP_ARGISJS_API_VERSION: API_VERSION } = process.env;
+
+const mapViewConstraints = {
+ minZoom: 3,
+ rotationEnabled: false,
+ snapToZoom: false,
+ minScale: 147914381,
+};
+
+function ViewContainer(props) {
+ const { mapId, mapName, onViewLoad } = props;
+
+ const [map, setMap] = useState(null);
+ const [view, setView] = useState(null);
+ const loaderOptions = {
+ url: `https://js.arcgis.com/${API_VERSION}`,
+ };
+
+ useEffect(() => {
+ loadModules(['esri/Map', 'esri/layers/FeatureLayer'], loaderOptions)
+ .then(([Map, FeatureLayer]) => {
+ const countries = new FeatureLayer({
+ portalItem: {
+ id: '53a1e68de7e4499cad77c80daba46a94',
+ },
+ });
+
+ const flatMap = new Map({
+ basemap: SATELLITE_BASEMAP_LAYER,
+ ground: {
+ surfaceColor: '#070710',
+ },
+ layers: [countries],
+ });
+
+ setMap(flatMap);
+ // if (onMapLoad) {
+ // onMapLoad(flatMap);
+ // }
+ })
+ .catch((err) => {
+ console.error(err);
+ });
+ }, []);
+
+ useEffect(() => {
+ if (map) {
+ loadModules(['esri/views/MapView'], loaderOptions)
+ .then(([MapView]) => {
+ const flatView = new MapView({
+ map,
+ container: `map-container-${mapName || mapId}`,
+ zoom: 6,
+ center: [-3, 42],
+ popup: null,
+ constraints: mapViewConstraints,
+ });
+
+ setView(flatView);
+ })
+ .catch((err) => {
+ console.error(err);
+ });
+ }
+ }, [map]);
+
+ useEffect(() => {
+ if (map && view) {
+ if (onViewLoad) {
+ onViewLoad(map, view);
+ }
+ }
+ }, [map, view]);
+
+ return ;
+}
+
+export default ViewContainer;
+
+// const [, setMap] = useState(null);
+// // const [view, setView] = useState(null);
+
+// const highlightCountry = async (query, zoomGeometry, layers, view) => {
+// const { countries, graphicsLayer, groupLayer } = layers;
+// // country symbol - when user clicks on a country
+// // we will query the country from the countries featurelayer
+// // add the country feature to the graphics layer.
+// const symbol = {
+// type: 'simple-fill',
+// color: 'rgba(255, 255, 255, 1)',
+// outline: null,
+// };
+
+// // query the countries layer for a country that intersects the clicked point
+// const {
+// features: [feature],
+// } = await countries.queryFeatures(query);
+// // user clicked on a country and the feature is returned
+// if (feature) {
+// graphicsLayer.graphics.removeAll();
+// feature.symbol = symbol;
+// // add the country to the graphics layer
+// graphicsLayer.graphics.add(feature);
+// // zoom to the highlighted country
+// view.goTo(
+// {
+// target: zoomGeometry,
+// extent: feature.geometry.clone(),
+// },
+// { duration: 1000 }
+// );
+// // set the group layer opacity to 1
+// // also increase the layer brightness and add drop-shadow to make the clicked country stand out.
+// groupLayer.effect = 'brightness(1.5) drop-shadow(0, 0px, 12px)';
+// groupLayer.opacity = 1;
+// }
+// };
+
+// useEffect(() => {
+// loadModules(
+// [
+// 'esri/Map',
+// 'esri/views/MapView',
+// 'esri/layers/TileLayer',
+// // 'esri/Graphic',
+// 'esri/layers/FeatureLayer',
+// 'esri/layers/GraphicsLayer',
+// 'esri/layers/GroupLayer',
+// ],
+// {
+// url: `https://js.arcgis.com/${API_VERSION}`,
+// }
+// )
+// .then(
+// ([
+// Map,
+// MapView,
+// TileLayer,
+// // Graphic,
+// FeatureLayer,
+// GraphicsLayer,
+// GroupLayer,
+// ]) => {
+// const worldImagery = new TileLayer({
+// portalItem: {
+// id: '10df2279f9684e4a9f6a7f08febac2a9', // world imagery
+// },
+// });
+
+// worldImagery.when(() => {
+// worldImagery.sublayers.forEach((layer) => {
+// if (layer.popupEnabled === true) {
+// layer.popupEnabled = false;
+// }
+// });
+// });
+
+// const countries = new FeatureLayer({
+// portalItem: {
+// id: '53a1e68de7e4499cad77c80daba46a94',
+// },
+// });
+
+// // clicked country feature will be added to this layer
+// const graphicsLayer = new GraphicsLayer({
+// blendMode: 'destination-in',
+// title: 'layer',
+// });
+
+// const tileLayer = new TileLayer({
+// portalItem: {
+// // bottom layer in the group layer
+// id: '10df2279f9684e4a9f6a7f08febac2a9', // world imagery
+// },
+// });
+// tileLayer.when(() => {
+// tileLayer.sublayers.forEach((layer) => {
+// if (layer.popupEnabled === true) {
+// layer.popupEnabled = false;
+// }
+// });
+// });
+
+// // this grouplayer has two layers
+// // destination-in blendMode set on the graphics layer
+// // country from the world imagery layer will show when user clicks on a country
+// const groupLayer = new GroupLayer({
+// layers: [
+// tileLayer,
+// // world imagery layer will show where it overlaps with the graphicslayer
+// graphicsLayer,
+// ],
+// opacity: 0, // initially this layer will be transparent
+// });
+
+// const layers = { countries, graphicsLayer, groupLayer };
+
+// const myMap = new Map({
+// // basemap: SATELLITE_BASEMAP_LAYER,
+// layers: [worldImagery, countries, groupLayer],
+// });
+
+// setMap(myMap);
+
+// const myView = new MapView({
+// map: myMap,
+// zoom: 6, // Zoom level
+// center: [-3, 42],
+// popup: null,
+// constraints: mapViewConstraints,
+// container: 'map',
+// });
+
+// myView.when(async () => {
+// const query = {
+// geometry: myView.center,
+// returnGeometry: true,
+// outFields: ['*'],
+// };
+// await highlightCountry(query, myView.center, layers, myView);
+// });
+
+// // listen to the view's click event
+// myView.on('click', async (event) => {
+// const query = {
+// geometry: myView.toMap(event),
+// returnGeometry: true,
+// outFields: ['*'],
+// };
+// await highlightCountry(query, query.geometry, layers, myView);
+// });
+// }
+// )
+// .catch((err) => {
+// console.error(err);
+// });
+// }, []);
diff --git a/src/components/map-view/selectors.js b/src/components/map-view/selectors.js
new file mode 100644
index 000000000..e69de29bb
diff --git a/src/containers/views/dashboard/component.jsx b/src/containers/views/dashboard/component.jsx
new file mode 100644
index 000000000..7ca796da2
--- /dev/null
+++ b/src/containers/views/dashboard/component.jsx
@@ -0,0 +1,16 @@
+import React from 'react';
+
+import MapView from '../../../components/map-view';
+
+const { REACT_APP_ARGISJS_API_VERSION: API_VERSION } = process.env;
+
+function DashboardViewComponent() {
+ return (
+
+ );
+}
+
+export default DashboardViewComponent;
diff --git a/src/containers/views/dashboard/index.js b/src/containers/views/dashboard/index.js
new file mode 100644
index 000000000..ef0731491
--- /dev/null
+++ b/src/containers/views/dashboard/index.js
@@ -0,0 +1,9 @@
+import React from 'react';
+
+import Component from './component';
+
+function DashboardView(props) {
+ return ;
+}
+
+export default DashboardView;
diff --git a/src/pages/dashboard/component.jsx b/src/pages/dashboard/component.jsx
new file mode 100644
index 000000000..9e002d34f
--- /dev/null
+++ b/src/pages/dashboard/component.jsx
@@ -0,0 +1,20 @@
+import React from 'react';
+
+import cx from 'classnames';
+
+import Logo from 'components/half-earth-logo';
+
+import uiStyles from 'styles/ui.module.scss';
+
+import DashboardView from '../../containers/views/dashboard';
+
+function DashboardPageComponent(props) {
+ return (
+ <>
+
+
+ >
+ );
+}
+
+export default DashboardPageComponent;
diff --git a/src/pages/dashboard/index.js b/src/pages/dashboard/index.js
index 7a7568700..152bae747 100644
--- a/src/pages/dashboard/index.js
+++ b/src/pages/dashboard/index.js
@@ -1,201 +1,11 @@
-import React, { useEffect } from 'react';
+import React from 'react';
import { connect } from 'react-redux';
-import { loadModules } from 'esri-loader';
-
-import * as urlActions from 'actions/url-actions';
-
-import Logo from 'components/half-earth-logo';
-
-// import { SATELLITE_BASEMAP_LAYER } from 'constants/layers-slugs';
-
-import uiStyles from 'styles/ui.module.scss';
-
+import Component from './component';
import mapStateToProps from './selectors';
-const actions = { ...urlActions };
-
-const { REACT_APP_ARGISJS_API_VERSION: API_VERSION } = process.env;
-
-const mapViewConstraints = {
- minZoom: 3,
- rotationEnabled: false,
- snapToZoom: false,
- minScale: 147914381,
-};
-
function DashboardComponent(props) {
- // const [map, setMap] = useState(null);
- // const [view, setView] = useState(null);
-
- const highlightCountry = async (query, zoomGeometry, layers, view) => {
- const { countries, graphicsLayer, worldImagery, groupLayer } = layers;
- console.log(layers);
- // country symbol - when user clicks on a country
- // we will query the country from the countries featurelayer
- // add the country feature to the graphics layer.
- const symbol = {
- type: 'simple-fill',
- color: 'rgba(255, 255, 255, 1)',
- outline: null,
- };
-
- // query the countries layer for a country that intersects the clicked point
- const {
- features: [feature],
- } = await countries.queryFeatures(query);
- // user clicked on a country and the feature is returned
- if (feature) {
- console.log('feature', feature);
- graphicsLayer.graphics.removeAll();
- feature.symbol = symbol;
- // add the country to the graphics layer
- graphicsLayer.graphics.add(feature);
- // zoom to the highlighted country
- view.goTo(
- {
- target: zoomGeometry,
- extent: feature.geometry.clone(),
- },
- { duration: 1000 }
- );
- // blur the world imagery basemap so that the clicked country can be highlighted
- worldImagery.effect = 'blur(8px) brightness(1.2) grayscale(0.8)';
- // set the group layer opacity to 1
- // also increase the layer brightness and add drop-shadow to make the clicked country stand out.
- groupLayer.effect = 'brightness(1.5) drop-shadow(0, 0px, 12px)';
- groupLayer.opacity = 1;
- }
- };
-
- useEffect(() => {
- loadModules(
- [
- 'esri/Map',
- 'esri/views/MapView',
- 'esri/layers/TileLayer',
- // 'esri/Graphic',
- 'esri/layers/FeatureLayer',
- 'esri/layers/GraphicsLayer',
- 'esri/layers/GroupLayer',
- ],
- {
- url: `https://js.arcgis.com/${API_VERSION}`,
- }
- )
- .then(
- ([
- Map,
- MapView,
- TileLayer,
- // Graphic,
- FeatureLayer,
- GraphicsLayer,
- GroupLayer,
- ]) => {
- const worldImagery = new TileLayer({
- portalItem: {
- id: '10df2279f9684e4a9f6a7f08febac2a9', // world imagery
- },
- });
-
- worldImagery.when(() => {
- worldImagery.sublayers.forEach((layer) => {
- if (layer.popupEnabled === true) {
- layer.popupEnabled = false;
- }
- });
- });
-
- const countries = new FeatureLayer({
- portalItem: {
- id: '53a1e68de7e4499cad77c80daba46a94',
- },
- });
-
- // clicked country feature will be added to this layer
- const graphicsLayer = new GraphicsLayer({
- blendMode: 'destination-in',
- title: 'layer',
- });
-
- const tileLayer = new TileLayer({
- portalItem: {
- // bottom layer in the group layer
- id: '10df2279f9684e4a9f6a7f08febac2a9', // world imagery
- },
- });
- tileLayer.when(() => {
- tileLayer.sublayers.forEach((layer) => {
- if (layer.popupEnabled === true) {
- layer.popupEnabled = false;
- }
- });
- });
-
- // this grouplayer has two layers
- // destination-in blendMode set on the graphics layer
- // country from the world imagery layer will show when user clicks on a country
- const groupLayer = new GroupLayer({
- layers: [
- tileLayer,
- // world imagery layer will show where it overlaps with the graphicslayer
- graphicsLayer,
- ],
- opacity: 0, // initially this layer will be transparent
- });
-
- const layers = { countries, worldImagery, graphicsLayer, groupLayer };
-
- const myMap = new Map({
- // basemap: SATELLITE_BASEMAP_LAYER,
- layers: [worldImagery, groupLayer],
- });
-
- const myView = new MapView({
- map: myMap,
- zoom: 6, // Zoom level
- center: [2, 46],
- popup: null,
- constraints: mapViewConstraints,
- container: 'map',
- });
-
- myView.when(async () => {
- const query = {
- geometry: myView.center,
- returnGeometry: true,
- outFields: ['*'],
- };
- await highlightCountry(query, myView.center, layers, myView);
- });
-
- // listen to the view's click event
- myView.on('click', async (event) => {
- const query = {
- geometry: myView.toMap(event),
- returnGeometry: true,
- outFields: ['*'],
- };
- await highlightCountry(query, query.geometry, layers, myView);
- });
- }
- )
- .catch((err) => {
- console.error(err);
- });
- }, []);
-
- console.log(props);
- return (
- <>
-
-
- >
- );
+ return ;
}
-export default connect(mapStateToProps, actions)(DashboardComponent);
+export default connect(mapStateToProps, null)(DashboardComponent);
From a5d8d3e68fdf88326216e4851832c6146e1ab904 Mon Sep 17 00:00:00 2001
From: Chris Manciero
Date: Tue, 4 Jun 2024 10:46:58 -0400
Subject: [PATCH 004/350] dashboard child components
---
src/components/map-view/index.js | 255 +++++++-----------
.../sidebars/dashboard-sidebar/component.jsx | 25 ++
.../data-layers/component.jsx | 7 +
.../dashboard-sidebar/data-layers/index.js | 9 +
.../sidebars/dashboard-sidebar/index.js | 11 +
.../sidebars/dashboard-sidebar/selectors.js | 0
.../species-info/component.jsx | 26 ++
.../dashboard-sidebar/species-info/index.js | 9 +
.../species-info/styles.module.scss | 47 ++++
.../dashboard-sidebar/styles.module.scss | 56 ++++
src/containers/views/dashboard/component.jsx | 5 +-
11 files changed, 287 insertions(+), 163 deletions(-)
create mode 100644 src/containers/sidebars/dashboard-sidebar/component.jsx
create mode 100644 src/containers/sidebars/dashboard-sidebar/data-layers/component.jsx
create mode 100644 src/containers/sidebars/dashboard-sidebar/data-layers/index.js
create mode 100644 src/containers/sidebars/dashboard-sidebar/index.js
create mode 100644 src/containers/sidebars/dashboard-sidebar/selectors.js
create mode 100644 src/containers/sidebars/dashboard-sidebar/species-info/component.jsx
create mode 100644 src/containers/sidebars/dashboard-sidebar/species-info/index.js
create mode 100644 src/containers/sidebars/dashboard-sidebar/species-info/styles.module.scss
create mode 100644 src/containers/sidebars/dashboard-sidebar/styles.module.scss
diff --git a/src/components/map-view/index.js b/src/components/map-view/index.js
index 926138b19..49a8a8f06 100644
--- a/src/components/map-view/index.js
+++ b/src/components/map-view/index.js
@@ -20,25 +20,97 @@ function ViewContainer(props) {
const [map, setMap] = useState(null);
const [view, setView] = useState(null);
+ const [countryLayer, setCountryLayer] = useState(null);
+ const [graphicsLayer, setGraphicsLayer] = useState(null);
+ const [groupLayer, setGroupLayer] = useState(null);
+
const loaderOptions = {
url: `https://js.arcgis.com/${API_VERSION}`,
};
+ const highlightCountry = async (query, zoomGeometry, flatView) => {
+ // country symbol - when user clicks on a country
+ // we will query the country from the countries featurelayer
+ // add the country feature to the graphics layer.
+ const symbol = {
+ type: 'simple-fill',
+ color: 'rgba(255, 255, 255, 1)',
+ outline: null,
+ };
+
+ // query the countries layer for a country that intersects the clicked point
+ const {
+ features: [feature],
+ } = await countryLayer.queryFeatures(query);
+ // user clicked on a country and the feature is returned
+ if (feature) {
+ graphicsLayer.graphics.removeAll();
+ feature.symbol = symbol;
+ // add the country to the graphics layer
+ graphicsLayer.graphics.add(feature);
+ // zoom to the highlighted country
+ flatView.goTo(
+ {
+ target: zoomGeometry,
+ extent: feature.geometry.clone(),
+ },
+ { duration: 1000 }
+ );
+ // set the group layer opacity to 1
+ // also increase the layer brightness and add drop-shadow to make the clicked country stand out.
+ groupLayer.effect = 'brightness(1.5) drop-shadow(0, 0px, 12px)';
+ groupLayer.opacity = 1;
+ }
+ };
+
useEffect(() => {
- loadModules(['esri/Map', 'esri/layers/FeatureLayer'], loaderOptions)
- .then(([Map, FeatureLayer]) => {
+ loadModules(
+ [
+ 'esri/Map',
+ 'esri/layers/FeatureLayer',
+ 'esri/layers/GraphicsLayer',
+ 'esri/layers/GroupLayer',
+ 'esri/layers/TileLayer',
+ ],
+ loaderOptions
+ )
+ .then(([Map, FeatureLayer, GraphicsLayer, GroupLayer, TileLayer]) => {
const countries = new FeatureLayer({
portalItem: {
id: '53a1e68de7e4499cad77c80daba46a94',
},
});
+ setCountryLayer(countries);
+
+ const graphics = new GraphicsLayer({
+ blendMode: 'destination-in',
+ title: 'layer',
+ });
+ setGraphicsLayer(graphics);
+
+ const tileLayer = new TileLayer({
+ portalItem: {
+ // bottom layer in the group layer
+ id: '10df2279f9684e4a9f6a7f08febac2a9', // world imagery
+ },
+ });
+
+ const group = new GroupLayer({
+ layers: [
+ tileLayer,
+ // world imagery layer will show where it overlaps with the graphicslayer
+ graphics,
+ ],
+ opacity: 0, // initially this layer will be transparent
+ });
+ setGroupLayer(group);
const flatMap = new Map({
basemap: SATELLITE_BASEMAP_LAYER,
ground: {
surfaceColor: '#070710',
},
- layers: [countries],
+ layers: [countries, group],
});
setMap(flatMap);
@@ -64,6 +136,24 @@ function ViewContainer(props) {
constraints: mapViewConstraints,
});
+ flatView.when(async () => {
+ const query = {
+ geometry: flatView.center,
+ returnGeometry: true,
+ outFields: ['*'],
+ };
+ await highlightCountry(query, flatView.center, flatView);
+ });
+
+ flatView.on('click', async (event) => {
+ const query = {
+ geometry: flatView.toMap(event),
+ returnGeometry: true,
+ outFields: ['*'],
+ };
+ await highlightCountry(query, query.geometry, flatView);
+ });
+
setView(flatView);
})
.catch((err) => {
@@ -84,162 +174,3 @@ function ViewContainer(props) {
}
export default ViewContainer;
-
-// const [, setMap] = useState(null);
-// // const [view, setView] = useState(null);
-
-// const highlightCountry = async (query, zoomGeometry, layers, view) => {
-// const { countries, graphicsLayer, groupLayer } = layers;
-// // country symbol - when user clicks on a country
-// // we will query the country from the countries featurelayer
-// // add the country feature to the graphics layer.
-// const symbol = {
-// type: 'simple-fill',
-// color: 'rgba(255, 255, 255, 1)',
-// outline: null,
-// };
-
-// // query the countries layer for a country that intersects the clicked point
-// const {
-// features: [feature],
-// } = await countries.queryFeatures(query);
-// // user clicked on a country and the feature is returned
-// if (feature) {
-// graphicsLayer.graphics.removeAll();
-// feature.symbol = symbol;
-// // add the country to the graphics layer
-// graphicsLayer.graphics.add(feature);
-// // zoom to the highlighted country
-// view.goTo(
-// {
-// target: zoomGeometry,
-// extent: feature.geometry.clone(),
-// },
-// { duration: 1000 }
-// );
-// // set the group layer opacity to 1
-// // also increase the layer brightness and add drop-shadow to make the clicked country stand out.
-// groupLayer.effect = 'brightness(1.5) drop-shadow(0, 0px, 12px)';
-// groupLayer.opacity = 1;
-// }
-// };
-
-// useEffect(() => {
-// loadModules(
-// [
-// 'esri/Map',
-// 'esri/views/MapView',
-// 'esri/layers/TileLayer',
-// // 'esri/Graphic',
-// 'esri/layers/FeatureLayer',
-// 'esri/layers/GraphicsLayer',
-// 'esri/layers/GroupLayer',
-// ],
-// {
-// url: `https://js.arcgis.com/${API_VERSION}`,
-// }
-// )
-// .then(
-// ([
-// Map,
-// MapView,
-// TileLayer,
-// // Graphic,
-// FeatureLayer,
-// GraphicsLayer,
-// GroupLayer,
-// ]) => {
-// const worldImagery = new TileLayer({
-// portalItem: {
-// id: '10df2279f9684e4a9f6a7f08febac2a9', // world imagery
-// },
-// });
-
-// worldImagery.when(() => {
-// worldImagery.sublayers.forEach((layer) => {
-// if (layer.popupEnabled === true) {
-// layer.popupEnabled = false;
-// }
-// });
-// });
-
-// const countries = new FeatureLayer({
-// portalItem: {
-// id: '53a1e68de7e4499cad77c80daba46a94',
-// },
-// });
-
-// // clicked country feature will be added to this layer
-// const graphicsLayer = new GraphicsLayer({
-// blendMode: 'destination-in',
-// title: 'layer',
-// });
-
-// const tileLayer = new TileLayer({
-// portalItem: {
-// // bottom layer in the group layer
-// id: '10df2279f9684e4a9f6a7f08febac2a9', // world imagery
-// },
-// });
-// tileLayer.when(() => {
-// tileLayer.sublayers.forEach((layer) => {
-// if (layer.popupEnabled === true) {
-// layer.popupEnabled = false;
-// }
-// });
-// });
-
-// // this grouplayer has two layers
-// // destination-in blendMode set on the graphics layer
-// // country from the world imagery layer will show when user clicks on a country
-// const groupLayer = new GroupLayer({
-// layers: [
-// tileLayer,
-// // world imagery layer will show where it overlaps with the graphicslayer
-// graphicsLayer,
-// ],
-// opacity: 0, // initially this layer will be transparent
-// });
-
-// const layers = { countries, graphicsLayer, groupLayer };
-
-// const myMap = new Map({
-// // basemap: SATELLITE_BASEMAP_LAYER,
-// layers: [worldImagery, countries, groupLayer],
-// });
-
-// setMap(myMap);
-
-// const myView = new MapView({
-// map: myMap,
-// zoom: 6, // Zoom level
-// center: [-3, 42],
-// popup: null,
-// constraints: mapViewConstraints,
-// container: 'map',
-// });
-
-// myView.when(async () => {
-// const query = {
-// geometry: myView.center,
-// returnGeometry: true,
-// outFields: ['*'],
-// };
-// await highlightCountry(query, myView.center, layers, myView);
-// });
-
-// // listen to the view's click event
-// myView.on('click', async (event) => {
-// const query = {
-// geometry: myView.toMap(event),
-// returnGeometry: true,
-// outFields: ['*'],
-// };
-// await highlightCountry(query, query.geometry, layers, myView);
-// });
-// }
-// )
-// .catch((err) => {
-// console.error(err);
-// });
-// }, []);
diff --git a/src/containers/sidebars/dashboard-sidebar/component.jsx b/src/containers/sidebars/dashboard-sidebar/component.jsx
new file mode 100644
index 000000000..42dd2cf26
--- /dev/null
+++ b/src/containers/sidebars/dashboard-sidebar/component.jsx
@@ -0,0 +1,25 @@
+import React from 'react';
+
+import styles from './styles.module.scss';
+
+import DataLayerContainer from './data-layers';
+import SpeciesInfoContainer from './species-info';
+
+function DashboardSidebar() {
+ return (
+
+ );
+}
+
+export default DashboardSidebar;
diff --git a/src/containers/sidebars/dashboard-sidebar/data-layers/component.jsx b/src/containers/sidebars/dashboard-sidebar/data-layers/component.jsx
new file mode 100644
index 000000000..2ce39b4f3
--- /dev/null
+++ b/src/containers/sidebars/dashboard-sidebar/data-layers/component.jsx
@@ -0,0 +1,7 @@
+import React from 'react';
+
+function DataLayerComponent() {
+ return DataLayerComponent
;
+}
+
+export default DataLayerComponent;
diff --git a/src/containers/sidebars/dashboard-sidebar/data-layers/index.js b/src/containers/sidebars/dashboard-sidebar/data-layers/index.js
new file mode 100644
index 000000000..a714d68ac
--- /dev/null
+++ b/src/containers/sidebars/dashboard-sidebar/data-layers/index.js
@@ -0,0 +1,9 @@
+import React from 'react';
+
+import DataLayerComponent from './component';
+
+function DataLayerContainer(props) {
+ return ;
+}
+
+export default DataLayerContainer;
diff --git a/src/containers/sidebars/dashboard-sidebar/index.js b/src/containers/sidebars/dashboard-sidebar/index.js
new file mode 100644
index 000000000..221f7cea5
--- /dev/null
+++ b/src/containers/sidebars/dashboard-sidebar/index.js
@@ -0,0 +1,11 @@
+import React from 'react';
+import { connect } from 'react-redux';
+
+import Component from './component.jsx';
+import mapStateToProps from './selectors';
+
+function DashboardSidebarContainer() {
+ return ;
+}
+
+export default connect(mapStateToProps, null)(DashboardSidebarContainer);
diff --git a/src/containers/sidebars/dashboard-sidebar/selectors.js b/src/containers/sidebars/dashboard-sidebar/selectors.js
new file mode 100644
index 000000000..e69de29bb
diff --git a/src/containers/sidebars/dashboard-sidebar/species-info/component.jsx b/src/containers/sidebars/dashboard-sidebar/species-info/component.jsx
new file mode 100644
index 000000000..2e06d8427
--- /dev/null
+++ b/src/containers/sidebars/dashboard-sidebar/species-info/component.jsx
@@ -0,0 +1,26 @@
+import React from 'react';
+
+import styles from './styles.module.scss';
+
+function SpeciesInfoComponent() {
+ return (
+
+
+
+
+
Hamlyns Monkey
+
Cercopithecus hamlyni
+
+
+
+
+ The Hamlyns monkey (Cercopithecus hamlyni), also known as the owl-faced
+ monkey, is a species of Old World monkey that inhabits the bamboo and
+ primary rainforests of the Congo. This species is exceedingly rare and
+ known only from a few specimens; little is known about it.
+
+
+ );
+}
+
+export default SpeciesInfoComponent;
diff --git a/src/containers/sidebars/dashboard-sidebar/species-info/index.js b/src/containers/sidebars/dashboard-sidebar/species-info/index.js
new file mode 100644
index 000000000..2fbe9eeb4
--- /dev/null
+++ b/src/containers/sidebars/dashboard-sidebar/species-info/index.js
@@ -0,0 +1,9 @@
+import React from 'react';
+
+import SpeciesInfoComponent from './component';
+
+function SpeciesInfoContainer(props) {
+ return ;
+}
+
+export default SpeciesInfoContainer;
diff --git a/src/containers/sidebars/dashboard-sidebar/species-info/styles.module.scss b/src/containers/sidebars/dashboard-sidebar/species-info/styles.module.scss
new file mode 100644
index 000000000..ce425595a
--- /dev/null
+++ b/src/containers/sidebars/dashboard-sidebar/species-info/styles.module.scss
@@ -0,0 +1,47 @@
+@import 'styles/ui.module';
+@import 'styles/settings';
+@import 'styles/typography-extends';
+@import 'styles/common-animations.module';
+
+.species{
+ display: flex;
+ flex-direction: column;
+ gap: 15px;
+ background-color: #efefef;
+
+ .title{
+ display: flex;
+ gap: 10px;
+
+ img{
+ width: 130px;
+ height: 130px;
+ margin-top: 8px;
+ }
+
+ .info{
+ display: flex;
+ flex-direction: column;
+ gap: 5px;
+
+ .commonName{
+ font-weight: 700;
+ font-size: 24px;
+ }
+
+ .taxa{
+ font-style: italic;
+ font-size: 18px;
+ }
+
+ img{
+ width: 60px;
+ height: 60px;
+ }
+ }
+
+ .description {
+ font-size: 14px;
+ }
+ }
+}
diff --git a/src/containers/sidebars/dashboard-sidebar/styles.module.scss b/src/containers/sidebars/dashboard-sidebar/styles.module.scss
new file mode 100644
index 000000000..76ae53ffe
--- /dev/null
+++ b/src/containers/sidebars/dashboard-sidebar/styles.module.scss
@@ -0,0 +1,56 @@
+@import 'styles/ui.module';
+@import 'styles/settings';
+@import 'styles/typography-extends';
+@import 'styles/common-animations.module';
+
+$sidebar-content-top: 180px;
+
+.sidebarContainer {
+ @include animationFunction($propertyToAnimate: all);
+ position: absolute;
+ height: calc(100vh - #{$nav-bar-height});
+ width: calc(#{$sidebar-width} + 30px);
+ top: $nav-bar-height;
+ left: $site-gutter;
+ padding-bottom: $site-gutter;
+ padding-left: 5px;
+
+ display: flex;
+ flex-direction: column;
+ gap: 10px;
+}
+
+.container {
+ @extend %verticalScrollbar;
+ @include backdropBlur();
+ position: absolute;
+ top: $sidebar-content-top;
+ left: $site-gutter;
+ display: flex;
+ flex-direction: column;
+ border: $sidebar-border;
+ border-radius: $sidebar-border-radius;
+ height: calc(100vh - #{$sidebar-content-top});
+ width: $sidebar-width;
+ padding: $site-gutter;
+ z-index: $bring-to-front;
+}
+
+.sidenav{
+ display: flex;
+ height: 100%;
+ background: rgba(255, 255, 255, 0.4);
+
+ .icons{
+ display: flex;
+ flex-direction: column;
+ height: 100%;
+ border-right: 1px solid;
+
+ span{
+ display: inline-block;
+ width: 50px;
+ height: 50px;
+ }
+ }
+}
diff --git a/src/containers/views/dashboard/component.jsx b/src/containers/views/dashboard/component.jsx
index 7ca796da2..5e5af8a19 100644
--- a/src/containers/views/dashboard/component.jsx
+++ b/src/containers/views/dashboard/component.jsx
@@ -1,6 +1,7 @@
import React from 'react';
import MapView from '../../../components/map-view';
+import DashboardSidebar from '../../sidebars/dashboard-sidebar/component';
const { REACT_APP_ARGISJS_API_VERSION: API_VERSION } = process.env;
@@ -9,7 +10,9 @@ function DashboardViewComponent() {
+ >
+
+
);
}
From 3dcde8b7ee51c5a814261230636e6c54c90694f2 Mon Sep 17 00:00:00 2001
From: Chris Manciero
Date: Wed, 5 Jun 2024 12:01:41 -0400
Subject: [PATCH 005/350] update dashboard view
---
src/components/map-view/component.jsx | 38 +++--
src/components/map-view/index.js | 25 ++--
src/components/map-view/selectors.js | 11 ++
...nt.jsx => dashboard-sidebar-component.jsx} | 3 +-
...s => dashboard-sidebar-styles.module.scss} | 0
...omponent.jsx => data-layers-component.jsx} | 0
.../dashboard-sidebar/data-layers/index.js | 2 +-
.../sidebars/dashboard-sidebar/index.js | 2 +-
.../dashboard-sidebar/species-info/index.js | 2 +-
...mponent.jsx => species-info-component.jsx} | 2 +-
...e.scss => species-info-styles.module.scss} | 0
.../dashboard-view-component.jsx | 62 ++++++++
.../dashboard-view/dashboard-view-config.js | 67 +++++++++
.../dashboard-view-selectors.js | 40 +++++
.../views/dashboard-view/dashboard-view.js | 43 ++++++
src/containers/views/dashboard/component.jsx | 19 ---
src/containers/views/dashboard/index.js | 9 --
src/pages/dashboard/component.jsx | 20 ---
src/pages/dashboard/dashboard-component.jsx | 62 ++++++++
src/pages/dashboard/dashboard-selectors.js | 138 ++++++++++++++++++
src/pages/dashboard/index.js | 26 +++-
src/pages/dashboard/selectors.js | 35 -----
22 files changed, 485 insertions(+), 121 deletions(-)
rename src/containers/sidebars/dashboard-sidebar/{component.jsx => dashboard-sidebar-component.jsx} (89%)
rename src/containers/sidebars/dashboard-sidebar/{styles.module.scss => dashboard-sidebar-styles.module.scss} (100%)
rename src/containers/sidebars/dashboard-sidebar/data-layers/{component.jsx => data-layers-component.jsx} (100%)
rename src/containers/sidebars/dashboard-sidebar/species-info/{component.jsx => species-info-component.jsx} (94%)
rename src/containers/sidebars/dashboard-sidebar/species-info/{styles.module.scss => species-info-styles.module.scss} (100%)
create mode 100644 src/containers/views/dashboard-view/dashboard-view-component.jsx
create mode 100644 src/containers/views/dashboard-view/dashboard-view-config.js
create mode 100644 src/containers/views/dashboard-view/dashboard-view-selectors.js
create mode 100644 src/containers/views/dashboard-view/dashboard-view.js
delete mode 100644 src/containers/views/dashboard/component.jsx
delete mode 100644 src/containers/views/dashboard/index.js
delete mode 100644 src/pages/dashboard/component.jsx
create mode 100644 src/pages/dashboard/dashboard-component.jsx
create mode 100644 src/pages/dashboard/dashboard-selectors.js
delete mode 100644 src/pages/dashboard/selectors.js
diff --git a/src/components/map-view/component.jsx b/src/components/map-view/component.jsx
index 6e8079514..b820c631b 100644
--- a/src/components/map-view/component.jsx
+++ b/src/components/map-view/component.jsx
@@ -1,19 +1,31 @@
import React from 'react';
+import Spinner from 'components/spinner';
+
+import styles from 'styles/themes/scene-theme.module.scss';
+
export default function ViewComponent(props) {
- const { map, view, mapName, mapId, children, loadState = 'loaded' } = props;
- // if (loadState === 'loading') {
- // return (
- // <>
- //
- //
- // >
- // );
- // }
+ const {
+ map,
+ view,
+ mapName,
+ mapId,
+ children,
+ loadState,
+ spinner = true,
+ } = props;
+ if (loadState === 'loading') {
+ return (
+ <>
+
+
+ >
+ );
+ }
if (loadState === 'loaded') {
return (
{
console.error(err);
@@ -133,7 +129,7 @@ function ViewContainer(props) {
zoom: 6,
center: [-3, 42],
popup: null,
- constraints: mapViewConstraints,
+ ...viewSettings,
});
flatView.when(async () => {
@@ -164,13 +160,14 @@ function ViewContainer(props) {
useEffect(() => {
if (map && view) {
+ setLoadState('loaded');
if (onViewLoad) {
onViewLoad(map, view);
}
}
}, [map, view]);
- return
;
+ return
;
}
-export default ViewContainer;
+export default connect(mapStateToProps, null)(ViewContainer);
diff --git a/src/components/map-view/selectors.js b/src/components/map-view/selectors.js
index e69de29bb..d6f72cff1 100644
--- a/src/components/map-view/selectors.js
+++ b/src/components/map-view/selectors.js
@@ -0,0 +1,11 @@
+import { createStructuredSelector } from 'reselect';
+
+import { getIsGlobesMenuPages } from 'selectors/location-selectors';
+
+const selectCenterOn = ({ location }) =>
+ (location.query && location.query.centerOn) || null;
+
+export default createStructuredSelector({
+ isGlobesMenuPages: getIsGlobesMenuPages,
+ centerOn: selectCenterOn,
+});
diff --git a/src/containers/sidebars/dashboard-sidebar/component.jsx b/src/containers/sidebars/dashboard-sidebar/dashboard-sidebar-component.jsx
similarity index 89%
rename from src/containers/sidebars/dashboard-sidebar/component.jsx
rename to src/containers/sidebars/dashboard-sidebar/dashboard-sidebar-component.jsx
index 42dd2cf26..6f0b73de5 100644
--- a/src/containers/sidebars/dashboard-sidebar/component.jsx
+++ b/src/containers/sidebars/dashboard-sidebar/dashboard-sidebar-component.jsx
@@ -1,7 +1,6 @@
import React from 'react';
-import styles from './styles.module.scss';
-
+import styles from './dashboard-sidebar-styles.module.scss';
import DataLayerContainer from './data-layers';
import SpeciesInfoContainer from './species-info';
diff --git a/src/containers/sidebars/dashboard-sidebar/styles.module.scss b/src/containers/sidebars/dashboard-sidebar/dashboard-sidebar-styles.module.scss
similarity index 100%
rename from src/containers/sidebars/dashboard-sidebar/styles.module.scss
rename to src/containers/sidebars/dashboard-sidebar/dashboard-sidebar-styles.module.scss
diff --git a/src/containers/sidebars/dashboard-sidebar/data-layers/component.jsx b/src/containers/sidebars/dashboard-sidebar/data-layers/data-layers-component.jsx
similarity index 100%
rename from src/containers/sidebars/dashboard-sidebar/data-layers/component.jsx
rename to src/containers/sidebars/dashboard-sidebar/data-layers/data-layers-component.jsx
diff --git a/src/containers/sidebars/dashboard-sidebar/data-layers/index.js b/src/containers/sidebars/dashboard-sidebar/data-layers/index.js
index a714d68ac..e71e73498 100644
--- a/src/containers/sidebars/dashboard-sidebar/data-layers/index.js
+++ b/src/containers/sidebars/dashboard-sidebar/data-layers/index.js
@@ -1,6 +1,6 @@
import React from 'react';
-import DataLayerComponent from './component';
+import DataLayerComponent from './data-layers-component';
function DataLayerContainer(props) {
return
;
diff --git a/src/containers/sidebars/dashboard-sidebar/index.js b/src/containers/sidebars/dashboard-sidebar/index.js
index 221f7cea5..96ea309bb 100644
--- a/src/containers/sidebars/dashboard-sidebar/index.js
+++ b/src/containers/sidebars/dashboard-sidebar/index.js
@@ -1,7 +1,7 @@
import React from 'react';
import { connect } from 'react-redux';
-import Component from './component.jsx';
+import Component from './dashboard-sidebar-component.jsx';
import mapStateToProps from './selectors';
function DashboardSidebarContainer() {
diff --git a/src/containers/sidebars/dashboard-sidebar/species-info/index.js b/src/containers/sidebars/dashboard-sidebar/species-info/index.js
index 2fbe9eeb4..827bf970d 100644
--- a/src/containers/sidebars/dashboard-sidebar/species-info/index.js
+++ b/src/containers/sidebars/dashboard-sidebar/species-info/index.js
@@ -1,6 +1,6 @@
import React from 'react';
-import SpeciesInfoComponent from './component';
+import SpeciesInfoComponent from './species-info-component';
function SpeciesInfoContainer(props) {
return
;
diff --git a/src/containers/sidebars/dashboard-sidebar/species-info/component.jsx b/src/containers/sidebars/dashboard-sidebar/species-info/species-info-component.jsx
similarity index 94%
rename from src/containers/sidebars/dashboard-sidebar/species-info/component.jsx
rename to src/containers/sidebars/dashboard-sidebar/species-info/species-info-component.jsx
index 2e06d8427..96b185278 100644
--- a/src/containers/sidebars/dashboard-sidebar/species-info/component.jsx
+++ b/src/containers/sidebars/dashboard-sidebar/species-info/species-info-component.jsx
@@ -1,6 +1,6 @@
import React from 'react';
-import styles from './styles.module.scss';
+import styles from './species-info-styles.module.scss';
function SpeciesInfoComponent() {
return (
diff --git a/src/containers/sidebars/dashboard-sidebar/species-info/styles.module.scss b/src/containers/sidebars/dashboard-sidebar/species-info/species-info-styles.module.scss
similarity index 100%
rename from src/containers/sidebars/dashboard-sidebar/species-info/styles.module.scss
rename to src/containers/sidebars/dashboard-sidebar/species-info/species-info-styles.module.scss
diff --git a/src/containers/views/dashboard-view/dashboard-view-component.jsx b/src/containers/views/dashboard-view/dashboard-view-component.jsx
new file mode 100644
index 000000000..46c9e05b4
--- /dev/null
+++ b/src/containers/views/dashboard-view/dashboard-view-component.jsx
@@ -0,0 +1,62 @@
+import React from 'react';
+
+import loadable from '@loadable/component';
+
+import CountryLabelsLayer from 'containers/layers/country-labels-layer';
+import RegionsLabelsLayer from 'containers/layers/regions-labels-layer';
+import ArcgisLayerManager from 'containers/managers/arcgis-layer-manager';
+import SideMenu from 'containers/menus/sidemenu';
+
+import MapView from '../../../components/map-view';
+import DashboardSidebar from '../../sidebars/dashboard-sidebar/dashboard-sidebar-component';
+
+const LabelsLayer = loadable(() => import('containers/layers/labels-layer'));
+const { REACT_APP_ARGISJS_API_VERSION: API_VERSION } = process.env;
+
+function DashboardViewComponent(props) {
+ const {
+ updatedActiveLayers,
+ onMapLoad,
+ sceneMode,
+ viewSettings,
+ countryISO,
+ countryName,
+ isFullscreenActive,
+ openedModal,
+ } = props;
+
+ return (
+
+
+
+
+
+
+
+
+
+
+
+
+ );
+}
+
+export default DashboardViewComponent;
diff --git a/src/containers/views/dashboard-view/dashboard-view-config.js b/src/containers/views/dashboard-view/dashboard-view-config.js
new file mode 100644
index 000000000..304f91434
--- /dev/null
+++ b/src/containers/views/dashboard-view/dashboard-view-config.js
@@ -0,0 +1,67 @@
+import {
+ GRAPHIC_LAYER,
+ ALL_TAXA_PRIORITY,
+ CITIES_LABELS_LAYER,
+ REGIONS_LABELS_LAYER,
+ ADMIN_AREAS_FEATURE_LAYER,
+ COUNTRIES_LABELS_FEATURE_LAYER,
+ LANDSCAPE_FEATURES_LABELS_LAYER,
+ FIREFLY_BASEMAP_LAYER,
+ SATELLITE_BASEMAP_LAYER,
+} from 'constants/layers-slugs';
+import {
+ DEFAULT_OPACITY,
+ LAYERS_CATEGORIES,
+} from 'constants/mol-layers-configs';
+
+export default {
+ view: {
+ activeLayers: [
+ { title: GRAPHIC_LAYER },
+ { title: CITIES_LABELS_LAYER },
+ { title: REGIONS_LABELS_LAYER, opacity: 0 },
+ { title: COUNTRIES_LABELS_FEATURE_LAYER },
+ { title: LANDSCAPE_FEATURES_LABELS_LAYER },
+ {
+ title: ALL_TAXA_PRIORITY,
+ opacity: DEFAULT_OPACITY,
+ category: LAYERS_CATEGORIES.BIODIVERSITY,
+ },
+ { title: ADMIN_AREAS_FEATURE_LAYER },
+ ],
+ padding: {
+ left: 300,
+ },
+ environment: {
+ atmosphereEnabled: false,
+ background: {
+ type: 'color',
+ color: [0, 10, 16],
+ },
+ alphaCompositingEnabled: true,
+ },
+ constraints: {
+ altitude: {
+ max: 35512548,
+ min: 10000,
+ },
+ minZoom: 3,
+ rotationEnabled: false,
+ snapToZoom: false,
+ minScale: 147914381,
+ },
+ ui: {
+ components: [],
+ },
+ basemap: {
+ layersArray: [FIREFLY_BASEMAP_LAYER, SATELLITE_BASEMAP_LAYER],
+ },
+ },
+ ui: {
+ isSidebarOpen: false,
+ isFullscreenActive: false,
+ activeCategory: '',
+ sceneMode: 'data',
+ selectedAnalysisLayer: ADMIN_AREAS_FEATURE_LAYER,
+ },
+};
diff --git a/src/containers/views/dashboard-view/dashboard-view-selectors.js b/src/containers/views/dashboard-view/dashboard-view-selectors.js
new file mode 100644
index 000000000..bae44a568
--- /dev/null
+++ b/src/containers/views/dashboard-view/dashboard-view-selectors.js
@@ -0,0 +1,40 @@
+import { createSelector, createStructuredSelector } from 'reselect';
+
+import { selectAoiId } from 'selectors/aoi-selectors';
+import { selectUiUrlState } from 'selectors/location-selectors';
+import { selectTooltipData } from 'selectors/map-tooltip-selectors';
+import { selectSceneView } from 'selectors/scene-selectors';
+import { getSidebarTabActive } from 'selectors/ui-selectors';
+
+import {
+ getSelectedAnalysisLayer,
+ getSelectedAnalysisTab,
+} from 'pages/data-globe/data-globe-selectors';
+
+import aoiSceneConfig from 'containers/scenes/aoi-scene/config';
+
+const selectTemporaryPosition = ({ location }) =>
+ (location.query && location.query.centerOn) || null;
+
+const getUiSettings = createSelector(selectUiUrlState, (uiUrlState) => {
+ return {
+ ...aoiSceneConfig.ui,
+ ...uiUrlState,
+ };
+});
+
+const getActiveCategoryLayers = createSelector(
+ getUiSettings,
+ (uiSettings) => uiSettings.activeCategoryLayers
+);
+
+export default createStructuredSelector({
+ aoiId: selectAoiId,
+ activeCategoryLayers: getActiveCategoryLayers,
+ mapTooltipData: selectTooltipData,
+ sidebarTabActive: getSidebarTabActive,
+ selectedAnalysisLayer: getSelectedAnalysisLayer,
+ selectedAnalysisTab: getSelectedAnalysisTab,
+ centerOn: selectTemporaryPosition,
+ view: selectSceneView,
+});
diff --git a/src/containers/views/dashboard-view/dashboard-view.js b/src/containers/views/dashboard-view/dashboard-view.js
new file mode 100644
index 000000000..833cf5ef8
--- /dev/null
+++ b/src/containers/views/dashboard-view/dashboard-view.js
@@ -0,0 +1,43 @@
+import React, { useEffect, useState } from 'react';
+import { connect } from 'react-redux';
+
+import unionBy from 'lodash/unionBy';
+
+import { ADMIN_AREAS_FEATURE_LAYER } from 'constants/layers-slugs';
+
+import Component from './dashboard-view-component';
+import mapStateToProps from './dashboard-view-selectors';
+
+function DashboardView(props) {
+ const { activeLayers, changeUI, activeCategoryLayers, viewSettings } = props;
+
+ const activeLayersWithoutAdmin = activeLayers.filter(
+ (ual) => ual.title !== ADMIN_AREAS_FEATURE_LAYER
+ );
+
+ const [updatedActiveLayers, setUpdatedActiveLayers] = useState(
+ activeLayersWithoutAdmin
+ );
+
+ useEffect(() => {
+ // Add temporary activeCategoryLayers to activeLayers at render and reset the param
+ if (activeCategoryLayers) {
+ setUpdatedActiveLayers(
+ unionBy(activeCategoryLayers, activeLayers, 'title')
+ );
+ changeUI({ activeCategoryLayers: undefined });
+ } else {
+ setUpdatedActiveLayers(activeLayers);
+ }
+ }, [activeLayers]);
+
+ return (
+
+ );
+}
+
+export default connect(mapStateToProps, null)(DashboardView);
diff --git a/src/containers/views/dashboard/component.jsx b/src/containers/views/dashboard/component.jsx
deleted file mode 100644
index 5e5af8a19..000000000
--- a/src/containers/views/dashboard/component.jsx
+++ /dev/null
@@ -1,19 +0,0 @@
-import React from 'react';
-
-import MapView from '../../../components/map-view';
-import DashboardSidebar from '../../sidebars/dashboard-sidebar/component';
-
-const { REACT_APP_ARGISJS_API_VERSION: API_VERSION } = process.env;
-
-function DashboardViewComponent() {
- return (
-
-
-
- );
-}
-
-export default DashboardViewComponent;
diff --git a/src/containers/views/dashboard/index.js b/src/containers/views/dashboard/index.js
deleted file mode 100644
index ef0731491..000000000
--- a/src/containers/views/dashboard/index.js
+++ /dev/null
@@ -1,9 +0,0 @@
-import React from 'react';
-
-import Component from './component';
-
-function DashboardView(props) {
- return
;
-}
-
-export default DashboardView;
diff --git a/src/pages/dashboard/component.jsx b/src/pages/dashboard/component.jsx
deleted file mode 100644
index 9e002d34f..000000000
--- a/src/pages/dashboard/component.jsx
+++ /dev/null
@@ -1,20 +0,0 @@
-import React from 'react';
-
-import cx from 'classnames';
-
-import Logo from 'components/half-earth-logo';
-
-import uiStyles from 'styles/ui.module.scss';
-
-import DashboardView from '../../containers/views/dashboard';
-
-function DashboardPageComponent(props) {
- return (
- <>
-
-
- >
- );
-}
-
-export default DashboardPageComponent;
diff --git a/src/pages/dashboard/dashboard-component.jsx b/src/pages/dashboard/dashboard-component.jsx
new file mode 100644
index 000000000..1e68b3211
--- /dev/null
+++ b/src/pages/dashboard/dashboard-component.jsx
@@ -0,0 +1,62 @@
+import React from 'react';
+
+import cx from 'classnames';
+
+import Logo from 'components/half-earth-logo';
+
+import uiStyles from 'styles/ui.module.scss';
+
+import DashboardView from '../../containers/views/dashboard-view/dashboard-view';
+
+function DashboardComponent(props) {
+ const {
+ sceneMode,
+ countryISO,
+ countryName,
+ openedModal,
+ activeLayers,
+ handleMapLoad,
+ viewSettings,
+ isSidebarOpen,
+ activeCategory,
+ selectedSpecies,
+ isFullscreenActive,
+ handleGlobeUpdating,
+ countedActiveLayers,
+ isBiodiversityActive,
+ countryTooltipDisplayFor,
+ onboardingType,
+ onboardingStep,
+ waitingInteraction,
+ aoiId,
+ } = props;
+ return (
+ <>
+
+
handleMapLoad(map, activeLayers)}
+ {...props}
+ />
+ >
+ );
+}
+
+export default DashboardComponent;
diff --git a/src/pages/dashboard/dashboard-selectors.js b/src/pages/dashboard/dashboard-selectors.js
new file mode 100644
index 000000000..5a96498e6
--- /dev/null
+++ b/src/pages/dashboard/dashboard-selectors.js
@@ -0,0 +1,138 @@
+/* eslint-disable max-len */
+import { isEmpty } from 'lodash';
+import { createSelector, createStructuredSelector } from 'reselect';
+
+import { getDataGlobeLayers } from 'selectors/layers-selectors';
+import {
+ selectGlobeUrlState,
+ selectUiUrlState,
+} from 'selectors/location-selectors';
+
+import dashboardViewConfig from '../../containers/views/dashboard-view/dashboard-view-config';
+
+const selectBiodiversityData = ({ biodiversityData }) =>
+ biodiversityData && (biodiversityData.data || null);
+const selectMetadataData = ({ metadata }) =>
+ metadata && (!isEmpty(metadata.data) || null);
+const selectCountryExtent = ({ countryExtent }) =>
+ countryExtent ? countryExtent.data : null;
+
+const getViewSettings = createSelector(selectGlobeUrlState, (globeUrlState) => {
+ return {
+ ...dashboardViewConfig.view,
+ ...globeUrlState,
+ };
+});
+
+const getUiSettings = createSelector(selectUiUrlState, (uiUrlState) => {
+ return {
+ ...dashboardViewConfig.ui,
+ ...uiUrlState,
+ };
+});
+
+export const getActiveLayers = createSelector(
+ getViewSettings,
+ (viewSettings) => viewSettings.activeLayers
+);
+export const getCountryTooltipDisplayFor = createSelector(
+ getViewSettings,
+ (viewSettings) => viewSettings.countryTooltipDisplayFor
+);
+const getGlobeUpdating = createSelector(
+ getViewSettings,
+ (viewSettings) => viewSettings.isGlobeUpdating
+);
+const getSelectedSpecies = createSelector(
+ getViewSettings,
+ (viewSettings) => viewSettings.selectedSpecies
+);
+export const getCountryISO = createSelector(
+ getViewSettings,
+ (viewSettings) => viewSettings.countryISO
+);
+const getCountryName = createSelector(
+ getViewSettings,
+ (viewSettings) => viewSettings.countryName
+);
+const getSidebarVisibility = createSelector(
+ getUiSettings,
+ (uiSettings) => uiSettings.isSidebarOpen
+);
+const getFullscreenActive = createSelector(
+ getUiSettings,
+ (uiSettings) => uiSettings.isFullscreenActive
+);
+const getActiveCategory = createSelector(
+ getUiSettings,
+ (uiSettings) => uiSettings.activeCategory
+);
+const getHalfEarthModalOpen = createSelector(
+ getUiSettings,
+ (uiSettings) => uiSettings.openedModal
+);
+const getSceneMode = createSelector(
+ getUiSettings,
+ (uiSettings) => uiSettings.sceneMode
+);
+const getCountryChallengesSelectedKey = createSelector(
+ getUiSettings,
+ (uiSettings) => uiSettings.countryChallengesSelectedKey
+);
+export const getLocalSceneFilters = createSelector(
+ getUiSettings,
+ (uiSettings) => uiSettings.localSceneFilters
+);
+export const getCountryChallengesSelectedFilter = createSelector(
+ getUiSettings,
+ (uiSettings) => uiSettings.countryChallengesSelectedFilter
+);
+export const getOnboardingType = createSelector(
+ getUiSettings,
+ (uiSettings) => uiSettings.onboardingType
+);
+export const getOnboardingStep = createSelector(
+ getUiSettings,
+ (uiSettings) => uiSettings.onboardingStep
+);
+export const getOnWaitingInteraction = createSelector(
+ getUiSettings,
+ (uiSettings) => uiSettings.waitingInteraction
+);
+export const getAOIId = createSelector(
+ getUiSettings,
+ (uiSettings) => uiSettings.aoiId
+);
+export const getSelectedAnalysisLayer = createSelector(
+ getUiSettings,
+ (uiSettings) => uiSettings.selectedAnalysisLayer
+);
+export const getSelectedAnalysisTab = createSelector(
+ getUiSettings,
+ (uiSettings) => uiSettings.selectedAnalysisTab || 'click'
+);
+
+export default createStructuredSelector({
+ viewSettings: getViewSettings,
+ sceneLayers: getDataGlobeLayers,
+ activeLayers: getActiveLayers,
+ countryISO: getCountryISO,
+ countryName: getCountryName,
+ isSidebarOpen: getSidebarVisibility,
+ isGlobeUpdating: getGlobeUpdating,
+ isFullscreenActive: getFullscreenActive,
+ activeCategory: getActiveCategory,
+ speciesCategories: selectBiodiversityData,
+ hasMetadata: selectMetadataData,
+ selectedSpecies: getSelectedSpecies,
+ openedModal: getHalfEarthModalOpen,
+ sceneMode: getSceneMode,
+ countryTooltipDisplayFor: getCountryTooltipDisplayFor,
+ countryChallengesSelectedKey: getCountryChallengesSelectedKey,
+ countryExtent: selectCountryExtent,
+ localSceneFilters: getLocalSceneFilters,
+ onboardingType: getOnboardingType,
+ onboardingStep: getOnboardingStep,
+ waitingInteraction: getOnWaitingInteraction,
+ aoiId: getAOIId,
+});
diff --git a/src/pages/dashboard/index.js b/src/pages/dashboard/index.js
index 152bae747..8caeb623c 100644
--- a/src/pages/dashboard/index.js
+++ b/src/pages/dashboard/index.js
@@ -1,11 +1,27 @@
import React from 'react';
import { connect } from 'react-redux';
-import Component from './component';
-import mapStateToProps from './selectors';
+import { activateLayersOnLoad } from 'utils/layer-manager-utils';
-function DashboardComponent(props) {
- return ;
+import { layersConfig } from 'constants/mol-layers-configs';
+
+import { setBasemap } from '../../utils/layer-manager-utils.js';
+
+import DashboardComponent from './dashboard-component';
+import mapStateToProps from './dashboard-selectors';
+
+function DashboardContainer(props) {
+ const { viewSettings } = props;
+ const handleMapLoad = (map, activeLayers) => {
+ console.log('map view loaded', map);
+ setBasemap({
+ map,
+ layersArray: viewSettings.basemap.layersArray,
+ });
+ activateLayersOnLoad(map, activeLayers, layersConfig);
+ };
+
+ return ;
}
-export default connect(mapStateToProps, null)(DashboardComponent);
+export default connect(mapStateToProps, null)(DashboardContainer);
diff --git a/src/pages/dashboard/selectors.js b/src/pages/dashboard/selectors.js
deleted file mode 100644
index e6865f665..000000000
--- a/src/pages/dashboard/selectors.js
+++ /dev/null
@@ -1,35 +0,0 @@
-import { createSelector, createStructuredSelector } from 'reselect';
-
-const selectCountryIso = ({ location }) => location.payload.iso.toUpperCase();
-const selectCountriesData = ({ countryData }) =>
- countryData && countryData.data;
-
-const getCountryData = createSelector(
- [selectCountriesData, selectCountryIso],
- (countriesData, countryISO) => {
- if (!countriesData || !countryISO) {
- return null;
- }
- return countriesData[countryISO];
- }
-);
-
-const getCountryName = createSelector([getCountryData], (countryData) => {
- if (!countryData) {
- return null;
- }
- return countryData.NAME_0;
-});
-
-const getCountryId = createSelector([getCountryData], (countryData) => {
- if (!countryData) {
- return null;
- }
- return countryData.OBJECTID;
-});
-
-export default createStructuredSelector({
- countryISO: selectCountryIso,
- countryId: getCountryId,
- countryName: getCountryName,
-});
From 72bcf9952528c43f279fe175f425eb107aec6fc2 Mon Sep 17 00:00:00 2001
From: Chris Manciero
Date: Thu, 6 Jun 2024 09:01:36 -0400
Subject: [PATCH 006/350] adding data layers ui
---
.../dashboard-sidebar-component.jsx | 2 +-
.../dashboard-sidebar-styles.module.scss | 21 ++-----------
.../data-layers/data-layers-component.jsx | 30 +++++++++++++++++--
.../data-layers-styles.module.scss | 9 ++++++
.../species-info-styles.module.scss | 19 +++++++-----
.../dashboard-view/dashboard-view-config.js | 10 -------
6 files changed, 53 insertions(+), 38 deletions(-)
create mode 100644 src/containers/sidebars/dashboard-sidebar/data-layers/data-layers-styles.module.scss
diff --git a/src/containers/sidebars/dashboard-sidebar/dashboard-sidebar-component.jsx b/src/containers/sidebars/dashboard-sidebar/dashboard-sidebar-component.jsx
index 6f0b73de5..684d218e3 100644
--- a/src/containers/sidebars/dashboard-sidebar/dashboard-sidebar-component.jsx
+++ b/src/containers/sidebars/dashboard-sidebar/dashboard-sidebar-component.jsx
@@ -6,7 +6,7 @@ import SpeciesInfoContainer from './species-info';
function DashboardSidebar() {
return (
-
+
diff --git a/src/containers/sidebars/dashboard-sidebar/dashboard-sidebar-styles.module.scss b/src/containers/sidebars/dashboard-sidebar/dashboard-sidebar-styles.module.scss
index 76ae53ffe..cc7d22e6f 100644
--- a/src/containers/sidebars/dashboard-sidebar/dashboard-sidebar-styles.module.scss
+++ b/src/containers/sidebars/dashboard-sidebar/dashboard-sidebar-styles.module.scss
@@ -3,34 +3,20 @@
@import 'styles/typography-extends';
@import 'styles/common-animations.module';
-$sidebar-content-top: 180px;
-.sidebarContainer {
- @include animationFunction($propertyToAnimate: all);
- position: absolute;
- height: calc(100vh - #{$nav-bar-height});
- width: calc(#{$sidebar-width} + 30px);
- top: $nav-bar-height;
- left: $site-gutter;
- padding-bottom: $site-gutter;
- padding-left: 5px;
-
- display: flex;
- flex-direction: column;
- gap: 10px;
-}
+$top: calc(#{$sidebar-top-margin} + #{$he-project-logo-size});
.container {
@extend %verticalScrollbar;
@include backdropBlur();
position: absolute;
- top: $sidebar-content-top;
+ top: $top;
left: $site-gutter;
display: flex;
flex-direction: column;
border: $sidebar-border;
border-radius: $sidebar-border-radius;
- height: calc(100vh - #{$sidebar-content-top});
+ height: calc(100vh - #{$top});
width: $sidebar-width;
padding: $site-gutter;
z-index: $bring-to-front;
@@ -39,7 +25,6 @@ $sidebar-content-top: 180px;
.sidenav{
display: flex;
height: 100%;
- background: rgba(255, 255, 255, 0.4);
.icons{
display: flex;
diff --git a/src/containers/sidebars/dashboard-sidebar/data-layers/data-layers-component.jsx b/src/containers/sidebars/dashboard-sidebar/data-layers/data-layers-component.jsx
index 2ce39b4f3..e86663f0b 100644
--- a/src/containers/sidebars/dashboard-sidebar/data-layers/data-layers-component.jsx
+++ b/src/containers/sidebars/dashboard-sidebar/data-layers/data-layers-component.jsx
@@ -1,7 +1,33 @@
import React from 'react';
-function DataLayerComponent() {
- return DataLayerComponent
;
+import LayerToggle from 'components/layer-toggle';
+
+import { FUTURE_PLACES_SLUG } from 'constants/analyze-areas-constants';
+
+import styles from './data-layers-styles.module.scss';
+
+function DataLayerComponent(props) {
+ const { map, activeLayers, handleLayerToggle, showProgress } = props;
+ const speciesLayers = [];
+ return (
+
+ );
}
export default DataLayerComponent;
diff --git a/src/containers/sidebars/dashboard-sidebar/data-layers/data-layers-styles.module.scss b/src/containers/sidebars/dashboard-sidebar/data-layers/data-layers-styles.module.scss
new file mode 100644
index 000000000..23df7c001
--- /dev/null
+++ b/src/containers/sidebars/dashboard-sidebar/data-layers/data-layers-styles.module.scss
@@ -0,0 +1,9 @@
+@import 'styles/ui.module';
+@import 'styles/settings';
+@import 'styles/typography-extends';
+@import 'styles/common-animations.module';
+
+.container{
+ display: flex;
+ flex-direction: column;
+}
diff --git a/src/containers/sidebars/dashboard-sidebar/species-info/species-info-styles.module.scss b/src/containers/sidebars/dashboard-sidebar/species-info/species-info-styles.module.scss
index ce425595a..560465bb6 100644
--- a/src/containers/sidebars/dashboard-sidebar/species-info/species-info-styles.module.scss
+++ b/src/containers/sidebars/dashboard-sidebar/species-info/species-info-styles.module.scss
@@ -6,8 +6,6 @@
.species{
display: flex;
flex-direction: column;
- gap: 15px;
- background-color: #efefef;
.title{
display: flex;
@@ -22,16 +20,20 @@
.info{
display: flex;
flex-direction: column;
- gap: 5px;
+ gap: 3px;
+ color: $white;
+ margin: 0 0 $site-gutter / 2 0;
.commonName{
- font-weight: 700;
+ @extend %display1;
font-size: 24px;
+ line-height: 1.5;
}
.taxa{
font-style: italic;
font-size: 18px;
+ line-height: 1.5;
}
img{
@@ -39,9 +41,12 @@
height: 60px;
}
}
+ }
- .description {
- font-size: 14px;
- }
+ .description {
+ @extend %bodyText;
+ color: $white;
+ margin: 0 0 $site-gutter / 2 0;
+ font-size: 14px;
}
}
diff --git a/src/containers/views/dashboard-view/dashboard-view-config.js b/src/containers/views/dashboard-view/dashboard-view-config.js
index 304f91434..d707ee476 100644
--- a/src/containers/views/dashboard-view/dashboard-view-config.js
+++ b/src/containers/views/dashboard-view/dashboard-view-config.js
@@ -1,6 +1,5 @@
import {
GRAPHIC_LAYER,
- ALL_TAXA_PRIORITY,
CITIES_LABELS_LAYER,
REGIONS_LABELS_LAYER,
ADMIN_AREAS_FEATURE_LAYER,
@@ -9,10 +8,6 @@ import {
FIREFLY_BASEMAP_LAYER,
SATELLITE_BASEMAP_LAYER,
} from 'constants/layers-slugs';
-import {
- DEFAULT_OPACITY,
- LAYERS_CATEGORIES,
-} from 'constants/mol-layers-configs';
export default {
view: {
@@ -22,11 +17,6 @@ export default {
{ title: REGIONS_LABELS_LAYER, opacity: 0 },
{ title: COUNTRIES_LABELS_FEATURE_LAYER },
{ title: LANDSCAPE_FEATURES_LABELS_LAYER },
- {
- title: ALL_TAXA_PRIORITY,
- opacity: DEFAULT_OPACITY,
- category: LAYERS_CATEGORIES.BIODIVERSITY,
- },
{ title: ADMIN_AREAS_FEATURE_LAYER },
],
padding: {
From f6df55fc87ca5f404709996f5b9e61c2734bb8ff Mon Sep 17 00:00:00 2001
From: Chris Manciero
Date: Thu, 6 Jun 2024 14:30:53 -0400
Subject: [PATCH 007/350] add data layer checkboxes
---
.../dashboard-sidebar-component.jsx | 5 +-
.../data-layers/data-layers-component.jsx | 87 ++++++++++++++++++-
.../data-layers-styles.module.scss | 21 +++++
.../dashboard-view-component.jsx | 2 +-
4 files changed, 108 insertions(+), 7 deletions(-)
diff --git a/src/containers/sidebars/dashboard-sidebar/dashboard-sidebar-component.jsx b/src/containers/sidebars/dashboard-sidebar/dashboard-sidebar-component.jsx
index 684d218e3..6d09677af 100644
--- a/src/containers/sidebars/dashboard-sidebar/dashboard-sidebar-component.jsx
+++ b/src/containers/sidebars/dashboard-sidebar/dashboard-sidebar-component.jsx
@@ -4,7 +4,8 @@ import styles from './dashboard-sidebar-styles.module.scss';
import DataLayerContainer from './data-layers';
import SpeciesInfoContainer from './species-info';
-function DashboardSidebar() {
+function DashboardSidebar(props) {
+ const { activeLayers } = props;
return (
@@ -15,7 +16,7 @@ function DashboardSidebar() {
BI
RA
-
+
);
diff --git a/src/containers/sidebars/dashboard-sidebar/data-layers/data-layers-component.jsx b/src/containers/sidebars/dashboard-sidebar/data-layers/data-layers-component.jsx
index e86663f0b..b6822d722 100644
--- a/src/containers/sidebars/dashboard-sidebar/data-layers/data-layers-component.jsx
+++ b/src/containers/sidebars/dashboard-sidebar/data-layers/data-layers-component.jsx
@@ -1,6 +1,8 @@
import React from 'react';
+import Button from 'components/button';
import LayerToggle from 'components/layer-toggle';
+import SearchInput from 'components/search-input';
import { FUTURE_PLACES_SLUG } from 'constants/analyze-areas-constants';
@@ -8,12 +10,89 @@ import styles from './data-layers-styles.module.scss';
function DataLayerComponent(props) {
const { map, activeLayers, handleLayerToggle, showProgress } = props;
- const speciesLayers = [];
+ const speciesPublicLayers = [
+ {
+ name: 'Point Observations',
+ value: 'PointObservations',
+ },
+ {
+ name: 'Habitat Suitable Range',
+ value: 'PointObservations',
+ },
+ {
+ name: 'Local Inventories',
+ value: 'PointObservations',
+ },
+ {
+ name: 'Expert Range Maps',
+ value: 'PointObservations',
+ },
+ {
+ name: 'Regional Checklists',
+ value: 'PointObservations',
+ },
+ ];
+
+ const speciesPrivateLayers = [
+ {
+ name: 'Point Observations',
+ value: 'PointObservations',
+ },
+ ];
+
+ const speciesRegionsLayers = [
+ {
+ name: 'Protected Areas',
+ value: 'PointObservations',
+ },
+ {
+ name: 'Proposed Protected',
+ value: 'PointObservations',
+ },
+ {
+ name: 'Administrative Layers',
+ value: 'PointObservations',
+ },
+ ];
+
return (
- Download Data
-
- {speciesLayers.map((layer) => (
+
+
+ Distribute Data: Public
+ {speciesPublicLayers.map((layer) => (
+
+ ))}
+ Distribute Data: Private
+ {speciesPrivateLayers.map((layer) => (
+
+ ))}
+ Regions Data
+ {speciesRegionsLayers.map((layer) => (
-
+
Date: Mon, 10 Jun 2024 14:14:17 -0400
Subject: [PATCH 008/350] added icons and sections
---
src/assets/icons/analytics.svg | 1 +
src/assets/icons/stacks.svg | 1 +
src/assets/icons/timeline.svg | 1 +
.../biodiversity-indicators-component.jsx | 11 +++
...biodiversity-indicators-styles.module.scss | 12 +++
.../biodiversity-indicators/index.js | 9 +++
.../dashboard-sidebar-component.jsx | 48 ++++++++++--
.../dashboard-sidebar-styles.module.scss | 18 ++++-
.../data-layers/data-layers-component.jsx | 73 ++++++++++++++-----
.../data-layers-styles.module.scss | 27 ++++++-
.../dashboard-sidebar/data-layers/index.js | 43 ++++++++++-
.../regions-analysis/index.js | 9 +++
.../regions-analysis-component.jsx | 9 +++
.../regions-analysis-styles.module.scss | 12 +++
.../species-info-styles.module.scss | 1 +
15 files changed, 245 insertions(+), 30 deletions(-)
create mode 100644 src/assets/icons/analytics.svg
create mode 100644 src/assets/icons/stacks.svg
create mode 100644 src/assets/icons/timeline.svg
create mode 100644 src/containers/sidebars/dashboard-sidebar/biodiversity-indicators/biodiversity-indicators-component.jsx
create mode 100644 src/containers/sidebars/dashboard-sidebar/biodiversity-indicators/biodiversity-indicators-styles.module.scss
create mode 100644 src/containers/sidebars/dashboard-sidebar/biodiversity-indicators/index.js
create mode 100644 src/containers/sidebars/dashboard-sidebar/regions-analysis/index.js
create mode 100644 src/containers/sidebars/dashboard-sidebar/regions-analysis/regions-analysis-component.jsx
create mode 100644 src/containers/sidebars/dashboard-sidebar/regions-analysis/regions-analysis-styles.module.scss
diff --git a/src/assets/icons/analytics.svg b/src/assets/icons/analytics.svg
new file mode 100644
index 000000000..b9e077f5c
--- /dev/null
+++ b/src/assets/icons/analytics.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/src/assets/icons/stacks.svg b/src/assets/icons/stacks.svg
new file mode 100644
index 000000000..964df48ed
--- /dev/null
+++ b/src/assets/icons/stacks.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/src/assets/icons/timeline.svg b/src/assets/icons/timeline.svg
new file mode 100644
index 000000000..9dfe6fae4
--- /dev/null
+++ b/src/assets/icons/timeline.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/src/containers/sidebars/dashboard-sidebar/biodiversity-indicators/biodiversity-indicators-component.jsx b/src/containers/sidebars/dashboard-sidebar/biodiversity-indicators/biodiversity-indicators-component.jsx
new file mode 100644
index 000000000..409e6fc94
--- /dev/null
+++ b/src/containers/sidebars/dashboard-sidebar/biodiversity-indicators/biodiversity-indicators-component.jsx
@@ -0,0 +1,11 @@
+import React from 'react';
+
+import styles from './biodiversity-indicators-styles.module.scss';
+
+function BioDiversityComponent() {
+ return (
+
+ );
+}
+
+export default BioDiversityComponent;
diff --git a/src/containers/sidebars/dashboard-sidebar/biodiversity-indicators/biodiversity-indicators-styles.module.scss b/src/containers/sidebars/dashboard-sidebar/biodiversity-indicators/biodiversity-indicators-styles.module.scss
new file mode 100644
index 000000000..eaddfa125
--- /dev/null
+++ b/src/containers/sidebars/dashboard-sidebar/biodiversity-indicators/biodiversity-indicators-styles.module.scss
@@ -0,0 +1,12 @@
+@import 'styles/ui.module';
+@import 'styles/settings';
+@import 'styles/typography-extends';
+@import 'styles/common-animations.module';
+
+.container{
+ display: flex;
+ flex-direction: column;
+ padding: 5px 10px;
+ width: 100%;
+ color: $white;
+}
diff --git a/src/containers/sidebars/dashboard-sidebar/biodiversity-indicators/index.js b/src/containers/sidebars/dashboard-sidebar/biodiversity-indicators/index.js
new file mode 100644
index 000000000..c637dc090
--- /dev/null
+++ b/src/containers/sidebars/dashboard-sidebar/biodiversity-indicators/index.js
@@ -0,0 +1,9 @@
+import React from 'react';
+
+import BioDiversityComponent from './biodiversity-indicators-component';
+
+function BioDiversityContainer(props) {
+ return ;
+}
+
+export default BioDiversityContainer;
diff --git a/src/containers/sidebars/dashboard-sidebar/dashboard-sidebar-component.jsx b/src/containers/sidebars/dashboard-sidebar/dashboard-sidebar-component.jsx
index 6d09677af..3446b82ae 100644
--- a/src/containers/sidebars/dashboard-sidebar/dashboard-sidebar-component.jsx
+++ b/src/containers/sidebars/dashboard-sidebar/dashboard-sidebar-component.jsx
@@ -1,22 +1,60 @@
-import React from 'react';
+import React, { useState } from 'react';
+import cx from 'classnames';
+
+import { ReactComponent as AnalyticsIcon } from 'icons/analytics.svg';
+import { ReactComponent as StacksIcon } from 'icons/stacks.svg';
+import { ReactComponent as TimeLineIcon } from 'icons/timeline.svg';
+
+import BioDiversityContainer from './biodiversity-indicators';
import styles from './dashboard-sidebar-styles.module.scss';
import DataLayerContainer from './data-layers';
+import RegionsAnalysisComponent from './regions-analysis/regions-analysis-component';
import SpeciesInfoContainer from './species-info';
function DashboardSidebar(props) {
const { activeLayers } = props;
+ const [selectedIndex, setSelectedIndex] = useState(1);
+
return (
-
DL
-
BI
-
RA
+
setSelectedIndex(1)}
+ >
+
+
+
setSelectedIndex(2)}
+ >
+
+
+
setSelectedIndex(3)}
+ >
+
+
-
+ {selectedIndex === 1 && (
+
+ )}
+ {selectedIndex === 2 && }
+ {selectedIndex === 3 && }
);
diff --git a/src/containers/sidebars/dashboard-sidebar/dashboard-sidebar-styles.module.scss b/src/containers/sidebars/dashboard-sidebar/dashboard-sidebar-styles.module.scss
index cc7d22e6f..45d0c86ba 100644
--- a/src/containers/sidebars/dashboard-sidebar/dashboard-sidebar-styles.module.scss
+++ b/src/containers/sidebars/dashboard-sidebar/dashboard-sidebar-styles.module.scss
@@ -18,7 +18,6 @@ $top: calc(#{$sidebar-top-margin} + #{$he-project-logo-size});
border-radius: $sidebar-border-radius;
height: calc(100vh - #{$top});
width: $sidebar-width;
- padding: $site-gutter;
z-index: $bring-to-front;
}
@@ -32,10 +31,23 @@ $top: calc(#{$sidebar-top-margin} + #{$he-project-logo-size});
height: 100%;
border-right: 1px solid;
- span{
- display: inline-block;
+ button{
width: 50px;
height: 50px;
+
+ svg{
+ width: 30px;
+ height: 30px;
+ }
+
+ &.selected,
+ &:hover{
+ background: $white;
+
+ svg{
+ fill: $black;
+ }
+ }
}
}
}
diff --git a/src/containers/sidebars/dashboard-sidebar/data-layers/data-layers-component.jsx b/src/containers/sidebars/dashboard-sidebar/data-layers/data-layers-component.jsx
index b6822d722..eac34fa93 100644
--- a/src/containers/sidebars/dashboard-sidebar/data-layers/data-layers-component.jsx
+++ b/src/containers/sidebars/dashboard-sidebar/data-layers/data-layers-component.jsx
@@ -1,10 +1,20 @@
import React from 'react';
+import cx from 'classnames';
+
import Button from 'components/button';
import LayerToggle from 'components/layer-toggle';
-import SearchInput from 'components/search-input';
+// import SearchInput from 'components/search-input';
+
+import {
+ PROTECTION_SLUG,
+ LAND_HUMAN_PRESSURES_SLUG,
+ BIODIVERSITY_SLUG,
+} from 'constants/analyze-areas-constants';
-import { FUTURE_PLACES_SLUG } from 'constants/analyze-areas-constants';
+import hrTheme from 'styles/themes/hr-theme.module.scss';
+
+import { ReactComponent as ArrowIcon } from 'icons/arrow_right.svg';
import styles from './data-layers-styles.module.scss';
@@ -13,48 +23,50 @@ function DataLayerComponent(props) {
const speciesPublicLayers = [
{
name: 'Point Observations',
- value: 'PointObservations',
+ value: 'countries_labels_layer',
},
{
name: 'Habitat Suitable Range',
- value: 'PointObservations',
+ value: 'protected_areas_vector_tile_layer',
},
{
name: 'Local Inventories',
- value: 'PointObservations',
+ value: 'regions_labels_layer',
},
{
name: 'Expert Range Maps',
- value: 'PointObservations',
+ value: 'countries_data_layer',
},
{
name: 'Regional Checklists',
- value: 'PointObservations',
+ value: 'community_areas_vector_tile_layer',
},
];
const speciesPrivateLayers = [
{
name: 'Point Observations',
- value: 'PointObservations',
+ value: 'PointObservations6',
},
];
const speciesRegionsLayers = [
{
name: 'Protected Areas',
- value: 'PointObservations',
+ value: 'PointObservations7',
},
{
name: 'Proposed Protected',
- value: 'PointObservations',
+ value: 'PointObservations8',
},
{
name: 'Administrative Layers',
- value: 'PointObservations',
+ value: 'PointObservations9',
},
];
+ const isOpened = true;
+
return (
-
- Distribute Data: Public
+ {/* */}
+
+ {}}>
+
+ Distribute Data: Public
+
+
{speciesPublicLayers.map((layer) => (
))}
- Distribute Data: Private
+
+ {}}>
+
+ Distribute Data: Private
+
{speciesPrivateLayers.map((layer) => (
))}
- Regions Data
+
+ {}}>
+
+ Regions Data
+
{speciesRegionsLayers.map((layer) => (
))}
diff --git a/src/containers/sidebars/dashboard-sidebar/data-layers/data-layers-styles.module.scss b/src/containers/sidebars/dashboard-sidebar/data-layers/data-layers-styles.module.scss
index 6f1a8ab9f..72f043f84 100644
--- a/src/containers/sidebars/dashboard-sidebar/data-layers/data-layers-styles.module.scss
+++ b/src/containers/sidebars/dashboard-sidebar/data-layers/data-layers-styles.module.scss
@@ -6,6 +6,8 @@
.container{
display: flex;
flex-direction: column;
+ padding: 5px 10px;
+ width: 100%;
.saveButton {
color: $dark-text;
@@ -24,7 +26,30 @@
max-width: 300px;
}
- h3{
+ .sectionTitle{
+ display: flex;
+ gap: 8px;
+ align-items: center;
+ font-size: 14px;
+ font-weight: 700;
+ text-transform: uppercase;
+ line-height: 1.5;
color: $white;
+
+ .arrowIcon {
+ fill: $white;
+ transform: rotate(90deg);
+
+ &.isOpened {
+ transform:rotate(-90deg);
+ }
+
+ transition: transform 0.2s ease;
+
+ > path {
+ fill: inherit;
+ }
}
}
+
+}
diff --git a/src/containers/sidebars/dashboard-sidebar/data-layers/index.js b/src/containers/sidebars/dashboard-sidebar/data-layers/index.js
index e71e73498..2ef6dd758 100644
--- a/src/containers/sidebars/dashboard-sidebar/data-layers/index.js
+++ b/src/containers/sidebars/dashboard-sidebar/data-layers/index.js
@@ -1,9 +1,46 @@
-import React from 'react';
+import React, { useState } from 'react';
+import { connect } from 'react-redux';
+import metadataActions from 'redux_modules/metadata';
+
+import * as urlActions from 'actions/url-actions';
+
+import { layerManagerToggle } from 'utils/layer-manager-utils';
+
+import { LAYERS_CATEGORIES } from 'constants/mol-layers-configs';
import DataLayerComponent from './data-layers-component';
+const actions = { ...metadataActions, ...urlActions };
+
function DataLayerContainer(props) {
- return ;
+ const { activeLayers, changeGlobe } = props;
+
+ const [selectedLayers, setSelectedLayers] = useState([]);
+
+ const handleLayerToggle = (option) => {
+ if (selectedLayers.find((layer) => layer === option.value)) {
+ setSelectedLayers(
+ selectedLayers.filter((layer) => layer !== option.value)
+ );
+ } else {
+ setSelectedLayers([...selectedLayers, option.value]);
+ }
+
+ layerManagerToggle(
+ option.value,
+ activeLayers,
+ changeGlobe,
+ LAYERS_CATEGORIES.PROTECTION
+ );
+ };
+
+ return (
+
+ );
}
-export default DataLayerContainer;
+export default connect(null, actions)(DataLayerContainer);
diff --git a/src/containers/sidebars/dashboard-sidebar/regions-analysis/index.js b/src/containers/sidebars/dashboard-sidebar/regions-analysis/index.js
new file mode 100644
index 000000000..1b2acf3e3
--- /dev/null
+++ b/src/containers/sidebars/dashboard-sidebar/regions-analysis/index.js
@@ -0,0 +1,9 @@
+import React from 'react';
+
+import RegionsAnalysisComponent from './regions-analysis-component';
+
+function RegionsAnalysisContainer(props) {
+ return ;
+}
+
+export default RegionsAnalysisContainer;
diff --git a/src/containers/sidebars/dashboard-sidebar/regions-analysis/regions-analysis-component.jsx b/src/containers/sidebars/dashboard-sidebar/regions-analysis/regions-analysis-component.jsx
new file mode 100644
index 000000000..61b75c859
--- /dev/null
+++ b/src/containers/sidebars/dashboard-sidebar/regions-analysis/regions-analysis-component.jsx
@@ -0,0 +1,9 @@
+import React from 'react';
+
+import styles from './regions-analysis-styles.module.scss';
+
+function RegionsAnalysisComponent() {
+ return ;
+}
+
+export default RegionsAnalysisComponent;
diff --git a/src/containers/sidebars/dashboard-sidebar/regions-analysis/regions-analysis-styles.module.scss b/src/containers/sidebars/dashboard-sidebar/regions-analysis/regions-analysis-styles.module.scss
new file mode 100644
index 000000000..eaddfa125
--- /dev/null
+++ b/src/containers/sidebars/dashboard-sidebar/regions-analysis/regions-analysis-styles.module.scss
@@ -0,0 +1,12 @@
+@import 'styles/ui.module';
+@import 'styles/settings';
+@import 'styles/typography-extends';
+@import 'styles/common-animations.module';
+
+.container{
+ display: flex;
+ flex-direction: column;
+ padding: 5px 10px;
+ width: 100%;
+ color: $white;
+}
diff --git a/src/containers/sidebars/dashboard-sidebar/species-info/species-info-styles.module.scss b/src/containers/sidebars/dashboard-sidebar/species-info/species-info-styles.module.scss
index 560465bb6..00810a4d2 100644
--- a/src/containers/sidebars/dashboard-sidebar/species-info/species-info-styles.module.scss
+++ b/src/containers/sidebars/dashboard-sidebar/species-info/species-info-styles.module.scss
@@ -6,6 +6,7 @@
.species{
display: flex;
flex-direction: column;
+ padding: $paragraph-gutter;
.title{
display: flex;
From 115d2a437dd75315c671af343706ef86ebaf7ee6 Mon Sep 17 00:00:00 2001
From: Chris Manciero
Date: Mon, 10 Jun 2024 14:30:08 -0400
Subject: [PATCH 009/350] add regions analysis draft
---
.../regions-analysis-component.jsx | 44 ++++++++++++++++++-
.../regions-analysis-styles.module.scss | 31 +++++++++++++
2 files changed, 74 insertions(+), 1 deletion(-)
diff --git a/src/containers/sidebars/dashboard-sidebar/regions-analysis/regions-analysis-component.jsx b/src/containers/sidebars/dashboard-sidebar/regions-analysis/regions-analysis-component.jsx
index 61b75c859..d470b3ab3 100644
--- a/src/containers/sidebars/dashboard-sidebar/regions-analysis/regions-analysis-component.jsx
+++ b/src/containers/sidebars/dashboard-sidebar/regions-analysis/regions-analysis-component.jsx
@@ -1,9 +1,51 @@
import React from 'react';
+import Button from 'components/button';
+
+import hrTheme from 'styles/themes/hr-theme.module.scss';
+
+import Checkbox from '../../../../components/checkbox/checkbox-component';
+
import styles from './regions-analysis-styles.module.scss';
function RegionsAnalysisComponent() {
- return ;
+ return (
+
+ Regions Analysis
+
+
+ Select a region type below to explore a table of regions in which this
+ species is expected to occur.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ );
}
export default RegionsAnalysisComponent;
diff --git a/src/containers/sidebars/dashboard-sidebar/regions-analysis/regions-analysis-styles.module.scss b/src/containers/sidebars/dashboard-sidebar/regions-analysis/regions-analysis-styles.module.scss
index eaddfa125..c91827085 100644
--- a/src/containers/sidebars/dashboard-sidebar/regions-analysis/regions-analysis-styles.module.scss
+++ b/src/containers/sidebars/dashboard-sidebar/regions-analysis/regions-analysis-styles.module.scss
@@ -9,4 +9,35 @@
padding: 5px 10px;
width: 100%;
color: $white;
+
+ .sectionTitle{
+ font-size: 18px;
+ font-weight: 700;
+ text-transform: uppercase;
+ line-height: 1.5;
+ color: $white;
+ }
+
+ p{
+ font-size: 12px;
+ }
+
+ .choices{
+ display: flex;
+ flex-direction: column;
+ gap: 5px;
+ }
+
+ .search{
+ display: flex;
+ column-gap: 8px;
+ margin-top: 8px;
+ .saveButton {
+ color: $dark-text;
+ background-color: $brand-color-main;
+ &:hover {
+ background-color: $brand-color-main-hover;
+ }
+ }
+ }
}
From c4c61d47a0e38fd02ce2de25f363ef2f2ad15d6e Mon Sep 17 00:00:00 2001
From: Chris Manciero
Date: Tue, 11 Jun 2024 11:06:51 -0400
Subject: [PATCH 010/350] add rangemap beta
---
src/constants/layers-slugs.js | 2 ++
src/constants/layers-urls.js | 3 +++
src/constants/metadata.js | 2 ++
src/constants/mol-layers-configs.js | 8 ++++++++
.../data-layers/data-layers-component.jsx | 19 +++++++++++++------
5 files changed, 28 insertions(+), 6 deletions(-)
diff --git a/src/constants/layers-slugs.js b/src/constants/layers-slugs.js
index 2a0b9784d..bb777cc67 100644
--- a/src/constants/layers-slugs.js
+++ b/src/constants/layers-slugs.js
@@ -212,3 +212,5 @@ export const REPTILES_LOOKUP = 'reptiles-lookup-table';
// NRC Landing Layers
export const NRC_LANDING_LAYERS_SLUG = 'nrc-landing-layers';
export const EEZ_MARINE_AND_LAND_BORDERS = 'eez-marine-borders';
+
+export const FOOBAR = 'foobar';
diff --git a/src/constants/layers-urls.js b/src/constants/layers-urls.js
index adc324ae7..4efab16eb 100644
--- a/src/constants/layers-urls.js
+++ b/src/constants/layers-urls.js
@@ -122,6 +122,7 @@ import {
MAMMALS_SACA_RICHNESS_TOTAL,
MAMMALS_SACA_RARITY_TOTAL,
BIRDS_SACA_RICHNESS_TOTAL,
+ FOOBAR,
} from 'constants/layers-slugs';
const { REACT_APP_VERCEL_ENV } = process.env;
@@ -156,6 +157,7 @@ const GADM_0_ADMIN_AREAS_FEATURE_LAYER_URL =
const GADM_1_ADMIN_AREAS_FEATURE_LAYER_URL =
'https://utility.arcgis.com/usrsvcs/servers/340d03102060417c8a9f712754708216/rest/services/gadm1_precalculated_aoi_summaries_updated_20240321/FeatureServer';
+export const species = 'Accipiter_castanilius';
export const LAYERS_URLS = {
[GLOBAL_SPI_FEATURE_LAYER]:
'https://services9.arcgis.com/IkktFdUAcY3WrH25/arcgis/rest/services/SPI_Terrestrial_202403/FeatureServer',
@@ -180,6 +182,7 @@ export const LAYERS_URLS = {
'https://services9.arcgis.com/IkktFdUAcY3WrH25/arcgis/rest/services/Educator_Ambassadors/FeatureServer',
[COUNTRIES_LABELS_FEATURE_LAYER]: COUNTRIES_DATA_URL,
[COUNTRIES_DATA_FEATURE_LAYER]: COUNTRIES_DATA_URL,
+ [FOOBAR]: `https://services9.arcgis.com/IkktFdUAcY3WrH25/arcgis/rest/services/${species}_rangemap/FeatureServer`,
[LANDSCAPE_FEATURES_LABELS_LAYER]:
'https://services9.arcgis.com/IkktFdUAcY3WrH25/arcgis/rest/services/LandscapeUniqueRivers_gadm36/FeatureServer',
[CITIES_LABELS_LAYER]:
diff --git a/src/constants/metadata.js b/src/constants/metadata.js
index 781044454..6e5e356be 100644
--- a/src/constants/metadata.js
+++ b/src/constants/metadata.js
@@ -70,6 +70,7 @@ import {
CARBON_LAYER,
MARINE_CARBON_LAYER,
LAND_AND_MARINE_CARBON_LAYER,
+ FOOBAR,
} from 'constants/layers-slugs';
export const SPECIES_PROTECTION_INDEX = 'spi-def';
@@ -158,4 +159,5 @@ export default {
[MARINE_HUMAN_PRESSURES]: MARINE_HUMAN_PRESSURES,
[HALF_EARTH_FUTURE_TILE_LAYER]: HALF_EARTH_FUTURE_METADATA_SLUG,
[SPECIFIC_REGIONS_TILE_LAYER]: SPECIFIC_REGIONS_TILE_LAYER,
+ [FOOBAR]: FOOBAR,
};
diff --git a/src/constants/mol-layers-configs.js b/src/constants/mol-layers-configs.js
index 617310df6..a93875a7b 100644
--- a/src/constants/mol-layers-configs.js
+++ b/src/constants/mol-layers-configs.js
@@ -18,6 +18,7 @@ import {
MARINE_CARBON_LAYER,
PRIORITY_PLACES_POLYGONS,
PROTECTED_AREAS_VECTOR_TILE_LAYER,
+ FOOBAR,
HALF_EARTH_FUTURE_WDPA_LAYER,
HALF_EARTH_FUTURE_TILE_LAYER,
SPECIFIC_REGIONS_TILE_LAYER,
@@ -317,6 +318,13 @@ export const layersConfig = {
url: LAYERS_URLS[FEATURED_PLACES_LAYER],
bbox: null,
},
+ [FOOBAR]: {
+ title: FOOBAR,
+ slug: FOOBAR,
+ type: LAYER_TYPES.FEATURE_LAYER,
+ url: LAYERS_URLS[FOOBAR],
+ bbox: null,
+ },
[PROTECTED_AREAS_VECTOR_TILE_LAYER]: {
title: PROTECTED_AREAS_VECTOR_TILE_LAYER,
slug: PROTECTED_AREAS_VECTOR_TILE_LAYER,
diff --git a/src/containers/sidebars/dashboard-sidebar/data-layers/data-layers-component.jsx b/src/containers/sidebars/dashboard-sidebar/data-layers/data-layers-component.jsx
index eac34fa93..7650f86b0 100644
--- a/src/containers/sidebars/dashboard-sidebar/data-layers/data-layers-component.jsx
+++ b/src/containers/sidebars/dashboard-sidebar/data-layers/data-layers-component.jsx
@@ -4,13 +4,20 @@ import cx from 'classnames';
import Button from 'components/button';
import LayerToggle from 'components/layer-toggle';
-// import SearchInput from 'components/search-input';
import {
PROTECTION_SLUG,
LAND_HUMAN_PRESSURES_SLUG,
BIODIVERSITY_SLUG,
} from 'constants/analyze-areas-constants';
+import {
+ COUNTRIES_LABELS_FEATURE_LAYER,
+ REGIONS_LABELS_LAYER,
+ COUNTRIES_DATA_FEATURE_LAYER,
+ PROTECTED_AREAS_VECTOR_TILE_LAYER,
+ FOOBAR,
+} from 'constants/layers-slugs.js';
+// import SearchInput from 'components/search-input';
import hrTheme from 'styles/themes/hr-theme.module.scss';
@@ -23,23 +30,23 @@ function DataLayerComponent(props) {
const speciesPublicLayers = [
{
name: 'Point Observations',
- value: 'countries_labels_layer',
+ value: COUNTRIES_LABELS_FEATURE_LAYER,
},
{
name: 'Habitat Suitable Range',
- value: 'protected_areas_vector_tile_layer',
+ value: FOOBAR,
},
{
name: 'Local Inventories',
- value: 'regions_labels_layer',
+ value: REGIONS_LABELS_LAYER,
},
{
name: 'Expert Range Maps',
- value: 'countries_data_layer',
+ value: COUNTRIES_DATA_FEATURE_LAYER,
},
{
name: 'Regional Checklists',
- value: 'community_areas_vector_tile_layer',
+ value: PROTECTED_AREAS_VECTOR_TILE_LAYER,
},
];
From cca12c333104ac0d6a68b9fc83fc7acbb35d80cb Mon Sep 17 00:00:00 2001
From: Chris Manciero
Date: Tue, 11 Jun 2024 19:43:41 -0400
Subject: [PATCH 011/350] add layer on click for country and species
---
src/components/map-view/index.js | 14 +++-
src/constants/layers-urls.js | 4 +-
.../biodiversity-indicators-component.jsx | 11 ++-
...biodiversity-indicators-styles.module.scss | 32 ++++++++
.../dashboard-sidebar-component.jsx | 8 +-
.../data-layers/data-layers-component.jsx | 77 ++++++++++++++++---
.../data-layers-styles.module.scss | 38 +++++++--
.../regions-analysis-component.jsx | 16 +++-
.../regions-analysis-styles.module.scss | 1 +
.../dashboard-view-component.jsx | 9 ++-
10 files changed, 179 insertions(+), 31 deletions(-)
diff --git a/src/components/map-view/index.js b/src/components/map-view/index.js
index 2119f607d..e148308c8 100644
--- a/src/components/map-view/index.js
+++ b/src/components/map-view/index.js
@@ -11,9 +11,17 @@ import mapStateToProps from './selectors';
const { REACT_APP_ARGISJS_API_VERSION: API_VERSION } = process.env;
function ViewContainer(props) {
- const { mapId, mapName, onMapLoad, onViewLoad, viewSettings } = props;
+ const {
+ mapId,
+ mapName,
+ onMapLoad,
+ onViewLoad,
+ viewSettings,
+ coordinates,
+ map,
+ setMap,
+ } = props;
- const [map, setMap] = useState(null);
const [view, setView] = useState(null);
const [loadState, setLoadState] = useState('loading');
const [countryLayer, setCountryLayer] = useState(null);
@@ -127,7 +135,7 @@ function ViewContainer(props) {
map,
container: `map-container-${mapName || mapId}`,
zoom: 6,
- center: [-3, 42],
+ center: coordinates,
popup: null,
...viewSettings,
});
diff --git a/src/constants/layers-urls.js b/src/constants/layers-urls.js
index 4efab16eb..83e6f9644 100644
--- a/src/constants/layers-urls.js
+++ b/src/constants/layers-urls.js
@@ -157,7 +157,6 @@ const GADM_0_ADMIN_AREAS_FEATURE_LAYER_URL =
const GADM_1_ADMIN_AREAS_FEATURE_LAYER_URL =
'https://utility.arcgis.com/usrsvcs/servers/340d03102060417c8a9f712754708216/rest/services/gadm1_precalculated_aoi_summaries_updated_20240321/FeatureServer';
-export const species = 'Accipiter_castanilius';
export const LAYERS_URLS = {
[GLOBAL_SPI_FEATURE_LAYER]:
'https://services9.arcgis.com/IkktFdUAcY3WrH25/arcgis/rest/services/SPI_Terrestrial_202403/FeatureServer',
@@ -182,7 +181,8 @@ export const LAYERS_URLS = {
'https://services9.arcgis.com/IkktFdUAcY3WrH25/arcgis/rest/services/Educator_Ambassadors/FeatureServer',
[COUNTRIES_LABELS_FEATURE_LAYER]: COUNTRIES_DATA_URL,
[COUNTRIES_DATA_FEATURE_LAYER]: COUNTRIES_DATA_URL,
- [FOOBAR]: `https://services9.arcgis.com/IkktFdUAcY3WrH25/arcgis/rest/services/${species}_rangemap/FeatureServer`,
+ [FOOBAR]:
+ 'https://services9.arcgis.com/IkktFdUAcY3WrH25/arcgis/rest/services/occurrence_202301_alltaxa_drc_test/FeatureServer/0/query?where=taxa%20=%20%27mammals%27%20AND%20scientificname%20=%20%27Syncerus%20caffer%27',
[LANDSCAPE_FEATURES_LABELS_LAYER]:
'https://services9.arcgis.com/IkktFdUAcY3WrH25/arcgis/rest/services/LandscapeUniqueRivers_gadm36/FeatureServer',
[CITIES_LABELS_LAYER]:
diff --git a/src/containers/sidebars/dashboard-sidebar/biodiversity-indicators/biodiversity-indicators-component.jsx b/src/containers/sidebars/dashboard-sidebar/biodiversity-indicators/biodiversity-indicators-component.jsx
index 409e6fc94..f5c5b6c26 100644
--- a/src/containers/sidebars/dashboard-sidebar/biodiversity-indicators/biodiversity-indicators-component.jsx
+++ b/src/containers/sidebars/dashboard-sidebar/biodiversity-indicators/biodiversity-indicators-component.jsx
@@ -1,10 +1,19 @@
import React from 'react';
+import hrTheme from 'styles/themes/hr-theme.module.scss';
+
import styles from './biodiversity-indicators-styles.module.scss';
function BioDiversityComponent() {
return (
-
+
+ Biodiversity Indicators
+
+
+ *The Species Habitat Score is calculated using the habitat suitable
+ range map and remote sensing layers.
+
+
);
}
diff --git a/src/containers/sidebars/dashboard-sidebar/biodiversity-indicators/biodiversity-indicators-styles.module.scss b/src/containers/sidebars/dashboard-sidebar/biodiversity-indicators/biodiversity-indicators-styles.module.scss
index eaddfa125..bb775f0d3 100644
--- a/src/containers/sidebars/dashboard-sidebar/biodiversity-indicators/biodiversity-indicators-styles.module.scss
+++ b/src/containers/sidebars/dashboard-sidebar/biodiversity-indicators/biodiversity-indicators-styles.module.scss
@@ -9,4 +9,36 @@
padding: 5px 10px;
width: 100%;
color: $white;
+
+ .sectionTitle{
+ font-size: 18px;
+ font-weight: 700;
+ text-transform: uppercase;
+ line-height: 1.5;
+ color: $white;
+ }
+
+ p{
+ font-size: 12px;
+ }
+
+ .choices{
+ display: flex;
+ flex-direction: column;
+ gap: 5px;
+ }
+
+ .search{
+ display: flex;
+ column-gap: 8px;
+ margin-top: 8px;
+
+ .saveButton {
+ color: $dark-text;
+ background-color: $brand-color-main;
+ &:hover {
+ background-color: $brand-color-main-hover;
+ }
+ }
+ }
}
diff --git a/src/containers/sidebars/dashboard-sidebar/dashboard-sidebar-component.jsx b/src/containers/sidebars/dashboard-sidebar/dashboard-sidebar-component.jsx
index 3446b82ae..90a8a89ba 100644
--- a/src/containers/sidebars/dashboard-sidebar/dashboard-sidebar-component.jsx
+++ b/src/containers/sidebars/dashboard-sidebar/dashboard-sidebar-component.jsx
@@ -13,7 +13,7 @@ import RegionsAnalysisComponent from './regions-analysis/regions-analysis-compon
import SpeciesInfoContainer from './species-info';
function DashboardSidebar(props) {
- const { activeLayers } = props;
+ const { activeLayers, map } = props;
const [selectedIndex, setSelectedIndex] = useState(1);
return (
@@ -51,10 +51,10 @@ function DashboardSidebar(props) {
{selectedIndex === 1 && (
-
+
)}
- {selectedIndex === 2 && }
- {selectedIndex === 3 && }
+ {selectedIndex === 2 && }
+ {selectedIndex === 3 && }
);
diff --git a/src/containers/sidebars/dashboard-sidebar/data-layers/data-layers-component.jsx b/src/containers/sidebars/dashboard-sidebar/data-layers/data-layers-component.jsx
index 7650f86b0..3d637394c 100644
--- a/src/containers/sidebars/dashboard-sidebar/data-layers/data-layers-component.jsx
+++ b/src/containers/sidebars/dashboard-sidebar/data-layers/data-layers-component.jsx
@@ -4,6 +4,9 @@ import cx from 'classnames';
import Button from 'components/button';
import LayerToggle from 'components/layer-toggle';
+import SearchLocation from 'components/search-location';
+
+import EsriFeatureService from 'services/esri-feature-service';
import {
PROTECTION_SLUG,
@@ -17,7 +20,7 @@ import {
PROTECTED_AREAS_VECTOR_TILE_LAYER,
FOOBAR,
} from 'constants/layers-slugs.js';
-// import SearchInput from 'components/search-input';
+import { SEARCH_TYPES } from 'constants/search-location-constants';
import hrTheme from 'styles/themes/hr-theme.module.scss';
@@ -26,7 +29,14 @@ import { ReactComponent as ArrowIcon } from 'icons/arrow_right.svg';
import styles from './data-layers-styles.module.scss';
function DataLayerComponent(props) {
- const { map, activeLayers, handleLayerToggle, showProgress } = props;
+ const {
+ map,
+ activeLayers,
+ handleLayerToggle,
+ showProgress,
+ view,
+ selectedOption,
+ } = props;
const speciesPublicLayers = [
{
name: 'Point Observations',
@@ -74,16 +84,49 @@ function DataLayerComponent(props) {
const isOpened = true;
+ const showLayer = () => {
+ const taxa = 'mammals';
+ const scientificname = 'Syncerus caffer';
+
+ const url =
+ 'https://services9.arcgis.com/IkktFdUAcY3WrH25/arcgis/rest/services/occurrence_202301_alltaxa_drc_test/FeatureServer/0';
+
+ EsriFeatureService.getFeatures({
+ url,
+ whereClause: `taxa = '${taxa}' AND scientificname = '${scientificname}'`,
+ returnGeometry: true,
+ }).then((features) => {
+ const { layer } = features[0];
+ map.add(layer);
+ });
+ };
+
return (
-
- {/* */}
+ Data Layers
- {}}>
+
+
+
+
+
+ {}}
+ >
Distribute Data: Public
+
+ Show Layer
+
+
{speciesPublicLayers.map((layer) => (
))}
- {}}>
+ {}}
+ >
))}
- {}}>
+ {}}
+ >
Regions Analysis
@@ -37,7 +41,15 @@ function RegionsAnalysisComponent() {
/>
-
+
-
+
Date: Wed, 12 Jun 2024 09:31:42 -0400
Subject: [PATCH 012/350] center on country by url
---
src/components/map-view/index.js | 10 +--
.../dashboard-sidebar-component.jsx | 8 +-
.../data-layers/data-layers-component.jsx | 19 ++---
.../dashboard-view-component.jsx | 46 +++++++----
.../dashboard-view-selectors.js | 40 ---------
.../views/dashboard-view/dashboard-view.js | 34 +-------
src/pages/dashboard/dashboard-component.jsx | 22 -----
src/pages/dashboard/dashboard-selectors.js | 81 +------------------
src/pages/dashboard/index.js | 1 -
9 files changed, 57 insertions(+), 204 deletions(-)
delete mode 100644 src/containers/views/dashboard-view/dashboard-view-selectors.js
diff --git a/src/components/map-view/index.js b/src/components/map-view/index.js
index e148308c8..7226160fd 100644
--- a/src/components/map-view/index.js
+++ b/src/components/map-view/index.js
@@ -12,17 +12,18 @@ const { REACT_APP_ARGISJS_API_VERSION: API_VERSION } = process.env;
function ViewContainer(props) {
const {
- mapId,
- mapName,
onMapLoad,
onViewLoad,
+ mapName,
+ mapId,
viewSettings,
- coordinates,
map,
setMap,
+ view,
+ setView,
} = props;
- const [view, setView] = useState(null);
+ // const [view, setView] = useState(null);
const [loadState, setLoadState] = useState('loading');
const [countryLayer, setCountryLayer] = useState(null);
const [graphicsLayer, setGraphicsLayer] = useState(null);
@@ -135,7 +136,6 @@ function ViewContainer(props) {
map,
container: `map-container-${mapName || mapId}`,
zoom: 6,
- center: coordinates,
popup: null,
...viewSettings,
});
diff --git a/src/containers/sidebars/dashboard-sidebar/dashboard-sidebar-component.jsx b/src/containers/sidebars/dashboard-sidebar/dashboard-sidebar-component.jsx
index 90a8a89ba..a2ad62aa6 100644
--- a/src/containers/sidebars/dashboard-sidebar/dashboard-sidebar-component.jsx
+++ b/src/containers/sidebars/dashboard-sidebar/dashboard-sidebar-component.jsx
@@ -13,7 +13,7 @@ import RegionsAnalysisComponent from './regions-analysis/regions-analysis-compon
import SpeciesInfoContainer from './species-info';
function DashboardSidebar(props) {
- const { activeLayers, map } = props;
+ const { activeLayers, map, view } = props;
const [selectedIndex, setSelectedIndex] = useState(1);
return (
@@ -51,7 +51,11 @@ function DashboardSidebar(props) {
{selectedIndex === 1 && (
-
+
)}
{selectedIndex === 2 && }
{selectedIndex === 3 && }
diff --git a/src/containers/sidebars/dashboard-sidebar/data-layers/data-layers-component.jsx b/src/containers/sidebars/dashboard-sidebar/data-layers/data-layers-component.jsx
index 3d637394c..d8e609a28 100644
--- a/src/containers/sidebars/dashboard-sidebar/data-layers/data-layers-component.jsx
+++ b/src/containers/sidebars/dashboard-sidebar/data-layers/data-layers-component.jsx
@@ -13,13 +13,7 @@ import {
LAND_HUMAN_PRESSURES_SLUG,
BIODIVERSITY_SLUG,
} from 'constants/analyze-areas-constants';
-import {
- COUNTRIES_LABELS_FEATURE_LAYER,
- REGIONS_LABELS_LAYER,
- COUNTRIES_DATA_FEATURE_LAYER,
- PROTECTED_AREAS_VECTOR_TILE_LAYER,
- FOOBAR,
-} from 'constants/layers-slugs.js';
+import { PROTECTED_AREAS_VECTOR_TILE_LAYER } from 'constants/layers-slugs.js';
import { SEARCH_TYPES } from 'constants/search-location-constants';
import hrTheme from 'styles/themes/hr-theme.module.scss';
@@ -40,19 +34,19 @@ function DataLayerComponent(props) {
const speciesPublicLayers = [
{
name: 'Point Observations',
- value: COUNTRIES_LABELS_FEATURE_LAYER,
+ value: 'PointObservations1',
},
{
name: 'Habitat Suitable Range',
- value: FOOBAR,
+ value: 'PointObservations2',
},
{
name: 'Local Inventories',
- value: REGIONS_LABELS_LAYER,
+ value: 'PointObservations3',
},
{
name: 'Expert Range Maps',
- value: COUNTRIES_DATA_FEATURE_LAYER,
+ value: 'PointObservations4',
},
{
name: 'Regional Checklists',
@@ -96,8 +90,9 @@ function DataLayerComponent(props) {
whereClause: `taxa = '${taxa}' AND scientificname = '${scientificname}'`,
returnGeometry: true,
}).then((features) => {
- const { layer } = features[0];
+ const { layer, geometry } = features[0];
map.add(layer);
+ view.center = [geometry.longitude, geometry.latitude];
});
};
diff --git a/src/containers/views/dashboard-view/dashboard-view-component.jsx b/src/containers/views/dashboard-view/dashboard-view-component.jsx
index eeedfa895..0d8cfcfc8 100644
--- a/src/containers/views/dashboard-view/dashboard-view-component.jsx
+++ b/src/containers/views/dashboard-view/dashboard-view-component.jsx
@@ -1,4 +1,4 @@
-import React, { useState } from 'react';
+import React, { useEffect, useState } from 'react';
import loadable from '@loadable/component';
@@ -7,15 +7,18 @@ import RegionsLabelsLayer from 'containers/layers/regions-labels-layer';
import ArcgisLayerManager from 'containers/managers/arcgis-layer-manager';
import SideMenu from 'containers/menus/sidemenu';
+import EsriFeatureService from 'services/esri-feature-service';
+
+import { COUNTRIES_DATA_SERVICE_URL } from 'constants/layers-urls';
+
import MapView from '../../../components/map-view';
import DashboardSidebar from '../../sidebars/dashboard-sidebar/dashboard-sidebar-component';
const LabelsLayer = loadable(() => import('containers/layers/labels-layer'));
-const { REACT_APP_ARGISJS_API_VERSION: API_VERSION } = process.env;
function DashboardViewComponent(props) {
const {
- updatedActiveLayers,
+ activeLayers,
onMapLoad,
sceneMode,
viewSettings,
@@ -26,40 +29,53 @@ function DashboardViewComponent(props) {
} = props;
const [map, setMap] = useState(null);
+ const [view, setView] = useState(null);
+
+ useEffect(() => {
+ EsriFeatureService.getFeatures({
+ url: COUNTRIES_DATA_SERVICE_URL,
+ whereClause: `GID_0 = '${countryISO}'`,
+ returnGeometry: true,
+ }).then(
+ (features) => {
+ const { geometry } = features[0];
+ if (geometry) {
+ view.center = [geometry.longitude, geometry.latitude];
+ }
+ },
+ [view, countryISO]
+ );
+ });
return (
-
+
-
+
-
+
-
+
);
}
diff --git a/src/containers/views/dashboard-view/dashboard-view-selectors.js b/src/containers/views/dashboard-view/dashboard-view-selectors.js
deleted file mode 100644
index bae44a568..000000000
--- a/src/containers/views/dashboard-view/dashboard-view-selectors.js
+++ /dev/null
@@ -1,40 +0,0 @@
-import { createSelector, createStructuredSelector } from 'reselect';
-
-import { selectAoiId } from 'selectors/aoi-selectors';
-import { selectUiUrlState } from 'selectors/location-selectors';
-import { selectTooltipData } from 'selectors/map-tooltip-selectors';
-import { selectSceneView } from 'selectors/scene-selectors';
-import { getSidebarTabActive } from 'selectors/ui-selectors';
-
-import {
- getSelectedAnalysisLayer,
- getSelectedAnalysisTab,
-} from 'pages/data-globe/data-globe-selectors';
-
-import aoiSceneConfig from 'containers/scenes/aoi-scene/config';
-
-const selectTemporaryPosition = ({ location }) =>
- (location.query && location.query.centerOn) || null;
-
-const getUiSettings = createSelector(selectUiUrlState, (uiUrlState) => {
- return {
- ...aoiSceneConfig.ui,
- ...uiUrlState,
- };
-});
-
-const getActiveCategoryLayers = createSelector(
- getUiSettings,
- (uiSettings) => uiSettings.activeCategoryLayers
-);
-
-export default createStructuredSelector({
- aoiId: selectAoiId,
- activeCategoryLayers: getActiveCategoryLayers,
- mapTooltipData: selectTooltipData,
- sidebarTabActive: getSidebarTabActive,
- selectedAnalysisLayer: getSelectedAnalysisLayer,
- selectedAnalysisTab: getSelectedAnalysisTab,
- centerOn: selectTemporaryPosition,
- view: selectSceneView,
-});
diff --git a/src/containers/views/dashboard-view/dashboard-view.js b/src/containers/views/dashboard-view/dashboard-view.js
index 833cf5ef8..ab76fa052 100644
--- a/src/containers/views/dashboard-view/dashboard-view.js
+++ b/src/containers/views/dashboard-view/dashboard-view.js
@@ -1,43 +1,17 @@
-import React, { useEffect, useState } from 'react';
-import { connect } from 'react-redux';
-
-import unionBy from 'lodash/unionBy';
-
-import { ADMIN_AREAS_FEATURE_LAYER } from 'constants/layers-slugs';
+import React from 'react';
import Component from './dashboard-view-component';
-import mapStateToProps from './dashboard-view-selectors';
function DashboardView(props) {
- const { activeLayers, changeUI, activeCategoryLayers, viewSettings } = props;
-
- const activeLayersWithoutAdmin = activeLayers.filter(
- (ual) => ual.title !== ADMIN_AREAS_FEATURE_LAYER
- );
-
- const [updatedActiveLayers, setUpdatedActiveLayers] = useState(
- activeLayersWithoutAdmin
- );
-
- useEffect(() => {
- // Add temporary activeCategoryLayers to activeLayers at render and reset the param
- if (activeCategoryLayers) {
- setUpdatedActiveLayers(
- unionBy(activeCategoryLayers, activeLayers, 'title')
- );
- changeUI({ activeCategoryLayers: undefined });
- } else {
- setUpdatedActiveLayers(activeLayers);
- }
- }, [activeLayers]);
+ const { activeLayers, viewSettings } = props;
return (
);
}
-export default connect(mapStateToProps, null)(DashboardView);
+export default DashboardView;
diff --git a/src/pages/dashboard/dashboard-component.jsx b/src/pages/dashboard/dashboard-component.jsx
index 1e68b3211..27328c365 100644
--- a/src/pages/dashboard/dashboard-component.jsx
+++ b/src/pages/dashboard/dashboard-component.jsx
@@ -10,48 +10,26 @@ import DashboardView from '../../containers/views/dashboard-view/dashboard-view'
function DashboardComponent(props) {
const {
- sceneMode,
countryISO,
countryName,
- openedModal,
activeLayers,
handleMapLoad,
viewSettings,
isSidebarOpen,
- activeCategory,
selectedSpecies,
- isFullscreenActive,
- handleGlobeUpdating,
- countedActiveLayers,
isBiodiversityActive,
- countryTooltipDisplayFor,
- onboardingType,
- onboardingStep,
- waitingInteraction,
- aoiId,
} = props;
return (
<>
handleMapLoad(map, activeLayers)}
{...props}
/>
diff --git a/src/pages/dashboard/dashboard-selectors.js b/src/pages/dashboard/dashboard-selectors.js
index 5a96498e6..871bae428 100644
--- a/src/pages/dashboard/dashboard-selectors.js
+++ b/src/pages/dashboard/dashboard-selectors.js
@@ -10,12 +10,12 @@ import {
import dashboardViewConfig from '../../containers/views/dashboard-view/dashboard-view-config';
+const selectCountryIso = ({ location }) => location.payload.iso.toUpperCase();
+
const selectBiodiversityData = ({ biodiversityData }) =>
biodiversityData && (biodiversityData.data || null);
const selectMetadataData = ({ metadata }) =>
metadata && (!isEmpty(metadata.data) || null);
-const selectCountryExtent = ({ countryExtent }) =>
- countryExtent ? countryExtent.data : null;
const getViewSettings = createSelector(selectGlobeUrlState, (globeUrlState) => {
return {
@@ -35,21 +35,13 @@ export const getActiveLayers = createSelector(
getViewSettings,
(viewSettings) => viewSettings.activeLayers
);
-export const getCountryTooltipDisplayFor = createSelector(
- getViewSettings,
- (viewSettings) => viewSettings.countryTooltipDisplayFor
-);
-const getGlobeUpdating = createSelector(
- getViewSettings,
- (viewSettings) => viewSettings.isGlobeUpdating
-);
const getSelectedSpecies = createSelector(
getViewSettings,
(viewSettings) => viewSettings.selectedSpecies
);
export const getCountryISO = createSelector(
- getViewSettings,
- (viewSettings) => viewSettings.countryISO
+ selectCountryIso,
+ (countryISO) => countryISO
);
const getCountryName = createSelector(
getViewSettings,
@@ -59,58 +51,6 @@ const getSidebarVisibility = createSelector(
getUiSettings,
(uiSettings) => uiSettings.isSidebarOpen
);
-const getFullscreenActive = createSelector(
- getUiSettings,
- (uiSettings) => uiSettings.isFullscreenActive
-);
-const getActiveCategory = createSelector(
- getUiSettings,
- (uiSettings) => uiSettings.activeCategory
-);
-const getHalfEarthModalOpen = createSelector(
- getUiSettings,
- (uiSettings) => uiSettings.openedModal
-);
-const getSceneMode = createSelector(
- getUiSettings,
- (uiSettings) => uiSettings.sceneMode
-);
-const getCountryChallengesSelectedKey = createSelector(
- getUiSettings,
- (uiSettings) => uiSettings.countryChallengesSelectedKey
-);
-export const getLocalSceneFilters = createSelector(
- getUiSettings,
- (uiSettings) => uiSettings.localSceneFilters
-);
-export const getCountryChallengesSelectedFilter = createSelector(
- getUiSettings,
- (uiSettings) => uiSettings.countryChallengesSelectedFilter
-);
-export const getOnboardingType = createSelector(
- getUiSettings,
- (uiSettings) => uiSettings.onboardingType
-);
-export const getOnboardingStep = createSelector(
- getUiSettings,
- (uiSettings) => uiSettings.onboardingStep
-);
-export const getOnWaitingInteraction = createSelector(
- getUiSettings,
- (uiSettings) => uiSettings.waitingInteraction
-);
-export const getAOIId = createSelector(
- getUiSettings,
- (uiSettings) => uiSettings.aoiId
-);
-export const getSelectedAnalysisLayer = createSelector(
- getUiSettings,
- (uiSettings) => uiSettings.selectedAnalysisLayer
-);
-export const getSelectedAnalysisTab = createSelector(
- getUiSettings,
- (uiSettings) => uiSettings.selectedAnalysisTab || 'click'
-);
export default createStructuredSelector({
viewSettings: getViewSettings,
@@ -119,20 +59,7 @@ export default createStructuredSelector({
countryISO: getCountryISO,
countryName: getCountryName,
isSidebarOpen: getSidebarVisibility,
- isGlobeUpdating: getGlobeUpdating,
- isFullscreenActive: getFullscreenActive,
- activeCategory: getActiveCategory,
speciesCategories: selectBiodiversityData,
hasMetadata: selectMetadataData,
selectedSpecies: getSelectedSpecies,
- openedModal: getHalfEarthModalOpen,
- sceneMode: getSceneMode,
- countryTooltipDisplayFor: getCountryTooltipDisplayFor,
- countryChallengesSelectedKey: getCountryChallengesSelectedKey,
- countryExtent: selectCountryExtent,
- localSceneFilters: getLocalSceneFilters,
- onboardingType: getOnboardingType,
- onboardingStep: getOnboardingStep,
- waitingInteraction: getOnWaitingInteraction,
- aoiId: getAOIId,
});
diff --git a/src/pages/dashboard/index.js b/src/pages/dashboard/index.js
index 8caeb623c..d0811a98e 100644
--- a/src/pages/dashboard/index.js
+++ b/src/pages/dashboard/index.js
@@ -13,7 +13,6 @@ import mapStateToProps from './dashboard-selectors';
function DashboardContainer(props) {
const { viewSettings } = props;
const handleMapLoad = (map, activeLayers) => {
- console.log('map view loaded', map);
setBasemap({
map,
layersArray: viewSettings.basemap.layersArray,
From 7c3ff3c32cb46f7958363261939ce0bdb345639f Mon Sep 17 00:00:00 2001
From: Chris Manciero
Date: Wed, 12 Jun 2024 11:22:54 -0400
Subject: [PATCH 013/350] highlight navigate to ISO
---
src/components/map-view/index.js | 19 ++++++++-------
.../dashboard-view-component.jsx | 24 +++++++++----------
2 files changed, 21 insertions(+), 22 deletions(-)
diff --git a/src/components/map-view/index.js b/src/components/map-view/index.js
index 7226160fd..08b34deaf 100644
--- a/src/components/map-view/index.js
+++ b/src/components/map-view/index.js
@@ -21,6 +21,7 @@ function ViewContainer(props) {
setMap,
view,
setView,
+ geo,
} = props;
// const [view, setView] = useState(null);
@@ -140,15 +141,6 @@ function ViewContainer(props) {
...viewSettings,
});
- flatView.when(async () => {
- const query = {
- geometry: flatView.center,
- returnGeometry: true,
- outFields: ['*'],
- };
- await highlightCountry(query, flatView.center, flatView);
- });
-
flatView.on('click', async (event) => {
const query = {
geometry: flatView.toMap(event),
@@ -175,6 +167,15 @@ function ViewContainer(props) {
}
}, [map, view]);
+ useEffect(() => {
+ const query = {
+ geometry: geo,
+ returnGeometry: true,
+ outFields: ['*'],
+ };
+ highlightCountry(query, query.geometry, view);
+ }, [view, geo]);
+
return ;
}
diff --git a/src/containers/views/dashboard-view/dashboard-view-component.jsx b/src/containers/views/dashboard-view/dashboard-view-component.jsx
index 0d8cfcfc8..93d401467 100644
--- a/src/containers/views/dashboard-view/dashboard-view-component.jsx
+++ b/src/containers/views/dashboard-view/dashboard-view-component.jsx
@@ -4,7 +4,6 @@ import loadable from '@loadable/component';
import CountryLabelsLayer from 'containers/layers/country-labels-layer';
import RegionsLabelsLayer from 'containers/layers/regions-labels-layer';
-import ArcgisLayerManager from 'containers/managers/arcgis-layer-manager';
import SideMenu from 'containers/menus/sidemenu';
import EsriFeatureService from 'services/esri-feature-service';
@@ -30,22 +29,22 @@ function DashboardViewComponent(props) {
const [map, setMap] = useState(null);
const [view, setView] = useState(null);
+ const [geo, setGeo] = useState(null);
useEffect(() => {
EsriFeatureService.getFeatures({
url: COUNTRIES_DATA_SERVICE_URL,
whereClause: `GID_0 = '${countryISO}'`,
returnGeometry: true,
- }).then(
- (features) => {
- const { geometry } = features[0];
- if (geometry) {
- view.center = [geometry.longitude, geometry.latitude];
- }
- },
- [view, countryISO]
- );
- });
+ }).then((features) => {
+ const { geometry } = features[0];
+
+ if (geometry && view) {
+ view.center = [geometry.longitude, geometry.latitude];
+ setGeo(geometry);
+ }
+ });
+ }, [view, countryISO]);
return (
-
-
Date: Wed, 12 Jun 2024 11:45:02 -0400
Subject: [PATCH 014/350] display points on map
---
.../dashboard-sidebar/data-layers/data-layers-component.jsx | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/src/containers/sidebars/dashboard-sidebar/data-layers/data-layers-component.jsx b/src/containers/sidebars/dashboard-sidebar/data-layers/data-layers-component.jsx
index d8e609a28..0b4cac660 100644
--- a/src/containers/sidebars/dashboard-sidebar/data-layers/data-layers-component.jsx
+++ b/src/containers/sidebars/dashboard-sidebar/data-layers/data-layers-component.jsx
@@ -90,9 +90,8 @@ function DataLayerComponent(props) {
whereClause: `taxa = '${taxa}' AND scientificname = '${scientificname}'`,
returnGeometry: true,
}).then((features) => {
- const { layer, geometry } = features[0];
+ const { layer } = features[0];
map.add(layer);
- view.center = [geometry.longitude, geometry.latitude];
});
};
From 29c75b623346d55fb0fe749913abbca4728a7f53 Mon Sep 17 00:00:00 2001
From: Chris Manciero
Date: Mon, 17 Jun 2024 10:54:23 -0400
Subject: [PATCH 015/350] update mapviews
---
src/components/map-view/index.js | 43 ++++++++-----------
src/constants/layers-slugs.js | 2 -
src/constants/layers-urls.js | 3 --
src/constants/metadata.js | 2 -
src/constants/mol-layers-configs.js | 8 ----
.../data-layers/data-layers-component.jsx | 30 +++++++++++--
.../data-layers-styles.module.scss | 2 +-
.../dashboard-view-component.jsx | 6 +++
8 files changed, 52 insertions(+), 44 deletions(-)
diff --git a/src/components/map-view/index.js b/src/components/map-view/index.js
index 08b34deaf..640f58857 100644
--- a/src/components/map-view/index.js
+++ b/src/components/map-view/index.js
@@ -8,15 +8,13 @@ import { SATELLITE_BASEMAP_LAYER } from 'constants/layers-slugs';
import Component from './component';
import mapStateToProps from './selectors';
-const { REACT_APP_ARGISJS_API_VERSION: API_VERSION } = process.env;
-
function ViewContainer(props) {
const {
onMapLoad,
- onViewLoad,
mapName,
mapId,
viewSettings,
+ loaderOptions,
map,
setMap,
view,
@@ -24,16 +22,11 @@ function ViewContainer(props) {
geo,
} = props;
- // const [view, setView] = useState(null);
const [loadState, setLoadState] = useState('loading');
const [countryLayer, setCountryLayer] = useState(null);
const [graphicsLayer, setGraphicsLayer] = useState(null);
const [groupLayer, setGroupLayer] = useState(null);
- const loaderOptions = {
- url: `https://js.arcgis.com/${API_VERSION}`,
- };
-
const highlightCountry = async (query, zoomGeometry, flatView) => {
// country symbol - when user clicks on a country
// we will query the country from the countries featurelayer
@@ -120,6 +113,7 @@ function ViewContainer(props) {
});
setMap(flatMap);
+
if (onMapLoad) {
onMapLoad(flatMap);
}
@@ -141,14 +135,14 @@ function ViewContainer(props) {
...viewSettings,
});
- flatView.on('click', async (event) => {
- const query = {
- geometry: flatView.toMap(event),
- returnGeometry: true,
- outFields: ['*'],
- };
- await highlightCountry(query, query.geometry, flatView);
- });
+ // flatView.on('click', async (event) => {
+ // // const query = {
+ // // geometry: flatView.toMap(event),
+ // // returnGeometry: true,
+ // // outFields: ['*'],
+ // // };
+ // // await highlightCountry(query, query.geometry, flatView);
+ // });
setView(flatView);
})
@@ -161,19 +155,18 @@ function ViewContainer(props) {
useEffect(() => {
if (map && view) {
setLoadState('loaded');
- if (onViewLoad) {
- onViewLoad(map, view);
- }
}
}, [map, view]);
useEffect(() => {
- const query = {
- geometry: geo,
- returnGeometry: true,
- outFields: ['*'],
- };
- highlightCountry(query, query.geometry, view);
+ if (view && geo) {
+ const query = {
+ geometry: geo,
+ returnGeometry: true,
+ outFields: ['*'],
+ };
+ highlightCountry(query, query.geometry, view);
+ }
}, [view, geo]);
return ;
diff --git a/src/constants/layers-slugs.js b/src/constants/layers-slugs.js
index bb777cc67..2a0b9784d 100644
--- a/src/constants/layers-slugs.js
+++ b/src/constants/layers-slugs.js
@@ -212,5 +212,3 @@ export const REPTILES_LOOKUP = 'reptiles-lookup-table';
// NRC Landing Layers
export const NRC_LANDING_LAYERS_SLUG = 'nrc-landing-layers';
export const EEZ_MARINE_AND_LAND_BORDERS = 'eez-marine-borders';
-
-export const FOOBAR = 'foobar';
diff --git a/src/constants/layers-urls.js b/src/constants/layers-urls.js
index 83e6f9644..adc324ae7 100644
--- a/src/constants/layers-urls.js
+++ b/src/constants/layers-urls.js
@@ -122,7 +122,6 @@ import {
MAMMALS_SACA_RICHNESS_TOTAL,
MAMMALS_SACA_RARITY_TOTAL,
BIRDS_SACA_RICHNESS_TOTAL,
- FOOBAR,
} from 'constants/layers-slugs';
const { REACT_APP_VERCEL_ENV } = process.env;
@@ -181,8 +180,6 @@ export const LAYERS_URLS = {
'https://services9.arcgis.com/IkktFdUAcY3WrH25/arcgis/rest/services/Educator_Ambassadors/FeatureServer',
[COUNTRIES_LABELS_FEATURE_LAYER]: COUNTRIES_DATA_URL,
[COUNTRIES_DATA_FEATURE_LAYER]: COUNTRIES_DATA_URL,
- [FOOBAR]:
- 'https://services9.arcgis.com/IkktFdUAcY3WrH25/arcgis/rest/services/occurrence_202301_alltaxa_drc_test/FeatureServer/0/query?where=taxa%20=%20%27mammals%27%20AND%20scientificname%20=%20%27Syncerus%20caffer%27',
[LANDSCAPE_FEATURES_LABELS_LAYER]:
'https://services9.arcgis.com/IkktFdUAcY3WrH25/arcgis/rest/services/LandscapeUniqueRivers_gadm36/FeatureServer',
[CITIES_LABELS_LAYER]:
diff --git a/src/constants/metadata.js b/src/constants/metadata.js
index 6e5e356be..781044454 100644
--- a/src/constants/metadata.js
+++ b/src/constants/metadata.js
@@ -70,7 +70,6 @@ import {
CARBON_LAYER,
MARINE_CARBON_LAYER,
LAND_AND_MARINE_CARBON_LAYER,
- FOOBAR,
} from 'constants/layers-slugs';
export const SPECIES_PROTECTION_INDEX = 'spi-def';
@@ -159,5 +158,4 @@ export default {
[MARINE_HUMAN_PRESSURES]: MARINE_HUMAN_PRESSURES,
[HALF_EARTH_FUTURE_TILE_LAYER]: HALF_EARTH_FUTURE_METADATA_SLUG,
[SPECIFIC_REGIONS_TILE_LAYER]: SPECIFIC_REGIONS_TILE_LAYER,
- [FOOBAR]: FOOBAR,
};
diff --git a/src/constants/mol-layers-configs.js b/src/constants/mol-layers-configs.js
index a93875a7b..617310df6 100644
--- a/src/constants/mol-layers-configs.js
+++ b/src/constants/mol-layers-configs.js
@@ -18,7 +18,6 @@ import {
MARINE_CARBON_LAYER,
PRIORITY_PLACES_POLYGONS,
PROTECTED_AREAS_VECTOR_TILE_LAYER,
- FOOBAR,
HALF_EARTH_FUTURE_WDPA_LAYER,
HALF_EARTH_FUTURE_TILE_LAYER,
SPECIFIC_REGIONS_TILE_LAYER,
@@ -318,13 +317,6 @@ export const layersConfig = {
url: LAYERS_URLS[FEATURED_PLACES_LAYER],
bbox: null,
},
- [FOOBAR]: {
- title: FOOBAR,
- slug: FOOBAR,
- type: LAYER_TYPES.FEATURE_LAYER,
- url: LAYERS_URLS[FOOBAR],
- bbox: null,
- },
[PROTECTED_AREAS_VECTOR_TILE_LAYER]: {
title: PROTECTED_AREAS_VECTOR_TILE_LAYER,
slug: PROTECTED_AREAS_VECTOR_TILE_LAYER,
diff --git a/src/containers/sidebars/dashboard-sidebar/data-layers/data-layers-component.jsx b/src/containers/sidebars/dashboard-sidebar/data-layers/data-layers-component.jsx
index 0b4cac660..f53b8bdea 100644
--- a/src/containers/sidebars/dashboard-sidebar/data-layers/data-layers-component.jsx
+++ b/src/containers/sidebars/dashboard-sidebar/data-layers/data-layers-component.jsx
@@ -16,10 +16,13 @@ import {
import { PROTECTED_AREAS_VECTOR_TILE_LAYER } from 'constants/layers-slugs.js';
import { SEARCH_TYPES } from 'constants/search-location-constants';
+// import theme from 'styles/themes/checkboxes-theme.module.scss';
import hrTheme from 'styles/themes/hr-theme.module.scss';
import { ReactComponent as ArrowIcon } from 'icons/arrow_right.svg';
+// import CheckboxType from '../../../../components/layer-toggle/checkbox-type';
+
import styles from './data-layers-styles.module.scss';
function DataLayerComponent(props) {
@@ -95,6 +98,8 @@ function DataLayerComponent(props) {
});
};
+ // const [isChecked, setIsChecked] = useState(false);
+
return (
Data Layers
@@ -133,6 +138,26 @@ function DataLayerComponent(props) {
Show Layer
+ {/* {
+ setIsChecked(!isChecked);
+ }}
+ /> */}
+
+ {/* */}
+
{speciesPublicLayers.map((layer) => (
))}
@@ -169,7 +193,7 @@ function DataLayerComponent(props) {
showProgress={showProgress}
activeLayers={activeLayers}
themeCategorySlug={LAND_HUMAN_PRESSURES_SLUG}
- onChange={handleLayerToggle}
+ onChange={showLayer}
/>
))}
diff --git a/src/containers/sidebars/dashboard-sidebar/data-layers/data-layers-styles.module.scss b/src/containers/sidebars/dashboard-sidebar/data-layers/data-layers-styles.module.scss
index d8e481ddc..72fe5aa2f 100644
--- a/src/containers/sidebars/dashboard-sidebar/data-layers/data-layers-styles.module.scss
+++ b/src/containers/sidebars/dashboard-sidebar/data-layers/data-layers-styles.module.scss
@@ -76,6 +76,6 @@
fill: inherit;
}
}
+ }
}
-}
diff --git a/src/containers/views/dashboard-view/dashboard-view-component.jsx b/src/containers/views/dashboard-view/dashboard-view-component.jsx
index 93d401467..5627d5cb6 100644
--- a/src/containers/views/dashboard-view/dashboard-view-component.jsx
+++ b/src/containers/views/dashboard-view/dashboard-view-component.jsx
@@ -13,6 +13,8 @@ import { COUNTRIES_DATA_SERVICE_URL } from 'constants/layers-urls';
import MapView from '../../../components/map-view';
import DashboardSidebar from '../../sidebars/dashboard-sidebar/dashboard-sidebar-component';
+const { REACT_APP_ARGISJS_API_VERSION: API_VERSION } = process.env;
+
const LabelsLayer = loadable(() => import('containers/layers/labels-layer'));
function DashboardViewComponent(props) {
@@ -56,6 +58,9 @@ function DashboardViewComponent(props) {
view={view}
setView={setView}
geo={geo}
+ loaderOptions={{
+ url: `https://js.arcgis.com/${API_VERSION}`,
+ }}
>
@@ -65,6 +70,7 @@ function DashboardViewComponent(props) {
countryName={countryName}
activeLayers={activeLayers}
/>
+
Date: Tue, 18 Jun 2024 14:56:36 -0400
Subject: [PATCH 016/350] update layer toggle controls
---
.../dashboard-sidebar-component.jsx | 3 +
.../data-layers/data-layers-component.jsx | 144 +++++++++---------
src/pages/dashboard/dashboard-selectors.js | 2 -
src/styles/settings.scss | 6 +
.../themes/checkboxes-theme.module.scss | 39 +++++
5 files changed, 120 insertions(+), 74 deletions(-)
diff --git a/src/containers/sidebars/dashboard-sidebar/dashboard-sidebar-component.jsx b/src/containers/sidebars/dashboard-sidebar/dashboard-sidebar-component.jsx
index a2ad62aa6..260ea6471 100644
--- a/src/containers/sidebars/dashboard-sidebar/dashboard-sidebar-component.jsx
+++ b/src/containers/sidebars/dashboard-sidebar/dashboard-sidebar-component.jsx
@@ -24,6 +24,7 @@ function DashboardSidebar(props) {
{
+ const updateOption = (layerName, showHide) => {
+ const visibleLayers = speciesLayers.map((l) => {
+ if (l.value === layerName) {
+ return { ...l, isChecked: showHide };
+ }
+ return l;
+ });
+ setSpeciesLayers(visibleLayers);
+ };
+
+ const displayLayer = (event) => {
+ const layerName = event.value;
const taxa = 'mammals';
const scientificname = 'Syncerus caffer';
const url =
'https://services9.arcgis.com/IkktFdUAcY3WrH25/arcgis/rest/services/occurrence_202301_alltaxa_drc_test/FeatureServer/0';
- EsriFeatureService.getFeatures({
- url,
- whereClause: `taxa = '${taxa}' AND scientificname = '${scientificname}'`,
- returnGeometry: true,
- }).then((features) => {
- const { layer } = features[0];
- map.add(layer);
- });
- };
+ const layerToShow = speciesLayers.find((l) => l.value === layerName);
- // const [isChecked, setIsChecked] = useState(false);
+ if (!layerToShow.isChecked) {
+ EsriFeatureService.getFeatures({
+ url,
+ whereClause: `taxa = '${taxa}' AND scientificname = '${scientificname}'`,
+ returnGeometry: true,
+ }).then((features) => {
+ const { layer } = features[0];
+ setDataLayers({ ...dataLayers, [layerName]: layer });
+
+ updateOption(layerName, true);
+
+ map.add(layer);
+ });
+ } else {
+ const layer = dataLayers[layerName];
+ // get remaining layers from object
+ const { [layerName]: name, ...rest } = dataLayers;
+ // set the update the dataLayers object
+ setDataLayers(rest);
+
+ updateOption(layerName, false);
+
+ map.remove(layer);
+ }
+ };
return (
@@ -133,41 +157,17 @@ function DataLayerComponent(props) {
/>
Distribute Data: Public
-
-
- Show Layer
-
-
- {/* {
- setIsChecked(!isChecked);
- }}
- /> */}
-
- {/* */}
-
- {speciesPublicLayers.map((layer) => (
+ {speciesLayers.map((layer) => (
))}
@@ -190,10 +190,10 @@ function DataLayerComponent(props) {
type="checkbox"
variant="light"
key={layer.value}
- showProgress={showProgress}
+ isChecked={layer.isChecked}
activeLayers={activeLayers}
- themeCategorySlug={LAND_HUMAN_PRESSURES_SLUG}
- onChange={showLayer}
+ onChange={displayLayer}
+ themeCategorySlug={layer.value}
/>
))}
@@ -216,10 +216,10 @@ function DataLayerComponent(props) {
type="checkbox"
variant="light"
key={layer.value}
- showProgress={showProgress}
+ isChecked={layer.isChecked}
activeLayers={activeLayers}
- onChange={handleLayerToggle}
- themeCategorySlug={BIODIVERSITY_SLUG}
+ onChange={displayLayer}
+ themeCategorySlug={layer.value}
/>
))}
diff --git a/src/pages/dashboard/dashboard-selectors.js b/src/pages/dashboard/dashboard-selectors.js
index 871bae428..a323842db 100644
--- a/src/pages/dashboard/dashboard-selectors.js
+++ b/src/pages/dashboard/dashboard-selectors.js
@@ -2,7 +2,6 @@
import { isEmpty } from 'lodash';
import { createSelector, createStructuredSelector } from 'reselect';
-import { getDataGlobeLayers } from 'selectors/layers-selectors';
import {
selectGlobeUrlState,
selectUiUrlState,
@@ -54,7 +53,6 @@ const getSidebarVisibility = createSelector(
export default createStructuredSelector({
viewSettings: getViewSettings,
- sceneLayers: getDataGlobeLayers,
activeLayers: getActiveLayers,
countryISO: getCountryISO,
countryName: getCountryName,
diff --git a/src/styles/settings.scss b/src/styles/settings.scss
index 677bb7863..8a5d6edce 100644
--- a/src/styles/settings.scss
+++ b/src/styles/settings.scss
@@ -110,6 +110,12 @@ $spi-chart-gradient: linear-gradient(
);
$challenges-view-background: #040e14;
$warning: #dc2626;
+$pointObservations: #54B04A;
+$habitatSuitableRange: #E7C750;
+$localInventories: #7D4182;
+$expertRangeMap: #5A9AB5;
+$regionalChecklist: #AE305C;
+$privatePointObservations: #E93C39;
// country ranking
$endemic-species: #f8d300;
diff --git a/src/styles/themes/checkboxes-theme.module.scss b/src/styles/themes/checkboxes-theme.module.scss
index 1b2ce6a54..f7613bf2e 100644
--- a/src/styles/themes/checkboxes-theme.module.scss
+++ b/src/styles/themes/checkboxes-theme.module.scss
@@ -75,3 +75,42 @@
}
}
+
+
+
+.pointObservations{
+ input:checked+label::after {
+ background-color: $pointObservations;
+ }
+}
+
+.privatePointObservations{
+ input:checked+label::after {
+ background-color: $privatePointObservations;
+ }
+}
+
+
+.habitatSuitableRange{
+ input:checked+label::after {
+ background-color: $habitatSuitableRange;
+ }
+}
+
+.localInventories{
+ input:checked+label::after {
+ background-color: $localInventories;
+ }
+}
+
+.expertRangeMap{
+ input:checked+label::after {
+ background-color: $expertRangeMap;
+ }
+}
+
+.regionalChecklist{
+ input:checked+label::after {
+ background-color: $regionalChecklist
+ }
+}
From 4e768c0a683259dc27eb3b5197dfd747b2c00d6f Mon Sep 17 00:00:00 2001
From: Chris Manciero
Date: Tue, 18 Jun 2024 16:48:15 -0400
Subject: [PATCH 017/350] add dashboard trends endpoint
---
src/app.jsx | 5 ++
.../score-distributions/index.js | 9 ++
.../score-distributions-component.jsx | 35 ++++++++
.../score-distributions-styles.module.scss | 66 ++++++++++++++
.../temporal-trends/index.js | 9 ++
.../temporal-trends-component.jsx | 45 ++++++++++
.../temporal-trends-styles.module.scss | 66 ++++++++++++++
.../dashboard-trends-view-component.jsx | 90 +++++++++++++++++++
.../dashboard-trends-view-config.js | 57 ++++++++++++
.../dashboard-trends-view.js | 17 ++++
.../dashboard-view-component.jsx | 3 +-
.../dashboard-trends-component.jsx | 40 +++++++++
.../dashboard-trends-selectors.js | 63 +++++++++++++
src/pages/dashboard-trends/index.js | 26 ++++++
src/router.ts | 7 +-
15 files changed, 536 insertions(+), 2 deletions(-)
create mode 100644 src/containers/sidebars/dashboard-sidebar/score-distributions/index.js
create mode 100644 src/containers/sidebars/dashboard-sidebar/score-distributions/score-distributions-component.jsx
create mode 100644 src/containers/sidebars/dashboard-sidebar/score-distributions/score-distributions-styles.module.scss
create mode 100644 src/containers/sidebars/dashboard-sidebar/temporal-trends/index.js
create mode 100644 src/containers/sidebars/dashboard-sidebar/temporal-trends/temporal-trends-component.jsx
create mode 100644 src/containers/sidebars/dashboard-sidebar/temporal-trends/temporal-trends-styles.module.scss
create mode 100644 src/containers/views/dashboard-trends-view/dashboard-trends-view-component.jsx
create mode 100644 src/containers/views/dashboard-trends-view/dashboard-trends-view-config.js
create mode 100644 src/containers/views/dashboard-trends-view/dashboard-trends-view.js
create mode 100644 src/pages/dashboard-trends/dashboard-trends-component.jsx
create mode 100644 src/pages/dashboard-trends/dashboard-trends-selectors.js
create mode 100644 src/pages/dashboard-trends/index.js
diff --git a/src/app.jsx b/src/app.jsx
index bbabbff37..24298c2ef 100644
--- a/src/app.jsx
+++ b/src/app.jsx
@@ -32,6 +32,9 @@ const NationalReportCard = loadable(() => import('pages/nrc'));
const NationalReportCardLanding = loadable(() => import('pages/nrc-landing'));
const AreaOfInterest = loadable(() => import('pages/aoi'));
const DashboardComponent = loadable(() => import('pages/dashboard'));
+const DashboardTrendsComponent = loadable(() =>
+ import('pages/dashboard-trends')
+);
const mapStateToProps = ({ location }) => ({
route: location.routesMap[location.type],
@@ -65,6 +68,8 @@ function AppLayout(props) {
return ;
case 'dashboard':
return ;
+ case 'dashboard-trends':
+ return ;
default:
return isMobile ? : ;
}
diff --git a/src/containers/sidebars/dashboard-sidebar/score-distributions/index.js b/src/containers/sidebars/dashboard-sidebar/score-distributions/index.js
new file mode 100644
index 000000000..4da31c401
--- /dev/null
+++ b/src/containers/sidebars/dashboard-sidebar/score-distributions/index.js
@@ -0,0 +1,9 @@
+import React from 'react';
+
+import ScoreDistributionsComponent from './score-distributions-component';
+
+function ScoreDistributionsContainer(props) {
+ return ;
+}
+
+export default ScoreDistributionsContainer;
diff --git a/src/containers/sidebars/dashboard-sidebar/score-distributions/score-distributions-component.jsx b/src/containers/sidebars/dashboard-sidebar/score-distributions/score-distributions-component.jsx
new file mode 100644
index 000000000..105c11730
--- /dev/null
+++ b/src/containers/sidebars/dashboard-sidebar/score-distributions/score-distributions-component.jsx
@@ -0,0 +1,35 @@
+import React from 'react';
+
+import Button from 'components/button';
+
+import styles from './score-distributions-styles.module.scss';
+
+function ScoreDistributionsComponent() {
+ return (
+
+
+
+ Score Distributions
+
+
+
+ View the distribution of the individual Species Protection Scores for
+ all terrestrial vertebrates. Amphibians have the lowest average
+ protection score while birds have the highest.
+
+
+
+
+ Open and download a full table of species SPS and relevant traits at
+ national and province levels for a selected year.
+
+
+
+ );
+}
+
+export default ScoreDistributionsComponent;
diff --git a/src/containers/sidebars/dashboard-sidebar/score-distributions/score-distributions-styles.module.scss b/src/containers/sidebars/dashboard-sidebar/score-distributions/score-distributions-styles.module.scss
new file mode 100644
index 000000000..17375b683
--- /dev/null
+++ b/src/containers/sidebars/dashboard-sidebar/score-distributions/score-distributions-styles.module.scss
@@ -0,0 +1,66 @@
+@import 'styles/ui.module';
+@import 'styles/settings';
+@import 'styles/typography-extends';
+@import 'styles/common-animations.module';
+
+.temporalTrends{
+ display: flex;
+ flex-direction: column;
+ padding: $paragraph-gutter;
+
+ .title{
+ display: flex;
+ gap: 10px;
+
+ img{
+ width: 130px;
+ height: 130px;
+ margin-top: 8px;
+ }
+
+ .info{
+ display: flex;
+ flex-direction: column;
+ gap: 3px;
+ color: $white;
+ margin: 0 0 $site-gutter / 2 0;
+
+ .commonName{
+ @extend %display1;
+ font-size: 24px;
+ line-height: 1.5;
+ }
+ }
+ }
+
+ .description {
+ @extend %bodyText;
+ color: $white;
+ margin: 0 0 $site-gutter / 2 0;
+ font-size: 14px;
+ }
+
+ .options{
+ display: flex;
+ flex-direction: column;
+ row-gap: 8px;
+ margin-top: 10px;
+
+ .saveButton {
+ color: $dark-text;
+ background-color: $brand-color-main;
+ &:hover {
+ background-color: $brand-color-main-hover;
+ }
+ }
+
+ .helpText{
+ color: #FFF;
+ font-family: "Open Sans";
+ font-size: 9px;
+ font-style: italic;
+ font-weight: 400;
+ line-height: normal;
+ }
+ }
+}
diff --git a/src/containers/sidebars/dashboard-sidebar/temporal-trends/index.js b/src/containers/sidebars/dashboard-sidebar/temporal-trends/index.js
new file mode 100644
index 000000000..d42b387fb
--- /dev/null
+++ b/src/containers/sidebars/dashboard-sidebar/temporal-trends/index.js
@@ -0,0 +1,9 @@
+import React from 'react';
+
+import TemporalTrendsComponent from './temporal-trends-component';
+
+function TemporalTrendsContainer(props) {
+ return ;
+}
+
+export default TemporalTrendsContainer;
diff --git a/src/containers/sidebars/dashboard-sidebar/temporal-trends/temporal-trends-component.jsx b/src/containers/sidebars/dashboard-sidebar/temporal-trends/temporal-trends-component.jsx
new file mode 100644
index 000000000..db071073b
--- /dev/null
+++ b/src/containers/sidebars/dashboard-sidebar/temporal-trends/temporal-trends-component.jsx
@@ -0,0 +1,45 @@
+import React from 'react';
+
+import Button from 'components/button';
+
+import styles from './temporal-trends-styles.module.scss';
+
+function TemporalTrendsComponent() {
+ return (
+
+
+
+ Since 1980, the Democratic Republic of the Congo has added 328357 km2 of
+ land into its protected area network, representing 14% of the total land
+ in the country, increasing its Species Protection Index from 27.21 in
+ 1980 to 63 in 2023.
+
+
+
+
+ View how the percent of area protected, SPI, and score distributions
+ have changed over time.
+
+
+
+ Open and download a full table of annual national and province level
+ SPI over time.
+
+
+
+ );
+}
+
+export default TemporalTrendsComponent;
diff --git a/src/containers/sidebars/dashboard-sidebar/temporal-trends/temporal-trends-styles.module.scss b/src/containers/sidebars/dashboard-sidebar/temporal-trends/temporal-trends-styles.module.scss
new file mode 100644
index 000000000..17375b683
--- /dev/null
+++ b/src/containers/sidebars/dashboard-sidebar/temporal-trends/temporal-trends-styles.module.scss
@@ -0,0 +1,66 @@
+@import 'styles/ui.module';
+@import 'styles/settings';
+@import 'styles/typography-extends';
+@import 'styles/common-animations.module';
+
+.temporalTrends{
+ display: flex;
+ flex-direction: column;
+ padding: $paragraph-gutter;
+
+ .title{
+ display: flex;
+ gap: 10px;
+
+ img{
+ width: 130px;
+ height: 130px;
+ margin-top: 8px;
+ }
+
+ .info{
+ display: flex;
+ flex-direction: column;
+ gap: 3px;
+ color: $white;
+ margin: 0 0 $site-gutter / 2 0;
+
+ .commonName{
+ @extend %display1;
+ font-size: 24px;
+ line-height: 1.5;
+ }
+ }
+ }
+
+ .description {
+ @extend %bodyText;
+ color: $white;
+ margin: 0 0 $site-gutter / 2 0;
+ font-size: 14px;
+ }
+
+ .options{
+ display: flex;
+ flex-direction: column;
+ row-gap: 8px;
+ margin-top: 10px;
+
+ .saveButton {
+ color: $dark-text;
+ background-color: $brand-color-main;
+ &:hover {
+ background-color: $brand-color-main-hover;
+ }
+ }
+
+ .helpText{
+ color: #FFF;
+ font-family: "Open Sans";
+ font-size: 9px;
+ font-style: italic;
+ font-weight: 400;
+ line-height: normal;
+ }
+ }
+}
diff --git a/src/containers/views/dashboard-trends-view/dashboard-trends-view-component.jsx b/src/containers/views/dashboard-trends-view/dashboard-trends-view-component.jsx
new file mode 100644
index 000000000..9570c0a63
--- /dev/null
+++ b/src/containers/views/dashboard-trends-view/dashboard-trends-view-component.jsx
@@ -0,0 +1,90 @@
+import React, { useEffect, useState } from 'react';
+
+import loadable from '@loadable/component';
+
+import CountryLabelsLayer from 'containers/layers/country-labels-layer';
+import RegionsLabelsLayer from 'containers/layers/regions-labels-layer';
+import SideMenu from 'containers/menus/sidemenu';
+
+import MapView from 'components/map-view';
+
+import EsriFeatureService from 'services/esri-feature-service';
+
+import { COUNTRIES_DATA_SERVICE_URL } from 'constants/layers-urls';
+
+import ScoreDistributionsContainer from '../../sidebars/dashboard-sidebar/score-distributions';
+import TemporalTrendsContainer from '../../sidebars/dashboard-sidebar/temporal-trends';
+
+const { REACT_APP_ARGISJS_API_VERSION: API_VERSION } = process.env;
+
+const LabelsLayer = loadable(() => import('containers/layers/labels-layer'));
+
+function DashboardTrendsViewComponent(props) {
+ const {
+ activeLayers,
+ onMapLoad,
+ sceneMode,
+ viewSettings,
+ countryISO,
+ countryName,
+ isFullscreenActive,
+ openedModal,
+ } = props;
+
+ const [map, setMap] = useState(null);
+ const [view, setView] = useState(null);
+ const [geo, setGeo] = useState(null);
+
+ useEffect(() => {
+ EsriFeatureService.getFeatures({
+ url: COUNTRIES_DATA_SERVICE_URL,
+ whereClause: `GID_0 = '${countryISO}'`,
+ returnGeometry: true,
+ }).then((features) => {
+ const { geometry } = features[0];
+
+ if (geometry && view) {
+ view.center = [geometry.longitude, geometry.latitude];
+ setGeo(geometry);
+ }
+ });
+ }, [view, countryISO]);
+
+ return (
+
+
+
+
+
+
+
+
+
+
+
+
+ );
+}
+
+export default DashboardTrendsViewComponent;
diff --git a/src/containers/views/dashboard-trends-view/dashboard-trends-view-config.js b/src/containers/views/dashboard-trends-view/dashboard-trends-view-config.js
new file mode 100644
index 000000000..d707ee476
--- /dev/null
+++ b/src/containers/views/dashboard-trends-view/dashboard-trends-view-config.js
@@ -0,0 +1,57 @@
+import {
+ GRAPHIC_LAYER,
+ CITIES_LABELS_LAYER,
+ REGIONS_LABELS_LAYER,
+ ADMIN_AREAS_FEATURE_LAYER,
+ COUNTRIES_LABELS_FEATURE_LAYER,
+ LANDSCAPE_FEATURES_LABELS_LAYER,
+ FIREFLY_BASEMAP_LAYER,
+ SATELLITE_BASEMAP_LAYER,
+} from 'constants/layers-slugs';
+
+export default {
+ view: {
+ activeLayers: [
+ { title: GRAPHIC_LAYER },
+ { title: CITIES_LABELS_LAYER },
+ { title: REGIONS_LABELS_LAYER, opacity: 0 },
+ { title: COUNTRIES_LABELS_FEATURE_LAYER },
+ { title: LANDSCAPE_FEATURES_LABELS_LAYER },
+ { title: ADMIN_AREAS_FEATURE_LAYER },
+ ],
+ padding: {
+ left: 300,
+ },
+ environment: {
+ atmosphereEnabled: false,
+ background: {
+ type: 'color',
+ color: [0, 10, 16],
+ },
+ alphaCompositingEnabled: true,
+ },
+ constraints: {
+ altitude: {
+ max: 35512548,
+ min: 10000,
+ },
+ minZoom: 3,
+ rotationEnabled: false,
+ snapToZoom: false,
+ minScale: 147914381,
+ },
+ ui: {
+ components: [],
+ },
+ basemap: {
+ layersArray: [FIREFLY_BASEMAP_LAYER, SATELLITE_BASEMAP_LAYER],
+ },
+ },
+ ui: {
+ isSidebarOpen: false,
+ isFullscreenActive: false,
+ activeCategory: '',
+ sceneMode: 'data',
+ selectedAnalysisLayer: ADMIN_AREAS_FEATURE_LAYER,
+ },
+};
diff --git a/src/containers/views/dashboard-trends-view/dashboard-trends-view.js b/src/containers/views/dashboard-trends-view/dashboard-trends-view.js
new file mode 100644
index 000000000..ae2cb77ad
--- /dev/null
+++ b/src/containers/views/dashboard-trends-view/dashboard-trends-view.js
@@ -0,0 +1,17 @@
+import React from 'react';
+
+import Component from './dashboard-trends-view-component';
+
+function DashboardTrendsView(props) {
+ const { activeLayers, viewSettings } = props;
+
+ return (
+
+ );
+}
+
+export default DashboardTrendsView;
diff --git a/src/containers/views/dashboard-view/dashboard-view-component.jsx b/src/containers/views/dashboard-view/dashboard-view-component.jsx
index 5627d5cb6..69eb7671e 100644
--- a/src/containers/views/dashboard-view/dashboard-view-component.jsx
+++ b/src/containers/views/dashboard-view/dashboard-view-component.jsx
@@ -6,11 +6,12 @@ import CountryLabelsLayer from 'containers/layers/country-labels-layer';
import RegionsLabelsLayer from 'containers/layers/regions-labels-layer';
import SideMenu from 'containers/menus/sidemenu';
+import MapView from 'components/map-view';
+
import EsriFeatureService from 'services/esri-feature-service';
import { COUNTRIES_DATA_SERVICE_URL } from 'constants/layers-urls';
-import MapView from '../../../components/map-view';
import DashboardSidebar from '../../sidebars/dashboard-sidebar/dashboard-sidebar-component';
const { REACT_APP_ARGISJS_API_VERSION: API_VERSION } = process.env;
diff --git a/src/pages/dashboard-trends/dashboard-trends-component.jsx b/src/pages/dashboard-trends/dashboard-trends-component.jsx
new file mode 100644
index 000000000..056a80c2d
--- /dev/null
+++ b/src/pages/dashboard-trends/dashboard-trends-component.jsx
@@ -0,0 +1,40 @@
+import React from 'react';
+
+import cx from 'classnames';
+
+import Logo from 'components/half-earth-logo';
+
+import uiStyles from 'styles/ui.module.scss';
+
+import DashboardTrendsView from '../../containers/views/dashboard-trends-view/dashboard-trends-view';
+
+function DashboardTrendsComponent(props) {
+ const {
+ countryISO,
+ countryName,
+ activeLayers,
+ handleMapLoad,
+ viewSettings,
+ isSidebarOpen,
+ selectedSpecies,
+ isBiodiversityActive,
+ } = props;
+ return (
+ <>
+
+ handleMapLoad(map, activeLayers)}
+ {...props}
+ />
+ >
+ );
+}
+
+export default DashboardTrendsComponent;
diff --git a/src/pages/dashboard-trends/dashboard-trends-selectors.js b/src/pages/dashboard-trends/dashboard-trends-selectors.js
new file mode 100644
index 000000000..a323842db
--- /dev/null
+++ b/src/pages/dashboard-trends/dashboard-trends-selectors.js
@@ -0,0 +1,63 @@
+/* eslint-disable max-len */
+import { isEmpty } from 'lodash';
+import { createSelector, createStructuredSelector } from 'reselect';
+
+import {
+ selectGlobeUrlState,
+ selectUiUrlState,
+} from 'selectors/location-selectors';
+
+import dashboardViewConfig from '../../containers/views/dashboard-view/dashboard-view-config';
+
+const selectCountryIso = ({ location }) => location.payload.iso.toUpperCase();
+
+const selectBiodiversityData = ({ biodiversityData }) =>
+ biodiversityData && (biodiversityData.data || null);
+const selectMetadataData = ({ metadata }) =>
+ metadata && (!isEmpty(metadata.data) || null);
+
+const getViewSettings = createSelector(selectGlobeUrlState, (globeUrlState) => {
+ return {
+ ...dashboardViewConfig.view,
+ ...globeUrlState,
+ };
+});
+
+const getUiSettings = createSelector(selectUiUrlState, (uiUrlState) => {
+ return {
+ ...dashboardViewConfig.ui,
+ ...uiUrlState,
+ };
+});
+
+export const getActiveLayers = createSelector(
+ getViewSettings,
+ (viewSettings) => viewSettings.activeLayers
+);
+const getSelectedSpecies = createSelector(
+ getViewSettings,
+ (viewSettings) => viewSettings.selectedSpecies
+);
+export const getCountryISO = createSelector(
+ selectCountryIso,
+ (countryISO) => countryISO
+);
+const getCountryName = createSelector(
+ getViewSettings,
+ (viewSettings) => viewSettings.countryName
+);
+const getSidebarVisibility = createSelector(
+ getUiSettings,
+ (uiSettings) => uiSettings.isSidebarOpen
+);
+
+export default createStructuredSelector({
+ viewSettings: getViewSettings,
+ activeLayers: getActiveLayers,
+ countryISO: getCountryISO,
+ countryName: getCountryName,
+ isSidebarOpen: getSidebarVisibility,
+ speciesCategories: selectBiodiversityData,
+ hasMetadata: selectMetadataData,
+ selectedSpecies: getSelectedSpecies,
+});
diff --git a/src/pages/dashboard-trends/index.js b/src/pages/dashboard-trends/index.js
new file mode 100644
index 000000000..7f70cea6b
--- /dev/null
+++ b/src/pages/dashboard-trends/index.js
@@ -0,0 +1,26 @@
+import React from 'react';
+import { connect } from 'react-redux';
+
+import { activateLayersOnLoad } from 'utils/layer-manager-utils';
+
+import { layersConfig } from 'constants/mol-layers-configs';
+
+import { setBasemap } from '../../utils/layer-manager-utils.js';
+
+import DashboardTrendsComponent from './dashboard-trends-component';
+import mapStateToProps from './dashboard-trends-selectors';
+
+function DashboardTrendsContainer(props) {
+ const { viewSettings } = props;
+ const handleMapLoad = (map, activeLayers) => {
+ setBasemap({
+ map,
+ layersArray: viewSettings.basemap.layersArray,
+ });
+ activateLayersOnLoad(map, activeLayers, layersConfig);
+ };
+
+ return ;
+}
+
+export default connect(mapStateToProps, null)(DashboardTrendsContainer);
diff --git a/src/router.ts b/src/router.ts
index 13fa460e5..c6c47b33f 100644
--- a/src/router.ts
+++ b/src/router.ts
@@ -1,6 +1,6 @@
+import { connectRoutes, NOT_FOUND, redirect } from 'redux-first-router';
import { decodeUrlForState, encodeStateForUrl } from 'utils/state-to-url';
-import { connectRoutes, NOT_FOUND, redirect } from 'redux-first-router';
import type { RoutesMap } from 'redux-first-router';
export const LANDING = 'location/';
@@ -12,6 +12,7 @@ export const NATIONAL_REPORT_CARD_LANDING =
export const AREA_OF_INTEREST = 'location/AREA_OF_INTEREST';
export const MAP_IFRAME = 'location/MAP_IFRAME';
export const DASHBOARD = 'location/DASHBOARD';
+export const DASHBOARD_TRENDS = 'location/DASHBOARD_TRENDS';
export const routes: RoutesMap<{ path: string; page?: string }> = {
[LANDING]: {
@@ -38,6 +39,10 @@ export const routes: RoutesMap<{ path: string; page?: string }> = {
path: '/aoi/:id?',
page: 'aoi',
},
+ [DASHBOARD_TRENDS]: {
+ path: '/dashboard/:iso/:trends?',
+ page: 'dashboard-trends',
+ },
[DASHBOARD]: {
path: '/dashboard/:iso',
page: 'dashboard',
From 9e6add3de30320171d6b15d631c28ec68a19838a Mon Sep 17 00:00:00 2001
From: Chris Manciero
Date: Thu, 20 Jun 2024 11:20:00 -0400
Subject: [PATCH 018/350] placeholder for temporal trends charts
---
.../score-distributions-component.jsx | 35 ---------
.../score-distributions-styles.module.scss | 66 ----------------
.../temporal-trends-component.jsx | 45 -----------
.../temporal-trends-styles.module.scss | 66 ----------------
.../dashboard-trends-sidebar-component.jsx | 22 ++++++
...ashboard-trends-sidebar-styles.module.scss | 75 +++++++++++++++++++
.../dashboard-trends-sidebar/index.js | 11 +++
.../score-distributions/index.js | 0
.../score-distributions-component.jsx | 34 +++++++++
.../score-distributions-styles.module.scss | 4 +
.../dashboard-trends-sidebar/selectors.js | 0
.../temporal-trends/index.js | 0
.../temporal-trends-chart/index.js | 9 +++
.../temporal-trends-chart-component.jsx | 71 ++++++++++++++++++
.../temporal-trends-chart-styles.module.scss | 65 ++++++++++++++++
.../temporal-trends-component.jsx | 47 ++++++++++++
.../temporal-trends-styles.module.scss | 4 +
.../dashboard-trends-view-component.jsx | 10 ++-
18 files changed, 348 insertions(+), 216 deletions(-)
delete mode 100644 src/containers/sidebars/dashboard-sidebar/score-distributions/score-distributions-component.jsx
delete mode 100644 src/containers/sidebars/dashboard-sidebar/score-distributions/score-distributions-styles.module.scss
delete mode 100644 src/containers/sidebars/dashboard-sidebar/temporal-trends/temporal-trends-component.jsx
delete mode 100644 src/containers/sidebars/dashboard-sidebar/temporal-trends/temporal-trends-styles.module.scss
create mode 100644 src/containers/sidebars/dashboard-trends-sidebar/dashboard-trends-sidebar-component.jsx
create mode 100644 src/containers/sidebars/dashboard-trends-sidebar/dashboard-trends-sidebar-styles.module.scss
create mode 100644 src/containers/sidebars/dashboard-trends-sidebar/index.js
rename src/containers/sidebars/{dashboard-sidebar => dashboard-trends-sidebar}/score-distributions/index.js (100%)
create mode 100644 src/containers/sidebars/dashboard-trends-sidebar/score-distributions/score-distributions-component.jsx
create mode 100644 src/containers/sidebars/dashboard-trends-sidebar/score-distributions/score-distributions-styles.module.scss
create mode 100644 src/containers/sidebars/dashboard-trends-sidebar/selectors.js
rename src/containers/sidebars/{dashboard-sidebar => dashboard-trends-sidebar}/temporal-trends/index.js (100%)
create mode 100644 src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/temporal-trends-chart/index.js
create mode 100644 src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/temporal-trends-chart/temporal-trends-chart-component.jsx
create mode 100644 src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/temporal-trends-chart/temporal-trends-chart-styles.module.scss
create mode 100644 src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/temporal-trends-component.jsx
create mode 100644 src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/temporal-trends-styles.module.scss
diff --git a/src/containers/sidebars/dashboard-sidebar/score-distributions/score-distributions-component.jsx b/src/containers/sidebars/dashboard-sidebar/score-distributions/score-distributions-component.jsx
deleted file mode 100644
index 105c11730..000000000
--- a/src/containers/sidebars/dashboard-sidebar/score-distributions/score-distributions-component.jsx
+++ /dev/null
@@ -1,35 +0,0 @@
-import React from 'react';
-
-import Button from 'components/button';
-
-import styles from './score-distributions-styles.module.scss';
-
-function ScoreDistributionsComponent() {
- return (
-
-
-
- Score Distributions
-
-
-
- View the distribution of the individual Species Protection Scores for
- all terrestrial vertebrates. Amphibians have the lowest average
- protection score while birds have the highest.
-
-
-
-
- Open and download a full table of species SPS and relevant traits at
- national and province levels for a selected year.
-
-
-
- );
-}
-
-export default ScoreDistributionsComponent;
diff --git a/src/containers/sidebars/dashboard-sidebar/score-distributions/score-distributions-styles.module.scss b/src/containers/sidebars/dashboard-sidebar/score-distributions/score-distributions-styles.module.scss
deleted file mode 100644
index 17375b683..000000000
--- a/src/containers/sidebars/dashboard-sidebar/score-distributions/score-distributions-styles.module.scss
+++ /dev/null
@@ -1,66 +0,0 @@
-@import 'styles/ui.module';
-@import 'styles/settings';
-@import 'styles/typography-extends';
-@import 'styles/common-animations.module';
-
-.temporalTrends{
- display: flex;
- flex-direction: column;
- padding: $paragraph-gutter;
-
- .title{
- display: flex;
- gap: 10px;
-
- img{
- width: 130px;
- height: 130px;
- margin-top: 8px;
- }
-
- .info{
- display: flex;
- flex-direction: column;
- gap: 3px;
- color: $white;
- margin: 0 0 $site-gutter / 2 0;
-
- .commonName{
- @extend %display1;
- font-size: 24px;
- line-height: 1.5;
- }
- }
- }
-
- .description {
- @extend %bodyText;
- color: $white;
- margin: 0 0 $site-gutter / 2 0;
- font-size: 14px;
- }
-
- .options{
- display: flex;
- flex-direction: column;
- row-gap: 8px;
- margin-top: 10px;
-
- .saveButton {
- color: $dark-text;
- background-color: $brand-color-main;
- &:hover {
- background-color: $brand-color-main-hover;
- }
- }
-
- .helpText{
- color: #FFF;
- font-family: "Open Sans";
- font-size: 9px;
- font-style: italic;
- font-weight: 400;
- line-height: normal;
- }
- }
-}
diff --git a/src/containers/sidebars/dashboard-sidebar/temporal-trends/temporal-trends-component.jsx b/src/containers/sidebars/dashboard-sidebar/temporal-trends/temporal-trends-component.jsx
deleted file mode 100644
index db071073b..000000000
--- a/src/containers/sidebars/dashboard-sidebar/temporal-trends/temporal-trends-component.jsx
+++ /dev/null
@@ -1,45 +0,0 @@
-import React from 'react';
-
-import Button from 'components/button';
-
-import styles from './temporal-trends-styles.module.scss';
-
-function TemporalTrendsComponent() {
- return (
-
-
-
- Since 1980, the Democratic Republic of the Congo has added 328357 km2 of
- land into its protected area network, representing 14% of the total land
- in the country, increasing its Species Protection Index from 27.21 in
- 1980 to 63 in 2023.
-
-
-
-
- View how the percent of area protected, SPI, and score distributions
- have changed over time.
-
-
-
- Open and download a full table of annual national and province level
- SPI over time.
-
-
-
- );
-}
-
-export default TemporalTrendsComponent;
diff --git a/src/containers/sidebars/dashboard-sidebar/temporal-trends/temporal-trends-styles.module.scss b/src/containers/sidebars/dashboard-sidebar/temporal-trends/temporal-trends-styles.module.scss
deleted file mode 100644
index 17375b683..000000000
--- a/src/containers/sidebars/dashboard-sidebar/temporal-trends/temporal-trends-styles.module.scss
+++ /dev/null
@@ -1,66 +0,0 @@
-@import 'styles/ui.module';
-@import 'styles/settings';
-@import 'styles/typography-extends';
-@import 'styles/common-animations.module';
-
-.temporalTrends{
- display: flex;
- flex-direction: column;
- padding: $paragraph-gutter;
-
- .title{
- display: flex;
- gap: 10px;
-
- img{
- width: 130px;
- height: 130px;
- margin-top: 8px;
- }
-
- .info{
- display: flex;
- flex-direction: column;
- gap: 3px;
- color: $white;
- margin: 0 0 $site-gutter / 2 0;
-
- .commonName{
- @extend %display1;
- font-size: 24px;
- line-height: 1.5;
- }
- }
- }
-
- .description {
- @extend %bodyText;
- color: $white;
- margin: 0 0 $site-gutter / 2 0;
- font-size: 14px;
- }
-
- .options{
- display: flex;
- flex-direction: column;
- row-gap: 8px;
- margin-top: 10px;
-
- .saveButton {
- color: $dark-text;
- background-color: $brand-color-main;
- &:hover {
- background-color: $brand-color-main-hover;
- }
- }
-
- .helpText{
- color: #FFF;
- font-family: "Open Sans";
- font-size: 9px;
- font-style: italic;
- font-weight: 400;
- line-height: normal;
- }
- }
-}
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/dashboard-trends-sidebar-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/dashboard-trends-sidebar-component.jsx
new file mode 100644
index 000000000..7ddde0818
--- /dev/null
+++ b/src/containers/sidebars/dashboard-trends-sidebar/dashboard-trends-sidebar-component.jsx
@@ -0,0 +1,22 @@
+import React from 'react';
+
+import styles from './dashboard-trends-sidebar-styles.module.scss';
+import ScoreDistributionsContainer from './score-distributions';
+import TemporalTrendsContainer from './temporal-trends';
+
+function DashboardTrendsSidebar(props) {
+ const { activeLayers, map, view } = props;
+
+ return (
+
+
+
+
+ );
+}
+
+export default DashboardTrendsSidebar;
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/dashboard-trends-sidebar-styles.module.scss b/src/containers/sidebars/dashboard-trends-sidebar/dashboard-trends-sidebar-styles.module.scss
new file mode 100644
index 000000000..030bb1764
--- /dev/null
+++ b/src/containers/sidebars/dashboard-trends-sidebar/dashboard-trends-sidebar-styles.module.scss
@@ -0,0 +1,75 @@
+@import 'styles/ui.module';
+@import 'styles/settings';
+@import 'styles/typography-extends';
+@import 'styles/common-animations.module';
+
+$top: calc(#{$sidebar-top-margin} + #{$he-project-logo-size});
+$trends-width: 950px;
+
+.container {
+ @extend %verticalScrollbar;
+ @include backdropBlur();
+ position: absolute;
+ top: $top;
+ left: $site-gutter;
+ display: flex;
+ flex-direction: column;
+ border: $sidebar-border;
+ border-radius: $sidebar-border-radius;
+ height: calc(100vh - #{$top});
+ width: $trends-width;
+ z-index: $bring-to-front;
+}
+
+
+$info-width: 310px;
+
+.trends{
+ display: flex;
+ padding: $paragraph-gutter;
+
+ .info{
+ width: $info-width;
+
+ .title{
+ @extend %display1;
+ display: flex;
+ gap: 10px;
+ color: $white;
+ margin: 0 0 $site-gutter / 2 0;
+ font-size: 24px;
+ line-height: 1.5;
+ }
+
+ .description {
+ @extend %bodyText;
+ color: $white;
+ margin: 0 0 $site-gutter / 2 0;
+ font-size: 14px;
+ }
+
+ .options{
+ display: flex;
+ flex-direction: column;
+ row-gap: 8px;
+ margin-top: 10px;
+
+ .saveButton {
+ color: $dark-text;
+ background-color: $brand-color-main;
+ &:hover {
+ background-color: $brand-color-main-hover;
+ }
+ }
+
+ .helpText{
+ color: #FFF;
+ font-family: "Open Sans";
+ font-size: 9px;
+ font-style: italic;
+ font-weight: 400;
+ line-height: normal;
+ }
+ }
+ }
+}
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/index.js b/src/containers/sidebars/dashboard-trends-sidebar/index.js
new file mode 100644
index 000000000..b907870c7
--- /dev/null
+++ b/src/containers/sidebars/dashboard-trends-sidebar/index.js
@@ -0,0 +1,11 @@
+import React from 'react';
+import { connect } from 'react-redux';
+
+import Component from './dashboard-trends-sidebar-component.jsx';
+import mapStateToProps from './selectors';
+
+function DashboardTrendsSidebarContainer() {
+ return ;
+}
+
+export default connect(mapStateToProps, null)(DashboardTrendsSidebarContainer);
diff --git a/src/containers/sidebars/dashboard-sidebar/score-distributions/index.js b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/index.js
similarity index 100%
rename from src/containers/sidebars/dashboard-sidebar/score-distributions/index.js
rename to src/containers/sidebars/dashboard-trends-sidebar/score-distributions/index.js
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/score-distributions-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/score-distributions-component.jsx
new file mode 100644
index 000000000..e9730da24
--- /dev/null
+++ b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/score-distributions-component.jsx
@@ -0,0 +1,34 @@
+import React from 'react';
+
+import Button from 'components/button';
+
+import styles from '../dashboard-trends-sidebar-styles.module.scss';
+
+function ScoreDistributionsComponent() {
+ return (
+
+
+
Score Distributions
+
+
+ View the distribution of the individual Species Protection Scores for
+ all terrestrial vertebrates. Amphibians have the lowest average
+ protection score while birds have the highest.
+
+
+
+
+ Open and download a full table of species SPS and relevant traits at
+ national and province levels for a selected year.
+
+
+
+
+ );
+}
+
+export default ScoreDistributionsComponent;
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/score-distributions-styles.module.scss b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/score-distributions-styles.module.scss
new file mode 100644
index 000000000..c709bfc60
--- /dev/null
+++ b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/score-distributions-styles.module.scss
@@ -0,0 +1,4 @@
+@import 'styles/ui.module';
+@import 'styles/settings';
+@import 'styles/typography-extends';
+@import 'styles/common-animations.module';
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/selectors.js b/src/containers/sidebars/dashboard-trends-sidebar/selectors.js
new file mode 100644
index 000000000..e69de29bb
diff --git a/src/containers/sidebars/dashboard-sidebar/temporal-trends/index.js b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/index.js
similarity index 100%
rename from src/containers/sidebars/dashboard-sidebar/temporal-trends/index.js
rename to src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/index.js
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/temporal-trends-chart/index.js b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/temporal-trends-chart/index.js
new file mode 100644
index 000000000..49238c4cb
--- /dev/null
+++ b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/temporal-trends-chart/index.js
@@ -0,0 +1,9 @@
+import React from 'react';
+
+import TemporalTrendsChartComponent from './temporal-trends-chart-component';
+
+function TemporalTrendsChartContainer(props) {
+ return ;
+}
+
+export default TemporalTrendsChartContainer;
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/temporal-trends-chart/temporal-trends-chart-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/temporal-trends-chart/temporal-trends-chart-component.jsx
new file mode 100644
index 000000000..f8e1d2dfd
--- /dev/null
+++ b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/temporal-trends-chart/temporal-trends-chart-component.jsx
@@ -0,0 +1,71 @@
+import React from 'react';
+import Select from 'react-select';
+
+import ArcChart from 'components/charts/arc-chart';
+
+import COLORS from 'styles/settings';
+
+import styles from './temporal-trends-chart-styles.module.scss';
+
+function TemporalTrendsChartComponent() {
+ const areaChartHeight = 100;
+ const areaChartWidth = 220;
+ const spi = 48.55;
+
+ const provinces = [
+ { value: 'Mai-Ndombe', label: 'Mai-Ndombe' },
+ { value: 'Équateur', label: 'Équateur' },
+ { value: 'Kasaï', label: 'Kasaï' },
+ { value: 'Sankuru', label: 'Sankuru' },
+ ];
+
+ return (
+
+
+
+
+ #13 in Species Protection Index
+
+
+ #1 in vertebrate species richness
+
+
+ #16 in size
+
+
+
+
+ 2024
+ Year
+
+
+
+ 19.58
+ Area Protected
+
+
+
+ );
+}
+
+export default TemporalTrendsChartComponent;
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/temporal-trends-chart/temporal-trends-chart-styles.module.scss b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/temporal-trends-chart/temporal-trends-chart-styles.module.scss
new file mode 100644
index 000000000..972333a6d
--- /dev/null
+++ b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/temporal-trends-chart/temporal-trends-chart-styles.module.scss
@@ -0,0 +1,65 @@
+@import 'styles/ui.module';
+@import 'styles/settings';
+@import 'styles/typography-extends';
+@import 'styles/common-animations.module';
+
+.info{
+ padding: 10px 26px;
+ display: flex;
+ gap: 15px;
+
+ .specs{
+ display: flex;
+ flex-direction: column;
+ row-gap: 8px;
+
+ span{
+ color: #FFF;
+ font-family: "Open Sans";
+ font-size: 13px;
+ font-style: italic;
+ font-weight: 400;
+ line-height: normal;
+
+ b{
+ color: #FFF;
+ font-family: "Open Sans";
+ font-size: 14px;
+ font-style: normal;
+ font-weight: 600;
+ line-height: normal;
+ }
+ }
+ }
+
+ .arcChart{
+ display: flex;
+ height: 100px;
+ align-items: flex-end;
+
+ .stats{
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+
+ b {
+ color: #FFF;
+ font-family: "Open Sans";
+ font-size: 16px;
+ font-style: normal;
+ font-weight: 600;
+ line-height: normal;
+ }
+
+ span{
+ color: #FFF;
+ font-family: "Open Sans";
+ font-size: 12px;
+ font-style: italic;
+ font-weight: 600;
+ line-height: normal;
+ text-transform: uppercase;
+ }
+ }
+ }
+}
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/temporal-trends-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/temporal-trends-component.jsx
new file mode 100644
index 000000000..22fb4f113
--- /dev/null
+++ b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/temporal-trends-component.jsx
@@ -0,0 +1,47 @@
+import React from 'react';
+
+import Button from 'components/button';
+
+import styles from '../dashboard-trends-sidebar-styles.module.scss';
+
+import TemporalTrendsChartContainer from './temporal-trends-chart';
+
+function TemporalTrendsComponent(props) {
+ return (
+
+
+
Temporal Trends
+
+ Since 1980, the Democratic Republic of the Congo has added 328357 km2
+ of land into its protected area network, representing 14% of the total
+ land in the country, increasing its Species Protection Index from
+ 27.21 in 1980 to 63 in 2023.
+
+
+
+
+ View how the percent of area protected, SPI, and score distributions
+ have changed over time.
+
+
+
+ Open and download a full table of annual national and province level
+ SPI over time.
+
+
+
+
+
+
+ );
+}
+
+export default TemporalTrendsComponent;
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/temporal-trends-styles.module.scss b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/temporal-trends-styles.module.scss
new file mode 100644
index 000000000..c709bfc60
--- /dev/null
+++ b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/temporal-trends-styles.module.scss
@@ -0,0 +1,4 @@
+@import 'styles/ui.module';
+@import 'styles/settings';
+@import 'styles/typography-extends';
+@import 'styles/common-animations.module';
diff --git a/src/containers/views/dashboard-trends-view/dashboard-trends-view-component.jsx b/src/containers/views/dashboard-trends-view/dashboard-trends-view-component.jsx
index 9570c0a63..0b260fa68 100644
--- a/src/containers/views/dashboard-trends-view/dashboard-trends-view-component.jsx
+++ b/src/containers/views/dashboard-trends-view/dashboard-trends-view-component.jsx
@@ -12,8 +12,7 @@ import EsriFeatureService from 'services/esri-feature-service';
import { COUNTRIES_DATA_SERVICE_URL } from 'constants/layers-urls';
-import ScoreDistributionsContainer from '../../sidebars/dashboard-sidebar/score-distributions';
-import TemporalTrendsContainer from '../../sidebars/dashboard-sidebar/temporal-trends';
+import DashboardTrendsSidebar from '../../sidebars/dashboard-trends-sidebar/dashboard-trends-sidebar-component';
const { REACT_APP_ARGISJS_API_VERSION: API_VERSION } = process.env;
@@ -64,8 +63,11 @@ function DashboardTrendsViewComponent(props) {
url: `https://js.arcgis.com/${API_VERSION}`,
}}
>
-
-
+
Date: Thu, 20 Jun 2024 17:55:25 -0400
Subject: [PATCH 019/350] add bubble chart
---
package.json | 3 +
.../temporal-trends-chart-component.jsx | 126 ++++++++++++------
.../temporal-trends-chart-styles.module.scss | 89 +++++++------
yarn.lock | 27 ++++
4 files changed, 163 insertions(+), 82 deletions(-)
diff --git a/package.json b/package.json
index b78554272..e07ebe7bb 100644
--- a/package.json
+++ b/package.json
@@ -5,12 +5,14 @@
"dependencies": {
"@esri/arcgis-rest-feature-layer": "^3.4.3",
"@esri/arcgis-rest-request": "^3.4.3",
+ "@faker-js/faker": "^8.4.1",
"@loadable/component": "^5.10.1",
"@tanstack/react-query": "^4.1.0",
"@tippyjs/react": "^4.2.5",
"@transifex/native": "^4.1.0",
"@transifex/react": "^4.1.0",
"assert": "^2.0.0",
+ "chart.js": "^4.4.3",
"classnames": "^2.2.6",
"contentful": "^7.6.0",
"cross-var": "^1.1.0",
@@ -30,6 +32,7 @@
"qs": "^6.7.0",
"rc-slider": "^9.7.2",
"react": "^16.8.6",
+ "react-chartjs-2": "^5.2.0",
"react-copy-to-clipboard": "^5.0.1",
"react-dom": "^16.8.6",
"react-dropzone": "^11.4.0",
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/temporal-trends-chart/temporal-trends-chart-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/temporal-trends-chart/temporal-trends-chart-component.jsx
index f8e1d2dfd..0f59cc41a 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/temporal-trends-chart/temporal-trends-chart-component.jsx
+++ b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/temporal-trends-chart/temporal-trends-chart-component.jsx
@@ -1,12 +1,24 @@
import React from 'react';
+import { Bubble } from 'react-chartjs-2';
import Select from 'react-select';
+import { faker } from '@faker-js/faker';
+import {
+ Chart as ChartJS,
+ LinearScale,
+ PointElement,
+ Tooltip,
+ Legend,
+} from 'chart.js';
+
import ArcChart from 'components/charts/arc-chart';
import COLORS from 'styles/settings';
import styles from './temporal-trends-chart-styles.module.scss';
+ChartJS.register(LinearScale, PointElement, Tooltip, Legend);
+
function TemporalTrendsChartComponent() {
const areaChartHeight = 100;
const areaChartWidth = 220;
@@ -19,51 +31,85 @@ function TemporalTrendsChartComponent() {
{ value: 'Sankuru', label: 'Sankuru' },
];
+ const options = {
+ scales: {
+ y: {
+ beginAtZero: true,
+ },
+ },
+ };
+
+ const data = {
+ datasets: [
+ {
+ label: 'Red dataset',
+ data: Array.from({ length: 50 }, () => ({
+ x: faker.datatype.number({ min: -100, max: 100 }),
+ y: faker.datatype.number({ min: -100, max: 100 }),
+ r: faker.datatype.number({ min: 5, max: 20 }),
+ })),
+ backgroundColor: 'rgba(255, 99, 132, 0.5)',
+ },
+ {
+ label: 'Blue dataset',
+ data: Array.from({ length: 50 }, () => ({
+ x: faker.datatype.number({ min: -100, max: 100 }),
+ y: faker.datatype.number({ min: -100, max: 100 }),
+ r: faker.datatype.number({ min: 5, max: 20 }),
+ })),
+ backgroundColor: 'rgba(53, 162, 235, 0.5)',
+ },
+ ],
+ };
+
return (
-
-
-
-
- #13 in Species Protection Index
-
-
- #1 in vertebrate species richness
-
-
- #16 in size
-
-
-
-
- 2024
- Year
-
-
-
+
+
+
+
+ #13 in Species Protection Index
+
+
+ #1 in vertebrate species richness
+
+
+ #16 in size
+
-
-
19.58
-
Area Protected
+
+
+ 2024
+ Year
+
+
+
+ 19.58
+ Area Protected
+
+
);
}
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/temporal-trends-chart/temporal-trends-chart-styles.module.scss b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/temporal-trends-chart/temporal-trends-chart-styles.module.scss
index 972333a6d..bc157cd6d 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/temporal-trends-chart/temporal-trends-chart-styles.module.scss
+++ b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/temporal-trends-chart/temporal-trends-chart-styles.module.scss
@@ -3,62 +3,67 @@
@import 'styles/typography-extends';
@import 'styles/common-animations.module';
-.info{
- padding: 10px 26px;
+.container{
display: flex;
- gap: 15px;
+ flex-direction: column;
+ padding: 10px 26px;
- .specs{
+ .info{
display: flex;
- flex-direction: column;
- row-gap: 8px;
+ gap: 15px;
- span{
- color: #FFF;
- font-family: "Open Sans";
- font-size: 13px;
- font-style: italic;
- font-weight: 400;
- line-height: normal;
+ .specs{
+ display: flex;
+ flex-direction: column;
+ row-gap: 8px;
- b{
+ span{
color: #FFF;
font-family: "Open Sans";
- font-size: 14px;
- font-style: normal;
- font-weight: 600;
+ font-size: 13px;
+ font-style: italic;
+ font-weight: 400;
line-height: normal;
+
+ b{
+ color: #FFF;
+ font-family: "Open Sans";
+ font-size: 14px;
+ font-style: normal;
+ font-weight: 600;
+ line-height: normal;
+ }
}
}
- }
- .arcChart{
- display: flex;
- height: 100px;
- align-items: flex-end;
-
- .stats{
+ .arcChart{
display: flex;
- flex-direction: column;
- align-items: center;
+ height: 100px;
+ align-items: flex-end;
- b {
- color: #FFF;
- font-family: "Open Sans";
- font-size: 16px;
- font-style: normal;
- font-weight: 600;
- line-height: normal;
- }
+ .stats{
+ display: flex;
+ flex-direction: column;
+ align-items: center;
- span{
- color: #FFF;
- font-family: "Open Sans";
- font-size: 12px;
- font-style: italic;
- font-weight: 600;
- line-height: normal;
- text-transform: uppercase;
+ b {
+ color: #FFF;
+ font-family: "Open Sans";
+ font-size: 16px;
+ font-style: normal;
+ font-weight: 600;
+ line-height: normal;
+ }
+
+ span{
+ color: #FFF;
+ font-family: "Open Sans";
+ font-size: 12px;
+ font-style: italic;
+ font-weight: 600;
+ line-height: normal;
+ text-transform: uppercase;
+ }
}
}
}
diff --git a/yarn.lock b/yarn.lock
index d0958d329..2adc26a28 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -1496,6 +1496,11 @@
resolved "https://registry.yarnpkg.com/@esri/arcgis-rest-types/-/arcgis-rest-types-3.7.0.tgz#3fa61b95b63e4129b73a499411b368aa7940490b"
integrity sha512-KEgORx0HKHOrV4oMYOwmZ76N89WTNkbKb1z3UYJrOEaKVGRU3jisgQcuTXFqjJJe4ZApGQhxCzNgcaU067qdpA==
+"@faker-js/faker@^8.4.1":
+ version "8.4.1"
+ resolved "https://registry.yarnpkg.com/@faker-js/faker/-/faker-8.4.1.tgz#5d5e8aee8fce48f5e189bf730ebd1f758f491451"
+ integrity sha512-XQ3cU+Q8Uqmrbf2e0cIC/QN43sTBSC8KF12u29Mb47tWrt2hAgBXSgpZMj4Ao8Uk0iJcU99QsOCaIL8934obCg==
+
"@floating-ui/core@^1.0.0":
version "1.6.2"
resolved "https://registry.yarnpkg.com/@floating-ui/core/-/core-1.6.2.tgz#d37f3e0ac1f1c756c7de45db13303a266226851a"
@@ -1879,6 +1884,11 @@
"@jridgewell/resolve-uri" "^3.1.0"
"@jridgewell/sourcemap-codec" "^1.4.14"
+"@kurkle/color@^0.3.0":
+ version "0.3.2"
+ resolved "https://registry.yarnpkg.com/@kurkle/color/-/color-0.3.2.tgz#5acd38242e8bde4f9986e7913c8fdf49d3aa199f"
+ integrity sha512-fuscdXJ9G1qb7W8VdHi+IwRqij3lBkosAm4ydQtEmbY58OzHXqQhvlxqEkoz0yssNVn38bcpRWgA9PP+OGoisw==
+
"@leichtgewicht/ip-codec@^2.0.1":
version "2.0.5"
resolved "https://registry.yarnpkg.com/@leichtgewicht/ip-codec/-/ip-codec-2.0.5.tgz#4fc56c15c580b9adb7dc3c333a134e540b44bfb1"
@@ -5006,6 +5016,13 @@ charenc@0.0.2, "charenc@>= 0.0.1":
resolved "https://registry.yarnpkg.com/charenc/-/charenc-0.0.2.tgz#c0a1d2f3a7092e03774bfa83f14c0fc5790a8667"
integrity sha512-yrLQ/yVUFXkzg7EDQsPieE/53+0RlaWTs+wBrvW36cyilJ2SaDWfl4Yj7MtLTXleV9uEKefbAGUPv2/iWSooRA==
+chart.js@^4.4.3:
+ version "4.4.3"
+ resolved "https://registry.yarnpkg.com/chart.js/-/chart.js-4.4.3.tgz#3b2e11e7010fefa99b07d0349236f5098e5226ad"
+ integrity sha512-qK1gkGSRYcJzqrrzdR6a+I0vQ4/R+SoODXyAjscQ/4mzuNzySaMCd+hyVxitSY1+L2fjPD1Gbn+ibNqRmwQeLw==
+ dependencies:
+ "@kurkle/color" "^0.3.0"
+
check-more-types@^2.24.0:
version "2.24.0"
resolved "https://registry.yarnpkg.com/check-more-types/-/check-more-types-2.24.0.tgz#1420ffb10fd444dcfc79b43891bbfffd32a84600"
@@ -7249,6 +7266,11 @@ extsprintf@^1.2.0:
resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.4.1.tgz#8d172c064867f235c0c84a596806d279bf4bcc07"
integrity sha512-Wrk35e8ydCKDj/ArClo1VrPVmN8zph5V4AtHwIuHhvMXsKf73UT3BOD+azBIW+3wOJ4FhEH7zyaJCFvChjYvMA==
+faker@^6.6.6:
+ version "6.6.6"
+ resolved "https://registry.yarnpkg.com/faker/-/faker-6.6.6.tgz#e9529da0109dca4c7c5dbfeaadbd9234af943033"
+ integrity sha512-9tCqYEDHI5RYFQigXFwF1hnCwcWCOJl/hmll0lr5D2Ljjb0o4wphb69wikeJDz5qCEzXCoPvG6ss5SDP6IfOdg==
+
fast-copy@^2.1.0, fast-copy@^2.1.7:
version "2.1.7"
resolved "https://registry.yarnpkg.com/fast-copy/-/fast-copy-2.1.7.tgz#affc9475cb4b555fb488572b2a44231d0c9fa39e"
@@ -11861,6 +11883,11 @@ react-app-rewired@^2.2.1:
dependencies:
semver "^5.6.0"
+react-chartjs-2@^5.2.0:
+ version "5.2.0"
+ resolved "https://registry.yarnpkg.com/react-chartjs-2/-/react-chartjs-2-5.2.0.tgz#43c1e3549071c00a1a083ecbd26c1ad34d385f5d"
+ integrity sha512-98iN5aguJyVSxp5U3CblRLH67J8gkfyGNbiK3c+l1QI/G4irHMPQw44aEPmjVag+YKTyQ260NcF82GTQ3bdscA==
+
react-copy-to-clipboard@^5.0.1:
version "5.1.0"
resolved "https://registry.yarnpkg.com/react-copy-to-clipboard/-/react-copy-to-clipboard-5.1.0.tgz#09aae5ec4c62750ccb2e6421a58725eabc41255c"
From 5b4379d0eceef0b0185f6f57dc9fb888d5306be9 Mon Sep 17 00:00:00 2001
From: Chris Manciero
Date: Fri, 21 Jun 2024 18:08:15 -0400
Subject: [PATCH 020/350] update charts for trends
---
.../score-distributions-chart/index.js | 9 +
.../score-distribution-chart-component.jsx | 235 ++++++++++++++++++
.../score-distribution-styles.module.scss | 57 +++++
.../score-distributions-component.jsx | 6 +-
.../temporal-trends-chart-component.jsx | 65 +++--
.../temporal-trends-chart-styles.module.scss | 18 ++
src/router.ts | 2 +-
7 files changed, 370 insertions(+), 22 deletions(-)
create mode 100644 src/containers/sidebars/dashboard-trends-sidebar/score-distributions/score-distributions-chart/index.js
create mode 100644 src/containers/sidebars/dashboard-trends-sidebar/score-distributions/score-distributions-chart/score-distribution-chart-component.jsx
create mode 100644 src/containers/sidebars/dashboard-trends-sidebar/score-distributions/score-distributions-chart/score-distribution-styles.module.scss
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/score-distributions-chart/index.js b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/score-distributions-chart/index.js
new file mode 100644
index 000000000..128f1a7fe
--- /dev/null
+++ b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/score-distributions-chart/index.js
@@ -0,0 +1,9 @@
+import React from 'react';
+
+import ScoreDistributionChartComponent from './score-distribution-chart-component';
+
+function ScoreDistributionChartContainer(props) {
+ return ;
+}
+
+export default ScoreDistributionChartContainer;
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/score-distributions-chart/score-distribution-chart-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/score-distributions-chart/score-distribution-chart-component.jsx
new file mode 100644
index 000000000..fba29d7f5
--- /dev/null
+++ b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/score-distributions-chart/score-distribution-chart-component.jsx
@@ -0,0 +1,235 @@
+import React from 'react';
+import { Bar, Doughnut } from 'react-chartjs-2';
+
+import { faker } from '@faker-js/faker';
+import {
+ Chart as ChartJS,
+ CategoryScale,
+ LinearScale,
+ ArcElement,
+ BarElement,
+ Title,
+ Tooltip,
+ Legend,
+} from 'chart.js';
+
+import COLORS from 'styles/settings';
+
+import styles from './score-distribution-styles.module.scss';
+
+ChartJS.register(
+ CategoryScale,
+ LinearScale,
+ ArcElement,
+ BarElement,
+ Title,
+ Tooltip,
+ Legend
+);
+
+function ScoreDistributionChartComponent() {
+ const options = {
+ plugins: {
+ title: {
+ display: true,
+ text: 'Chart.js Bar Chart - Stacked',
+ },
+ },
+ responsive: true,
+ interaction: {
+ mode: 'index',
+ intersect: false,
+ },
+ scales: {
+ x: {
+ stacked: true,
+ },
+ y: {
+ stacked: true,
+ },
+ },
+ };
+
+ const doughnutOptions = {
+ cutout: '80%',
+ radius: '100%',
+ rotation: -90,
+ responsive: true,
+ circumference: 180,
+ hoverOffset: 5,
+ animation: {
+ animateRotate: true,
+ animateScale: false,
+ },
+ plugins: {
+ legend: {
+ display: false,
+ },
+ },
+ layout: {
+ padding: {
+ left: 5,
+ right: 5,
+ top: 5,
+ bottom: 5,
+ },
+ },
+ };
+
+ const labels = [
+ 'January',
+ 'February',
+ 'March',
+ 'April',
+ 'May',
+ 'June',
+ 'July',
+ ];
+
+ const data = {
+ labels,
+ datasets: [
+ {
+ label: 'Dataset 1',
+ data: labels.map(() =>
+ faker.datatype.number({ min: -1000, max: 1000 })
+ ),
+ backgroundColor: COLORS.primary,
+ stack: 'Stack 0',
+ },
+ {
+ label: 'Dataset 2',
+ data: labels.map(() =>
+ faker.datatype.number({ min: -1000, max: 1000 })
+ ),
+ backgroundColor: COLORS.tango,
+ stack: 'Stack 0',
+ },
+ {
+ label: 'Dataset 3',
+ data: labels.map(() =>
+ faker.datatype.number({ min: -1000, max: 1000 })
+ ),
+ backgroundColor: COLORS['medium-purple'],
+ stack: 'Stack 0',
+ },
+ {
+ label: 'Dataset 4',
+ data: labels.map(() =>
+ faker.datatype.number({ min: -1000, max: 1000 })
+ ),
+ backgroundColor: COLORS['french-rose'],
+ stack: 'Stack 0',
+ },
+ ],
+ };
+
+ const birdData = {
+ labels: ['Birds', 'Remaining'],
+ datasets: [
+ {
+ label: '',
+ data: [69.87, 30.13],
+ backgroundColor: [COLORS.primary, COLORS['white-opacity-20']],
+ borderColor: [COLORS.primary, COLORS['white-opacity-20']],
+ borderWidth: 1,
+ },
+ ],
+ };
+
+ const mammalsData = {
+ labels: ['Mammals', 'Remaining'],
+ datasets: [
+ {
+ label: '',
+ data: [60.98, 39.02],
+ backgroundColor: [COLORS.tango, COLORS['white-opacity-20']],
+ borderColor: [COLORS.tango, COLORS['white-opacity-20']],
+ borderWidth: 1,
+ },
+ ],
+ };
+
+ const reptilesData = {
+ labels: ['Reptiles', 'Remaining'],
+ datasets: [
+ {
+ label: '',
+ data: [63.45, 36.55],
+ backgroundColor: [COLORS['medium-purple'], COLORS['white-opacity-20']],
+ borderColor: [COLORS['medium-purple'], COLORS['white-opacity-20']],
+ borderWidth: 1,
+ },
+ ],
+ };
+
+ const amphibianData = {
+ labels: ['Amphibians', 'Remaining'],
+ datasets: [
+ {
+ label: '',
+ data: [49.02, 49.98],
+ backgroundColor: [COLORS['french-rose'], COLORS['white-opacity-20']],
+ borderColor: [COLORS['french-rose'], COLORS['white-opacity-20']],
+ borderWidth: 1,
+ },
+ ],
+ };
+
+ const areaChartHeight = 100;
+ const areaChartWidth = 120;
+
+ return (
+
+
NATIONAL SPI BY TAXONOMIC GROUP
+
+
+ 69.87
+
+
+
+ 60.98
+
+
+
+ 63.45
+
+
+
+ 49.02
+
+
+
+
+
+
+
+
+ );
+}
+
+export default ScoreDistributionChartComponent;
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/score-distributions-chart/score-distribution-styles.module.scss b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/score-distributions-chart/score-distribution-styles.module.scss
new file mode 100644
index 000000000..19b4a38ea
--- /dev/null
+++ b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/score-distributions-chart/score-distribution-styles.module.scss
@@ -0,0 +1,57 @@
+@import 'styles/ui.module';
+@import 'styles/settings';
+@import 'styles/typography-extends';
+@import 'styles/common-animations.module';
+
+.container{
+ display: flex;
+ flex-direction: column;
+ padding: 10px 26px;
+ flex-grow: 1;
+ align-items: center;
+
+ .title{
+ color: $white;
+ font-family: "Open Sans";
+ font-size: 15px;
+ font-style: normal;
+ font-weight: 700;
+ line-height: normal;
+ text-transform: uppercase;
+ }
+
+ .spis{
+ display: flex;
+ gap: 10px;
+ align-items: center;
+ width: 100%;
+ justify-content: center;
+ border-radius: 5px;
+ border: 1.5px solid $brand-color-main;
+ box-shadow: -2px 4px 4px 0px rgba(0, 0, 0, 0.25);
+ padding-top: 15px;
+ margin-top: 8px;
+
+ .spi{
+ display: flex;
+ flex-direction: column;
+ justify-content: center;
+ align-items: center;
+
+ .score{
+ color: #FFF;
+ text-align: center;
+ font-family: "Open Sans";
+ font-size: 20px;
+ font-style: normal;
+ font-weight: 700;
+ line-height: normal;
+ margin-bottom: -20px;
+ }
+ }
+ }
+
+ .barChart{
+ width: 100%;
+ }
+}
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/score-distributions-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/score-distributions-component.jsx
index e9730da24..c2d307e1d 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/score-distributions-component.jsx
+++ b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/score-distributions-component.jsx
@@ -4,7 +4,9 @@ import Button from 'components/button';
import styles from '../dashboard-trends-sidebar-styles.module.scss';
-function ScoreDistributionsComponent() {
+import ScoreDistributionChartContainer from './score-distributions-chart';
+
+function ScoreDistributionsComponent(props) {
return (
@@ -27,6 +29,8 @@ function ScoreDistributionsComponent() {
+
+
);
}
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/temporal-trends-chart/temporal-trends-chart-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/temporal-trends-chart/temporal-trends-chart-component.jsx
index 0f59cc41a..9e1ddb605 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/temporal-trends-chart/temporal-trends-chart-component.jsx
+++ b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/temporal-trends-chart/temporal-trends-chart-component.jsx
@@ -1,5 +1,5 @@
import React from 'react';
-import { Bubble } from 'react-chartjs-2';
+import { Bubble, Doughnut } from 'react-chartjs-2';
import Select from 'react-select';
import { faker } from '@faker-js/faker';
@@ -7,23 +7,18 @@ import {
Chart as ChartJS,
LinearScale,
PointElement,
+ ArcElement,
Tooltip,
Legend,
} from 'chart.js';
-import ArcChart from 'components/charts/arc-chart';
-
import COLORS from 'styles/settings';
import styles from './temporal-trends-chart-styles.module.scss';
-ChartJS.register(LinearScale, PointElement, Tooltip, Legend);
+ChartJS.register(LinearScale, ArcElement, PointElement, Tooltip, Legend);
function TemporalTrendsChartComponent() {
- const areaChartHeight = 100;
- const areaChartWidth = 220;
- const spi = 48.55;
-
const provinces = [
{ value: 'Mai-Ndombe', label: 'Mai-Ndombe' },
{ value: 'Équateur', label: 'Équateur' },
@@ -62,6 +57,45 @@ function TemporalTrendsChartComponent() {
],
};
+ const doughnutOptions = {
+ cutout: '80%',
+ radius: '100%',
+ rotation: -90,
+ responsive: true,
+ circumference: 180,
+ hoverOffset: 5,
+ animation: {
+ animateRotate: true,
+ animateScale: false,
+ },
+ plugins: {
+ legend: {
+ display: false,
+ },
+ },
+ layout: {
+ padding: {
+ left: 5,
+ right: 5,
+ top: 5,
+ bottom: 5,
+ },
+ },
+ };
+
+ const birdData = {
+ labels: ['Birds', 'Remaining'],
+ datasets: [
+ {
+ label: '',
+ data: [49, 51],
+ backgroundColor: [COLORS.primary, COLORS['white-opacity-20']],
+ borderColor: [COLORS.primary, COLORS['white-opacity-20']],
+ borderWidth: 1,
+ },
+ ],
+ };
+
return (
@@ -90,18 +124,9 @@ function TemporalTrendsChartComponent() {
2024
Year
-
-
+
+
+ 49
19.58
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/temporal-trends-chart/temporal-trends-chart-styles.module.scss b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/temporal-trends-chart/temporal-trends-chart-styles.module.scss
index bc157cd6d..3c7b36023 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/temporal-trends-chart/temporal-trends-chart-styles.module.scss
+++ b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/temporal-trends-chart/temporal-trends-chart-styles.module.scss
@@ -41,6 +41,24 @@
height: 100px;
align-items: flex-end;
+ .spi{
+ display: flex;
+ flex-direction: column;
+ justify-content: center;
+ align-items: center;
+
+ .score{
+ color: #FFF;
+ text-align: center;
+ font-family: "Open Sans";
+ font-size: 20px;
+ font-style: normal;
+ font-weight: 700;
+ line-height: normal;
+ margin-top: -20px;
+ }
+ }
+
.stats{
display: flex;
flex-direction: column;
diff --git a/src/router.ts b/src/router.ts
index c6c47b33f..900016de1 100644
--- a/src/router.ts
+++ b/src/router.ts
@@ -40,7 +40,7 @@ export const routes: RoutesMap<{ path: string; page?: string }> = {
page: 'aoi',
},
[DASHBOARD_TRENDS]: {
- path: '/dashboard/:iso/:trends?',
+ path: '/dashboard/:iso/trends',
page: 'dashboard-trends',
},
[DASHBOARD]: {
From 499a69c63cc0d752ef5dd0bcc9bdbb59d88d9c73 Mon Sep 17 00:00:00 2001
From: Chris Manciero
Date: Mon, 24 Jun 2024 12:45:51 -0400
Subject: [PATCH 021/350] updated chart styling for trends
---
src/assets/images/amphibians.svg | 3 +
src/assets/images/birds.svg | 3 +
src/assets/images/mammals.svg | 3 +
src/assets/images/reptiles.svg | 3 +
.../score-distribution-chart-component.jsx | 185 +++++++++++-------
.../score-distribution-styles.module.scss | 31 ++-
.../temporal-trends-chart-component.jsx | 86 ++++++--
.../temporal-trends-chart-styles.module.scss | 15 +-
8 files changed, 237 insertions(+), 92 deletions(-)
create mode 100644 src/assets/images/amphibians.svg
create mode 100644 src/assets/images/birds.svg
create mode 100644 src/assets/images/mammals.svg
create mode 100644 src/assets/images/reptiles.svg
diff --git a/src/assets/images/amphibians.svg b/src/assets/images/amphibians.svg
new file mode 100644
index 000000000..f1d96422e
--- /dev/null
+++ b/src/assets/images/amphibians.svg
@@ -0,0 +1,3 @@
+
+
+
diff --git a/src/assets/images/birds.svg b/src/assets/images/birds.svg
new file mode 100644
index 000000000..d1656aa4f
--- /dev/null
+++ b/src/assets/images/birds.svg
@@ -0,0 +1,3 @@
+
+
+
diff --git a/src/assets/images/mammals.svg b/src/assets/images/mammals.svg
new file mode 100644
index 000000000..a28016c83
--- /dev/null
+++ b/src/assets/images/mammals.svg
@@ -0,0 +1,3 @@
+
+
+
diff --git a/src/assets/images/reptiles.svg b/src/assets/images/reptiles.svg
new file mode 100644
index 000000000..974b0bc49
--- /dev/null
+++ b/src/assets/images/reptiles.svg
@@ -0,0 +1,3 @@
+
+
+
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/score-distributions-chart/score-distribution-chart-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/score-distributions-chart/score-distribution-chart-component.jsx
index fba29d7f5..160a75d5f 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/score-distributions-chart/score-distribution-chart-component.jsx
+++ b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/score-distributions-chart/score-distribution-chart-component.jsx
@@ -15,6 +15,11 @@ import {
import COLORS from 'styles/settings';
+import Amphibians from 'images/amphibians.svg';
+import Birds from 'images/birds.svg';
+import Mammals from 'images/mammals.svg';
+import Reptiles from 'images/reptiles.svg';
+
import styles from './score-distribution-styles.module.scss';
ChartJS.register(
@@ -31,8 +36,10 @@ function ScoreDistributionChartComponent() {
const options = {
plugins: {
title: {
- display: true,
- text: 'Chart.js Bar Chart - Stacked',
+ display: false,
+ },
+ legend: {
+ display: false,
},
},
responsive: true,
@@ -43,35 +50,33 @@ function ScoreDistributionChartComponent() {
scales: {
x: {
stacked: true,
+ display: true,
+ title: {
+ display: true,
+ text: 'Protection Score',
+ color: COLORS['oslo-gray'],
+ },
+ grid: {
+ color: COLORS['oslo-gray'],
+ },
+ ticks: {
+ color: COLORS['oslo-gray'],
+ },
},
y: {
stacked: true,
- },
- },
- };
-
- const doughnutOptions = {
- cutout: '80%',
- radius: '100%',
- rotation: -90,
- responsive: true,
- circumference: 180,
- hoverOffset: 5,
- animation: {
- animateRotate: true,
- animateScale: false,
- },
- plugins: {
- legend: {
- display: false,
- },
- },
- layout: {
- padding: {
- left: 5,
- right: 5,
- top: 5,
- bottom: 5,
+ display: true,
+ title: {
+ display: true,
+ text: 'Number of Species',
+ color: COLORS['oslo-gray'],
+ },
+ grid: {
+ color: COLORS['oslo-gray'],
+ },
+ ticks: {
+ color: COLORS['oslo-gray'],
+ },
},
},
};
@@ -91,39 +96,57 @@ function ScoreDistributionChartComponent() {
datasets: [
{
label: 'Dataset 1',
- data: labels.map(() =>
- faker.datatype.number({ min: -1000, max: 1000 })
- ),
+ data: labels.map(() => faker.datatype.number({ min: 0, max: 250 })),
backgroundColor: COLORS.primary,
stack: 'Stack 0',
},
{
label: 'Dataset 2',
- data: labels.map(() =>
- faker.datatype.number({ min: -1000, max: 1000 })
- ),
+ data: labels.map(() => faker.datatype.number({ min: 0, max: 250 })),
backgroundColor: COLORS.tango,
stack: 'Stack 0',
},
{
label: 'Dataset 3',
- data: labels.map(() =>
- faker.datatype.number({ min: -1000, max: 1000 })
- ),
+ data: labels.map(() => faker.datatype.number({ min: 0, max: 250 })),
backgroundColor: COLORS['medium-purple'],
stack: 'Stack 0',
},
{
label: 'Dataset 4',
- data: labels.map(() =>
- faker.datatype.number({ min: -1000, max: 1000 })
- ),
+ data: labels.map(() => faker.datatype.number({ min: 0, max: 250 })),
backgroundColor: COLORS['french-rose'],
stack: 'Stack 0',
},
],
};
+ const doughnutOptions = {
+ cutout: '80%',
+ radius: '100%',
+ rotation: -90,
+ responsive: false,
+ circumference: 180,
+ hoverOffset: 5,
+ animation: {
+ animateRotate: true,
+ animateScale: false,
+ },
+ plugins: {
+ legend: {
+ display: false,
+ },
+ },
+ layout: {
+ padding: {
+ left: 5,
+ right: 5,
+ top: 5,
+ bottom: 5,
+ },
+ },
+ };
+
const birdData = {
labels: ['Birds', 'Remaining'],
datasets: [
@@ -183,49 +206,65 @@ function ScoreDistributionChartComponent() {
NATIONAL SPI BY TAXONOMIC GROUP
-
+
69.87
-
+
+
+
+
Species Richness:
+
1058 Birds
+
-
+
60.98
-
+
+
+
+
Species Richness:
+
498 Mammals
+
-
+
63.45
-
+
+
+
+
Species Richness:
+
362 Reptiles
+
-
+
49.02
-
+
+
+
+
Species Richness:
+
228 Amphibians
+
-
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/score-distributions-chart/score-distribution-styles.module.scss b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/score-distributions-chart/score-distribution-styles.module.scss
index 19b4a38ea..f06c9faa8 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/score-distributions-chart/score-distribution-styles.module.scss
+++ b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/score-distributions-chart/score-distribution-styles.module.scss
@@ -9,6 +9,7 @@
padding: 10px 26px;
flex-grow: 1;
align-items: center;
+ gap: 8px;
.title{
color: $white;
@@ -29,8 +30,7 @@
border-radius: 5px;
border: 1.5px solid $brand-color-main;
box-shadow: -2px 4px 4px 0px rgba(0, 0, 0, 0.25);
- padding-top: 15px;
- margin-top: 8px;
+ padding: 15px 0;
.spi{
display: flex;
@@ -48,10 +48,35 @@
line-height: normal;
margin-bottom: -20px;
}
+
+ .taxoGroup{
+ display: flex;
+ flex-direction: column;
+ margin-top: -60px;
+ align-items: center;
+
+ .richness{
+ color: #FFF;
+ text-align: center;
+ font-family: "Open Sans";
+ font-size: 11px;
+ font-style: italic;
+ font-weight: 400;
+ line-height: normal;
+ }
+
+ .score{
+ font-size: 16px;
+ font-weight: 600;
+ text-transform: uppercase;
+ margin-bottom: 0;
+ }
+ }
}
}
- .barChart{
+ .chart{
width: 100%;
+ margin-top: 25px;
}
}
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/temporal-trends-chart/temporal-trends-chart-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/temporal-trends-chart/temporal-trends-chart-component.jsx
index 9e1ddb605..a8af44d64 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/temporal-trends-chart/temporal-trends-chart-component.jsx
+++ b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/temporal-trends-chart/temporal-trends-chart-component.jsx
@@ -27,9 +27,44 @@ function TemporalTrendsChartComponent() {
];
const options = {
+ plugins: {
+ title: {
+ display: false,
+ },
+ legend: {
+ display: false,
+ },
+ },
scales: {
+ x: {
+ beginAtZero: false,
+ display: true,
+ title: {
+ display: true,
+ text: 'Total Area (1000 km2)',
+ color: COLORS['oslo-gray'],
+ },
+ grid: {
+ color: COLORS['oslo-gray'],
+ },
+ ticks: {
+ color: COLORS['oslo-gray'],
+ },
+ },
y: {
beginAtZero: true,
+ display: true,
+ title: {
+ display: true,
+ text: 'Species Protection Index',
+ color: COLORS['oslo-gray'],
+ },
+ grid: {
+ color: COLORS['oslo-gray'],
+ },
+ ticks: {
+ color: COLORS['oslo-gray'],
+ },
},
},
};
@@ -37,22 +72,40 @@ function TemporalTrendsChartComponent() {
const data = {
datasets: [
{
- label: 'Red dataset',
- data: Array.from({ length: 50 }, () => ({
- x: faker.datatype.number({ min: -100, max: 100 }),
- y: faker.datatype.number({ min: -100, max: 100 }),
+ label: 'Birds',
+ data: Array.from({ length: 5 }, () => ({
+ x: faker.datatype.number({ min: 0, max: 200 }),
+ y: faker.datatype.number({ min: 0, max: 100 }),
r: faker.datatype.number({ min: 5, max: 20 }),
})),
- backgroundColor: 'rgba(255, 99, 132, 0.5)',
+ backgroundColor: COLORS.primary,
},
{
- label: 'Blue dataset',
- data: Array.from({ length: 50 }, () => ({
- x: faker.datatype.number({ min: -100, max: 100 }),
- y: faker.datatype.number({ min: -100, max: 100 }),
+ label: 'Mammals',
+ data: Array.from({ length: 5 }, () => ({
+ x: faker.datatype.number({ min: 0, max: 200 }),
+ y: faker.datatype.number({ min: 0, max: 100 }),
r: faker.datatype.number({ min: 5, max: 20 }),
})),
- backgroundColor: 'rgba(53, 162, 235, 0.5)',
+ backgroundColor: COLORS.tango,
+ },
+ {
+ label: 'Reptiles',
+ data: Array.from({ length: 5 }, () => ({
+ x: faker.datatype.number({ min: 0, max: 200 }),
+ y: faker.datatype.number({ min: 0, max: 100 }),
+ r: faker.datatype.number({ min: 5, max: 20 }),
+ })),
+ backgroundColor: COLORS['medium-purple'],
+ },
+ {
+ label: 'Amphibians',
+ data: Array.from({ length: 5 }, () => ({
+ x: faker.datatype.number({ min: 0, max: 200 }),
+ y: faker.datatype.number({ min: 0, max: 100 }),
+ r: faker.datatype.number({ min: 5, max: 20 }),
+ })),
+ backgroundColor: COLORS['french-rose'],
},
],
};
@@ -61,7 +114,7 @@ function TemporalTrendsChartComponent() {
cutout: '80%',
radius: '100%',
rotation: -90,
- responsive: true,
+ responsive: false,
circumference: 180,
hoverOffset: 5,
animation: {
@@ -125,7 +178,12 @@ function TemporalTrendsChartComponent() {
Year
-
+
49
@@ -134,7 +192,9 @@ function TemporalTrendsChartComponent() {
-
+
+
+
);
}
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/temporal-trends-chart/temporal-trends-chart-styles.module.scss b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/temporal-trends-chart/temporal-trends-chart-styles.module.scss
index 3c7b36023..4f2b576fe 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/temporal-trends-chart/temporal-trends-chart-styles.module.scss
+++ b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/temporal-trends-chart/temporal-trends-chart-styles.module.scss
@@ -6,7 +6,8 @@
.container{
display: flex;
flex-direction: column;
- padding: 10px 26px;
+ padding: 10px 5px 10px 26px;
+ flex-grow: 1;
.info{
display: flex;
@@ -39,7 +40,11 @@
.arcChart{
display: flex;
height: 100px;
- align-items: flex-end;
+ align-items: center;
+ justify-content: space-evenly;
+ flex-grow: 1;
+ border-radius: 5px;
+ border: 1.5px solid $brand-color-main;
.spi{
display: flex;
@@ -55,7 +60,7 @@
font-style: normal;
font-weight: 700;
line-height: normal;
- margin-top: -20px;
+ margin-top: -25px;
}
}
@@ -85,4 +90,8 @@
}
}
}
+ .chart{
+ width: 100%;
+ margin-top: 25px;
+ }
}
From 2463c865c9b929d968aaba0c93b5cad71e46b15d Mon Sep 17 00:00:00 2001
From: Chris Manciero
Date: Mon, 24 Jun 2024 13:20:43 -0400
Subject: [PATCH 022/350] update styles
---
.../score-distribution-chart-component.jsx | 24 ++++++-------
.../temporal-trends-chart-component.jsx | 36 +++++++++++++------
.../temporal-trends-chart-styles.module.scss | 23 +++++-------
src/styles/settings.scss | 7 ++++
4 files changed, 54 insertions(+), 36 deletions(-)
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/score-distributions-chart/score-distribution-chart-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/score-distributions-chart/score-distribution-chart-component.jsx
index 160a75d5f..e7bb03a76 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/score-distributions-chart/score-distribution-chart-component.jsx
+++ b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/score-distributions-chart/score-distribution-chart-component.jsx
@@ -97,25 +97,25 @@ function ScoreDistributionChartComponent() {
{
label: 'Dataset 1',
data: labels.map(() => faker.datatype.number({ min: 0, max: 250 })),
- backgroundColor: COLORS.primary,
+ backgroundColor: COLORS.birds,
stack: 'Stack 0',
},
{
label: 'Dataset 2',
data: labels.map(() => faker.datatype.number({ min: 0, max: 250 })),
- backgroundColor: COLORS.tango,
+ backgroundColor: COLORS.mammals,
stack: 'Stack 0',
},
{
label: 'Dataset 3',
data: labels.map(() => faker.datatype.number({ min: 0, max: 250 })),
- backgroundColor: COLORS['medium-purple'],
+ backgroundColor: COLORS.reptiles,
stack: 'Stack 0',
},
{
label: 'Dataset 4',
data: labels.map(() => faker.datatype.number({ min: 0, max: 250 })),
- backgroundColor: COLORS['french-rose'],
+ backgroundColor: COLORS.amphibians,
stack: 'Stack 0',
},
],
@@ -153,8 +153,8 @@ function ScoreDistributionChartComponent() {
{
label: '',
data: [69.87, 30.13],
- backgroundColor: [COLORS.primary, COLORS['white-opacity-20']],
- borderColor: [COLORS.primary, COLORS['white-opacity-20']],
+ backgroundColor: [COLORS.birds, COLORS['white-opacity-20']],
+ borderColor: [COLORS.birds, COLORS['white-opacity-20']],
borderWidth: 1,
},
],
@@ -166,8 +166,8 @@ function ScoreDistributionChartComponent() {
{
label: '',
data: [60.98, 39.02],
- backgroundColor: [COLORS.tango, COLORS['white-opacity-20']],
- borderColor: [COLORS.tango, COLORS['white-opacity-20']],
+ backgroundColor: [COLORS.mammals, COLORS['white-opacity-20']],
+ borderColor: [COLORS.mammals, COLORS['white-opacity-20']],
borderWidth: 1,
},
],
@@ -179,8 +179,8 @@ function ScoreDistributionChartComponent() {
{
label: '',
data: [63.45, 36.55],
- backgroundColor: [COLORS['medium-purple'], COLORS['white-opacity-20']],
- borderColor: [COLORS['medium-purple'], COLORS['white-opacity-20']],
+ backgroundColor: [COLORS.reptiles, COLORS['white-opacity-20']],
+ borderColor: [COLORS.reptiles, COLORS['white-opacity-20']],
borderWidth: 1,
},
],
@@ -192,8 +192,8 @@ function ScoreDistributionChartComponent() {
{
label: '',
data: [49.02, 49.98],
- backgroundColor: [COLORS['french-rose'], COLORS['white-opacity-20']],
- borderColor: [COLORS['french-rose'], COLORS['white-opacity-20']],
+ backgroundColor: [COLORS.amphibians, COLORS['white-opacity-20']],
+ borderColor: [COLORS.amphibians, COLORS['white-opacity-20']],
borderWidth: 1,
},
],
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/temporal-trends-chart/temporal-trends-chart-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/temporal-trends-chart/temporal-trends-chart-component.jsx
index a8af44d64..6c6ae407f 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/temporal-trends-chart/temporal-trends-chart-component.jsx
+++ b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/temporal-trends-chart/temporal-trends-chart-component.jsx
@@ -78,7 +78,7 @@ function TemporalTrendsChartComponent() {
y: faker.datatype.number({ min: 0, max: 100 }),
r: faker.datatype.number({ min: 5, max: 20 }),
})),
- backgroundColor: COLORS.primary,
+ backgroundColor: COLORS.birds,
},
{
label: 'Mammals',
@@ -87,7 +87,7 @@ function TemporalTrendsChartComponent() {
y: faker.datatype.number({ min: 0, max: 100 }),
r: faker.datatype.number({ min: 5, max: 20 }),
})),
- backgroundColor: COLORS.tango,
+ backgroundColor: COLORS.mammals,
},
{
label: 'Reptiles',
@@ -96,7 +96,7 @@ function TemporalTrendsChartComponent() {
y: faker.datatype.number({ min: 0, max: 100 }),
r: faker.datatype.number({ min: 5, max: 20 }),
})),
- backgroundColor: COLORS['medium-purple'],
+ backgroundColor: COLORS.reptiles,
},
{
label: 'Amphibians',
@@ -105,7 +105,7 @@ function TemporalTrendsChartComponent() {
y: faker.datatype.number({ min: 0, max: 100 }),
r: faker.datatype.number({ min: 5, max: 20 }),
})),
- backgroundColor: COLORS['french-rose'],
+ backgroundColor: COLORS.amphibians,
},
],
};
@@ -141,9 +141,9 @@ function TemporalTrendsChartComponent() {
datasets: [
{
label: '',
- data: [49, 51],
- backgroundColor: [COLORS.primary, COLORS['white-opacity-20']],
- borderColor: [COLORS.primary, COLORS['white-opacity-20']],
+ data: [48.55, 51.45],
+ backgroundColor: [COLORS['temporal-spi'], COLORS['white-opacity-20']],
+ borderColor: [COLORS['temporal-spi'], COLORS['white-opacity-20']],
borderWidth: 1,
},
],
@@ -172,7 +172,23 @@ function TemporalTrendsChartComponent() {
#16 in size
-
+
+
2024
+
+
+ 48.55
+
+
19.58
+
Year
+
SPI
+
Area Protected
+
+ {/*
2024
Year
@@ -184,13 +200,13 @@ function TemporalTrendsChartComponent() {
width="125x"
height="75px"
/>
- 49
+ 48.55
19.58
Area Protected
-
+
*/}
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/temporal-trends-chart/temporal-trends-chart-styles.module.scss b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/temporal-trends-chart/temporal-trends-chart-styles.module.scss
index 4f2b576fe..1c184041c 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/temporal-trends-chart/temporal-trends-chart-styles.module.scss
+++ b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/temporal-trends-chart/temporal-trends-chart-styles.module.scss
@@ -37,14 +37,14 @@
}
}
- .arcChart{
- display: flex;
- height: 100px;
- align-items: center;
- justify-content: space-evenly;
- flex-grow: 1;
+ .arcGrid{
+ display: grid;
+ grid-template-columns: repeat(3, 1fr);
+ grid-template-rows: 70px 30px;
+ justify-items: center;
border-radius: 5px;
- border: 1.5px solid $brand-color-main;
+ height: 100px;
+ border: 1.5px solid #18bab4;
.spi{
display: flex;
@@ -60,15 +60,10 @@
font-style: normal;
font-weight: 700;
line-height: normal;
- margin-top: -25px;
+ margin-top: -35px;
}
}
- .stats{
- display: flex;
- flex-direction: column;
- align-items: center;
-
b {
color: #FFF;
font-family: "Open Sans";
@@ -76,6 +71,7 @@
font-style: normal;
font-weight: 600;
line-height: normal;
+ align-self: end;
}
span{
@@ -87,7 +83,6 @@
line-height: normal;
text-transform: uppercase;
}
- }
}
}
.chart{
diff --git a/src/styles/settings.scss b/src/styles/settings.scss
index 8a5d6edce..8454cf8c5 100644
--- a/src/styles/settings.scss
+++ b/src/styles/settings.scss
@@ -289,6 +289,13 @@ $desktop: 'screen and (min-width: #{$breakpoint-desktop})';
athens-gray: $athens-gray;
oslo-gray: $oslo-gray;
+ // TRENDS
+ birds: $birds-color;
+ mammals:$mammals-color;
+ reptiles:$reptiles-color;
+ amphibians: $amphibians-color;
+ temporal-spi: $regionalChecklist;
+
// Landcover legend
water: $water;
trees: $trees;
From a9a20ad809fe9ac2de6bdd5ba64c84022e7275ee Mon Sep 17 00:00:00 2001
From: Chris Manciero
Date: Mon, 24 Jun 2024 15:03:58 -0400
Subject: [PATCH 023/350] update styles
---
.../score-distribution-chart-component.jsx | 4 +--
.../temporal-trends-chart-component.jsx | 30 ++++++++++++++++---
2 files changed, 28 insertions(+), 6 deletions(-)
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/score-distributions-chart/score-distribution-chart-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/score-distributions-chart/score-distribution-chart-component.jsx
index e7bb03a76..3b2ea3877 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/score-distributions-chart/score-distribution-chart-component.jsx
+++ b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/score-distributions-chart/score-distribution-chart-component.jsx
@@ -54,7 +54,7 @@ function ScoreDistributionChartComponent() {
title: {
display: true,
text: 'Protection Score',
- color: COLORS['oslo-gray'],
+ color: COLORS.white,
},
grid: {
color: COLORS['oslo-gray'],
@@ -69,7 +69,7 @@ function ScoreDistributionChartComponent() {
title: {
display: true,
text: 'Number of Species',
- color: COLORS['oslo-gray'],
+ color: COLORS.white,
},
grid: {
color: COLORS['oslo-gray'],
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/temporal-trends-chart/temporal-trends-chart-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/temporal-trends-chart/temporal-trends-chart-component.jsx
index 6c6ae407f..812d9ddee 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/temporal-trends-chart/temporal-trends-chart-component.jsx
+++ b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/temporal-trends-chart/temporal-trends-chart-component.jsx
@@ -20,10 +20,32 @@ ChartJS.register(LinearScale, ArcElement, PointElement, Tooltip, Legend);
function TemporalTrendsChartComponent() {
const provinces = [
- { value: 'Mai-Ndombe', label: 'Mai-Ndombe' },
+ { value: 'Bas-Uélé', label: 'Bas-Uélé' },
+ { value: 'Haut-Uélé', label: 'Haut-Uélé' },
+ { value: 'Ituri', label: 'Ituri' },
+ { value: 'Bas-Congo', label: 'Bas-Congo' },
{ value: 'Équateur', label: 'Équateur' },
- { value: 'Kasaï', label: 'Kasaï' },
+ { value: 'Haut-Lomami', label: 'Haut-Lomami' },
+ { value: 'Haut-Katanga', label: 'Haut-Katanga' },
+ { value: 'Haut-Kasaï', label: 'Haut-Kasaï' },
+ { value: 'Kwango', label: 'Kwango' },
+ { value: 'Kwilu', label: 'Kwilu' },
+ { value: 'Lomami', label: 'Lomami' },
+ { value: 'Lualaba', label: 'Lualaba' },
+ { value: 'Mai-Ndombe', label: 'Mai-Ndombe' },
+ { value: 'Maniema', label: 'Maniema' },
+ { value: 'Mongala', label: 'Mongala' },
+ { value: 'Nord-Kivu', label: 'Nord-Kivu' },
+ { value: 'Nord-Ubangi', label: 'Nord-Ubangi' },
{ value: 'Sankuru', label: 'Sankuru' },
+ { value: 'Sud-Kivu', label: 'Sud-Kivu' },
+ { value: 'Sud-Ubangi', label: 'Sud-Ubangi' },
+ { value: 'Tanganyika', label: 'Tanganyika' },
+ { value: 'Tshopo', label: 'Tshopo' },
+ { value: 'Tshuapa', label: 'Tshuapa' },
+ { value: 'Kinshasa', label: 'Kinshasa' },
+ { value: 'Kasaï Central', label: 'Kasaï Central' },
+ { value: 'Kasaï Oriental', label: 'Kasaï Oriental' },
];
const options = {
@@ -42,7 +64,7 @@ function TemporalTrendsChartComponent() {
title: {
display: true,
text: 'Total Area (1000 km2)',
- color: COLORS['oslo-gray'],
+ color: COLORS.white,
},
grid: {
color: COLORS['oslo-gray'],
@@ -57,7 +79,7 @@ function TemporalTrendsChartComponent() {
title: {
display: true,
text: 'Species Protection Index',
- color: COLORS['oslo-gray'],
+ color: COLORS.white,
},
grid: {
color: COLORS['oslo-gray'],
From 7f083b96b7f36863d475ebea17ca37468c27b637 Mon Sep 17 00:00:00 2001
From: Chris Manciero
Date: Thu, 27 Jun 2024 19:34:01 -0400
Subject: [PATCH 024/350] update score distributions and added arc chart
---
src/components/charts/spi-arc-chart/index.js | 3 +
.../spi-arc-chart/spi-arc-chart-component.jsx | 97 +++++++++
.../spi-arc-chart-styles.module.scss | 57 +++++
.../dashboard-trends-sidebar-component.jsx | 11 +-
...ashboard-trends-sidebar-styles.module.scss | 72 ++++++-
.../score-distribution-chart-component.jsx | 195 +++++++++---------
...ore-distribution-chart-styles.module.scss} | 2 +-
.../score-distributions-component.jsx | 51 ++++-
.../temporal-trends-chart-component.jsx | 119 +++++------
.../dashboard-trends-view-component.jsx | 26 ++-
10 files changed, 460 insertions(+), 173 deletions(-)
create mode 100644 src/components/charts/spi-arc-chart/index.js
create mode 100644 src/components/charts/spi-arc-chart/spi-arc-chart-component.jsx
create mode 100644 src/components/charts/spi-arc-chart/spi-arc-chart-styles.module.scss
rename src/containers/sidebars/dashboard-trends-sidebar/score-distributions/score-distributions-chart/{score-distribution-styles.module.scss => score-distribution-chart-styles.module.scss} (98%)
diff --git a/src/components/charts/spi-arc-chart/index.js b/src/components/charts/spi-arc-chart/index.js
new file mode 100644
index 000000000..8db701c31
--- /dev/null
+++ b/src/components/charts/spi-arc-chart/index.js
@@ -0,0 +1,3 @@
+import Component from './spi-arc-chart-component';
+
+export default Component;
diff --git a/src/components/charts/spi-arc-chart/spi-arc-chart-component.jsx b/src/components/charts/spi-arc-chart/spi-arc-chart-component.jsx
new file mode 100644
index 000000000..64f9447f1
--- /dev/null
+++ b/src/components/charts/spi-arc-chart/spi-arc-chart-component.jsx
@@ -0,0 +1,97 @@
+import React, { useEffect, useState } from 'react';
+import { Doughnut } from 'react-chartjs-2';
+
+import {
+ Chart as ChartJS,
+ CategoryScale,
+ LinearScale,
+ ArcElement,
+ Title,
+ Tooltip,
+ Legend,
+} from 'chart.js';
+
+import styles from './spi-arc-chart-styles.module.scss';
+
+ChartJS.register(
+ CategoryScale,
+ LinearScale,
+ ArcElement,
+ Title,
+ Tooltip,
+ Legend
+);
+
+function SpiArcChartComponent(props) {
+ const { scores, width, height, data, img, species, value } = props;
+
+ const [score, setScore] = useState(0);
+
+ const doughnutOptions = {
+ cutout: '80%',
+ radius: '100%',
+ rotation: -90,
+ responsive: false,
+ circumference: 180,
+ hoverOffset: 5,
+ animation: {
+ animateRotate: true,
+ animateScale: false,
+ },
+ plugins: {
+ legend: {
+ display: false,
+ },
+ },
+ layout: {
+ padding: {
+ left: 5,
+ right: 5,
+ top: 5,
+ bottom: 5,
+ },
+ },
+ };
+
+ const arcChartHeight = height || 100;
+ const arcChartWidth = width || 120;
+
+ const getPercentage = () => {
+ const { count, total } = scores[species];
+ const percent = (count / total) * 100 || 0;
+ return [percent, 100 - percent];
+ };
+
+ useEffect(() => {
+ if (value) {
+ setScore(value.toFixed(2));
+ }
+ }, [value]);
+
+ return (
+
+ {scores && (
+
{getPercentage()[0].toFixed(2)}
+ )}
+
+
+ {scores && (
+
+
+
Species Richness:
+
+ {scores[species].total} {species}
+
+
+ )}
+ {!scores &&
{score}
}
+
+ );
+}
+
+export default SpiArcChartComponent;
diff --git a/src/components/charts/spi-arc-chart/spi-arc-chart-styles.module.scss b/src/components/charts/spi-arc-chart/spi-arc-chart-styles.module.scss
new file mode 100644
index 000000000..dd4a45594
--- /dev/null
+++ b/src/components/charts/spi-arc-chart/spi-arc-chart-styles.module.scss
@@ -0,0 +1,57 @@
+@import 'styles/ui.module';
+@import 'styles/settings';
+@import 'styles/typography-extends';
+@import 'styles/common-animations.module';
+
+.spi{
+ display: flex;
+ flex-direction: column;
+ justify-content: center;
+ align-items: center;
+
+ .score{
+ color: $white;
+ text-align: center;
+ font-family: "Open Sans";
+ font-size: 20px;
+ font-style: normal;
+ font-weight: 700;
+ line-height: normal;
+ margin-bottom: -20px;
+ }
+
+ .globalScore{
+ color: #FFF;
+ text-align: center;
+ font-family: "Open Sans";
+ font-size: 20px;
+ font-style: normal;
+ font-weight: 700;
+ line-height: normal;
+ margin-top: -35px;
+ }
+
+ .taxoGroup{
+ display: flex;
+ flex-direction: column;
+ margin-top: -60px;
+ align-items: center;
+
+ .richness{
+ color: $white;
+ text-align: center;
+ font-family: "Open Sans";
+ font-size: 11px;
+ font-style: italic;
+ font-weight: 400;
+ line-height: normal;
+ }
+
+ .score{
+ font-size: 16px;
+ font-weight: 600;
+ text-transform: uppercase;
+ margin-bottom: 0;
+ }
+ }
+}
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/dashboard-trends-sidebar-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/dashboard-trends-sidebar-component.jsx
index 7ddde0818..7df895633 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/dashboard-trends-sidebar-component.jsx
+++ b/src/containers/sidebars/dashboard-trends-sidebar/dashboard-trends-sidebar-component.jsx
@@ -5,16 +5,15 @@ import ScoreDistributionsContainer from './score-distributions';
import TemporalTrendsContainer from './temporal-trends';
function DashboardTrendsSidebar(props) {
- const { activeLayers, map, view } = props;
+ const { countryISO, countryData } = props;
return (
-
+
-
);
}
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/dashboard-trends-sidebar-styles.module.scss b/src/containers/sidebars/dashboard-trends-sidebar/dashboard-trends-sidebar-styles.module.scss
index 030bb1764..f4f7a3104 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/dashboard-trends-sidebar-styles.module.scss
+++ b/src/containers/sidebars/dashboard-trends-sidebar/dashboard-trends-sidebar-styles.module.scss
@@ -48,6 +48,76 @@ $info-width: 310px;
font-size: 14px;
}
+ .spsSpeciesTitle{
+ color: $white;
+ font-family: "Open Sans";
+ font-size: 15px;
+ font-style: normal;
+ font-weight: 400;
+ line-height: normal;
+ text-decoration: underline;
+ }
+
+ .spsSpecies{
+ list-style: none;
+ margin: 0;
+ padding: 0;
+ color: $white;
+
+ li{
+ display: flex;
+ gap: 12px;
+ margin: 6px 0;
+
+ .spsInfo{
+ display: flex;
+ flex-direction: column;
+ flex-grow: 1;
+
+ .name{
+ color: $white;
+ font-family: "Open Sans";
+ font-size: 12px;
+ font-style: normal;
+ font-weight: 600;
+ line-height: normal;
+ }
+
+ .scientificname{
+ color: $white;
+ font-family: "Open Sans";
+ font-size: 11px;
+ font-style: italic;
+ font-weight: 400;
+ line-height: normal;
+ flex-grow: 1;
+ }
+
+ .addToMap{
+ color: $white;
+ font-family: "Roboto Mono";
+ font-size: 9px;
+ font-style: normal;
+ font-weight: 300;
+ line-height: normal;
+ text-transform: uppercase;
+ width: fit-content;
+ padding: 0;
+ text-decoration: underline;
+ }
+ }
+
+ .spsScore{
+ color: $white;
+ font-family: "Open Sans";
+ font-size: 14px;
+ font-style: normal;
+ font-weight: 700;
+ line-height: normal;
+ }
+ }
+ }
+
.options{
display: flex;
flex-direction: column;
@@ -63,7 +133,7 @@ $info-width: 310px;
}
.helpText{
- color: #FFF;
+ color: $white;
font-family: "Open Sans";
font-size: 9px;
font-style: italic;
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/score-distributions-chart/score-distribution-chart-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/score-distributions-chart/score-distribution-chart-component.jsx
index 3b2ea3877..9ff71201c 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/score-distributions-chart/score-distribution-chart-component.jsx
+++ b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/score-distributions-chart/score-distribution-chart-component.jsx
@@ -1,5 +1,6 @@
-import React from 'react';
-import { Bar, Doughnut } from 'react-chartjs-2';
+/* eslint-disable camelcase */
+import React, { useEffect, useState } from 'react';
+import { Bar } from 'react-chartjs-2';
import { faker } from '@faker-js/faker';
import {
@@ -13,6 +14,8 @@ import {
Legend,
} from 'chart.js';
+import SpiArcChartComponent from 'components/charts/spi-arc-chart/spi-arc-chart-component';
+
import COLORS from 'styles/settings';
import Amphibians from 'images/amphibians.svg';
@@ -20,7 +23,7 @@ import Birds from 'images/birds.svg';
import Mammals from 'images/mammals.svg';
import Reptiles from 'images/reptiles.svg';
-import styles from './score-distribution-styles.module.scss';
+import styles from './score-distribution-chart-styles.module.scss';
ChartJS.register(
CategoryScale,
@@ -32,7 +35,71 @@ ChartJS.register(
Legend
);
-function ScoreDistributionChartComponent() {
+function ScoreDistributionChartComponent(props) {
+ const { countryData } = props;
+ const [scores, setScores] = useState({
+ birds: {
+ count: 0,
+ total: 0,
+ percentage: 0,
+ },
+ mammals: {
+ count: 0,
+ total: 0,
+ percentage: 0,
+ },
+ reptiles: {
+ count: 0,
+ total: 0,
+ percentage: 0,
+ },
+ amphibians: {
+ count: 0,
+ total: 0,
+ percentage: 0,
+ },
+ });
+
+ const getPercentage = (species) => {
+ const { count, total } = scores[species];
+ const percent = (count / total) * 100 || 0;
+ return [percent, 100 - percent];
+ };
+
+ useEffect(() => {
+ if (countryData) {
+ const {
+ endemic_birds,
+ birds,
+ endemic_mammals,
+ mammals,
+ endemic_reptiles,
+ reptiles,
+ endemic_amphibians,
+ amphibians,
+ } = countryData;
+
+ setScores({
+ birds: {
+ count: endemic_birds,
+ total: birds,
+ },
+ mammals: {
+ count: endemic_mammals,
+ total: mammals,
+ },
+ reptiles: {
+ count: endemic_reptiles,
+ total: reptiles,
+ },
+ amphibians: {
+ count: endemic_amphibians,
+ total: amphibians,
+ },
+ });
+ }
+ }, [countryData]);
+
const options = {
plugins: {
title: {
@@ -121,38 +188,12 @@ function ScoreDistributionChartComponent() {
],
};
- const doughnutOptions = {
- cutout: '80%',
- radius: '100%',
- rotation: -90,
- responsive: false,
- circumference: 180,
- hoverOffset: 5,
- animation: {
- animateRotate: true,
- animateScale: false,
- },
- plugins: {
- legend: {
- display: false,
- },
- },
- layout: {
- padding: {
- left: 5,
- right: 5,
- top: 5,
- bottom: 5,
- },
- },
- };
-
const birdData = {
labels: ['Birds', 'Remaining'],
datasets: [
{
label: '',
- data: [69.87, 30.13],
+ data: getPercentage('birds'),
backgroundColor: [COLORS.birds, COLORS['white-opacity-20']],
borderColor: [COLORS.birds, COLORS['white-opacity-20']],
borderWidth: 1,
@@ -165,7 +206,7 @@ function ScoreDistributionChartComponent() {
datasets: [
{
label: '',
- data: [60.98, 39.02],
+ data: getPercentage('mammals'),
backgroundColor: [COLORS.mammals, COLORS['white-opacity-20']],
borderColor: [COLORS.mammals, COLORS['white-opacity-20']],
borderWidth: 1,
@@ -178,7 +219,7 @@ function ScoreDistributionChartComponent() {
datasets: [
{
label: '',
- data: [63.45, 36.55],
+ data: getPercentage('reptiles'),
backgroundColor: [COLORS.reptiles, COLORS['white-opacity-20']],
borderColor: [COLORS.reptiles, COLORS['white-opacity-20']],
borderWidth: 1,
@@ -191,7 +232,7 @@ function ScoreDistributionChartComponent() {
datasets: [
{
label: '',
- data: [49.02, 49.98],
+ data: getPercentage('amphibians'),
backgroundColor: [COLORS.amphibians, COLORS['white-opacity-20']],
borderColor: [COLORS.amphibians, COLORS['white-opacity-20']],
borderWidth: 1,
@@ -199,69 +240,37 @@ function ScoreDistributionChartComponent() {
],
};
- const areaChartHeight = 100;
- const areaChartWidth = 120;
-
return (
NATIONAL SPI BY TAXONOMIC GROUP
-
-
69.87
-
-
-
-
Species Richness:
-
1058 Birds
-
-
-
-
60.98
-
-
-
-
Species Richness:
-
498 Mammals
-
-
-
-
63.45
-
-
-
-
Species Richness:
-
362 Reptiles
-
-
-
-
49.02
-
-
-
-
Species Richness:
-
228 Amphibians
-
-
+
+
+
+
+
+
+
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/score-distributions-chart/score-distribution-styles.module.scss b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/score-distributions-chart/score-distribution-chart-styles.module.scss
similarity index 98%
rename from src/containers/sidebars/dashboard-trends-sidebar/score-distributions/score-distributions-chart/score-distribution-styles.module.scss
rename to src/containers/sidebars/dashboard-trends-sidebar/score-distributions/score-distributions-chart/score-distribution-chart-styles.module.scss
index f06c9faa8..8b31c12e8 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/score-distributions-chart/score-distribution-styles.module.scss
+++ b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/score-distributions-chart/score-distribution-chart-styles.module.scss
@@ -6,7 +6,7 @@
.container{
display: flex;
flex-direction: column;
- padding: 10px 26px;
+ padding: 10px 5px 10px 26px;
flex-grow: 1;
align-items: center;
gap: 8px;
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/score-distributions-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/score-distributions-component.jsx
index c2d307e1d..85f4b39c5 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/score-distributions-component.jsx
+++ b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/score-distributions-component.jsx
@@ -7,6 +7,30 @@ import styles from '../dashboard-trends-sidebar-styles.module.scss';
import ScoreDistributionChartContainer from './score-distributions-chart';
function ScoreDistributionsComponent(props) {
+ const lowAvg = 'Amphibians';
+ const highAvg = 'birds';
+
+ // const value = 0.56;
+
+ const spsSpecies = [
+ {
+ name: 'Black-collared Apalis',
+ scientificname: 'Oreolais puncher',
+ },
+ {
+ name: 'Lomami Red Colobus',
+ scientificname: 'Piliocolobus parmentieri',
+ },
+ {
+ name: 'Grey-Winged Robin-Chat',
+ scientificname: 'Cossypha polioptera',
+ },
+ {
+ name: 'Palm Egg-Eater',
+ scientificname: 'Dasypeltis palmarum',
+ },
+ ];
+
return (
@@ -14,9 +38,32 @@ function ScoreDistributionsComponent(props) {
View the distribution of the individual Species Protection Scores for
- all terrestrial vertebrates. Amphibians have the lowest average
- protection score while birds have the highest.
+ all terrestrial vertebrates. {lowAvg} have the lowest average
+ protection score while {highAvg} have the highest.
+
+
+ Species with SPS between 0.5:
+
+
{
+ if (countryData) {
+ const spi = {
+ labels: ['Global SPI', 'Remaining'],
+ datasets: [
+ {
+ label: '',
+ data: [
+ countryData.Global_SPI_ter,
+ 100 - countryData.Global_SPI_ter,
+ ],
+ backgroundColor: [
+ COLORS['temporal-spi'],
+ COLORS['white-opacity-20'],
+ ],
+ borderColor: [COLORS['temporal-spi'], COLORS['white-opacity-20']],
+ borderWidth: 1,
+ },
+ ],
+ };
- const birdData = {
- labels: ['Birds', 'Remaining'],
- datasets: [
- {
- label: '',
- data: [48.55, 51.45],
- backgroundColor: [COLORS['temporal-spi'], COLORS['white-opacity-20']],
- borderColor: [COLORS['temporal-spi'], COLORS['white-opacity-20']],
- borderWidth: 1,
- },
- ],
- };
+ setSpiData(spi);
+ }
+ }, [countryData]);
return (
@@ -196,39 +199,17 @@ function TemporalTrendsChartComponent() {
2024
-
-
- 48.55
-
-
19.58
+
+
{countryData?.prop_protected_ter}
Year
SPI
Area Protected
- {/*
-
- 2024
- Year
-
-
-
- 48.55
-
-
- 19.58
- Area Protected
-
-
*/}
diff --git a/src/containers/views/dashboard-trends-view/dashboard-trends-view-component.jsx b/src/containers/views/dashboard-trends-view/dashboard-trends-view-component.jsx
index 0b260fa68..5894efcce 100644
--- a/src/containers/views/dashboard-trends-view/dashboard-trends-view-component.jsx
+++ b/src/containers/views/dashboard-trends-view/dashboard-trends-view-component.jsx
@@ -33,22 +33,44 @@ function DashboardTrendsViewComponent(props) {
const [map, setMap] = useState(null);
const [view, setView] = useState(null);
const [geo, setGeo] = useState(null);
+ const [countryData, setCountryData] = useState(null);
+ const url =
+ 'https://services9.arcgis.com/IkktFdUAcY3WrH25/arcgis/rest/services/SPI_Terrestrial_202403/FeatureServer/0';
+
+ // find and zoom to region
useEffect(() => {
EsriFeatureService.getFeatures({
url: COUNTRIES_DATA_SERVICE_URL,
whereClause: `GID_0 = '${countryISO}'`,
returnGeometry: true,
}).then((features) => {
- const { geometry } = features[0];
+ const { geometry, attributes } = features[0];
+ console.log(features);
if (geometry && view) {
view.center = [geometry.longitude, geometry.latitude];
setGeo(geometry);
+ setCountryData(attributes);
+ console.log(attributes);
}
});
}, [view, countryISO]);
+ // SPI layer
+ useEffect(() => {
+ EsriFeatureService.getFeatures({
+ url,
+ whereClause: `GID_0 = '${countryISO}'`,
+ returnGeometry: true,
+ }).then((features) => {
+ if (map) {
+ const { layer } = features[0];
+ map.add(layer);
+ }
+ });
+ }, [map, view]);
+
return (
Date: Fri, 28 Jun 2024 11:36:24 -0400
Subject: [PATCH 025/350] update position styles
---
src/components/map-view/index.js | 14 ++++++++------
.../score-distributions-component.jsx | 2 +-
.../dashboard-trends-view-config.js | 2 +-
.../dashboard-trends/dashboard-trends-selectors.js | 2 +-
4 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/src/components/map-view/index.js b/src/components/map-view/index.js
index 640f58857..0907a108f 100644
--- a/src/components/map-view/index.js
+++ b/src/components/map-view/index.js
@@ -51,6 +51,8 @@ function ViewContainer(props) {
flatView.goTo(
{
target: zoomGeometry,
+ center: [zoomGeometry.longitude - 15, zoomGeometry.latitude],
+ zoom: 5.5,
extent: feature.geometry.clone(),
},
{ duration: 1000 }
@@ -136,12 +138,12 @@ function ViewContainer(props) {
});
// flatView.on('click', async (event) => {
- // // const query = {
- // // geometry: flatView.toMap(event),
- // // returnGeometry: true,
- // // outFields: ['*'],
- // // };
- // // await highlightCountry(query, query.geometry, flatView);
+ // const query = {
+ // geometry: flatView.toMap(event),
+ // returnGeometry: true,
+ // outFields: ['*'],
+ // };
+ // await highlightCountry(query, query.geometry, flatView);
// });
setView(flatView);
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/score-distributions-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/score-distributions-component.jsx
index 85f4b39c5..c1d0afcc9 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/score-distributions-component.jsx
+++ b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/score-distributions-component.jsx
@@ -48,7 +48,7 @@ function ScoreDistributionsComponent(props) {
{spsSpecies.map((species) => {
return (
-
+
{species.name}
diff --git a/src/containers/views/dashboard-trends-view/dashboard-trends-view-config.js b/src/containers/views/dashboard-trends-view/dashboard-trends-view-config.js
index d707ee476..bffe19465 100644
--- a/src/containers/views/dashboard-trends-view/dashboard-trends-view-config.js
+++ b/src/containers/views/dashboard-trends-view/dashboard-trends-view-config.js
@@ -20,7 +20,7 @@ export default {
{ title: ADMIN_AREAS_FEATURE_LAYER },
],
padding: {
- left: 300,
+ left: 0,
},
environment: {
atmosphereEnabled: false,
diff --git a/src/pages/dashboard-trends/dashboard-trends-selectors.js b/src/pages/dashboard-trends/dashboard-trends-selectors.js
index a323842db..74f7df53e 100644
--- a/src/pages/dashboard-trends/dashboard-trends-selectors.js
+++ b/src/pages/dashboard-trends/dashboard-trends-selectors.js
@@ -7,7 +7,7 @@ import {
selectUiUrlState,
} from 'selectors/location-selectors';
-import dashboardViewConfig from '../../containers/views/dashboard-view/dashboard-view-config';
+import dashboardViewConfig from '../../containers/views/dashboard-trends-view/dashboard-trends-view-config';
const selectCountryIso = ({ location }) => location.payload.iso.toUpperCase();
From 5569d8de8ce0823d19a1fcab55083ffa3015320e Mon Sep 17 00:00:00 2001
From: Chris Manciero
Date: Mon, 8 Jul 2024 09:16:11 -0400
Subject: [PATCH 026/350] national trends changes
---
.../dashboard-trends-sidebar-component.jsx | 18 +-
...ashboard-trends-sidebar-styles.module.scss | 19 +-
.../score-distribution-chart-component.jsx | 1 +
.../score-distributions-component.jsx | 5 +-
.../temporal-trends-chart/index.js | 9 -
.../temporal-trends-component.jsx | 67 +++++--
.../temporal-trends-national-chart/index.js | 9 +
...mporal-trends-national-chart-component.jsx | 163 ++++++++++++++++++
...l-trends-national-chart-styles.module.scss | 93 ++++++++++
.../temporal-trends-province-chart/index.js | 9 +
...poral-trends-province-chart-component.jsx} | 6 +-
...-trends-province-chart-styles.module.scss} | 0
12 files changed, 371 insertions(+), 28 deletions(-)
delete mode 100644 src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/temporal-trends-chart/index.js
create mode 100644 src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/temporal-trends-national-chart/index.js
create mode 100644 src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/temporal-trends-national-chart/temporal-trends-national-chart-component.jsx
create mode 100644 src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/temporal-trends-national-chart/temporal-trends-national-chart-styles.module.scss
create mode 100644 src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/temporal-trends-province-chart/index.js
rename src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/{temporal-trends-chart/temporal-trends-chart-component.jsx => temporal-trends-province-chart/temporal-trends-province-chart-component.jsx} (97%)
rename src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/{temporal-trends-chart/temporal-trends-chart-styles.module.scss => temporal-trends-province-chart/temporal-trends-province-chart-styles.module.scss} (100%)
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/dashboard-trends-sidebar-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/dashboard-trends-sidebar-component.jsx
index 7df895633..34df49e10 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/dashboard-trends-sidebar-component.jsx
+++ b/src/containers/sidebars/dashboard-trends-sidebar/dashboard-trends-sidebar-component.jsx
@@ -1,18 +1,32 @@
-import React from 'react';
+import React, { useState } from 'react';
import styles from './dashboard-trends-sidebar-styles.module.scss';
import ScoreDistributionsContainer from './score-distributions';
import TemporalTrendsContainer from './temporal-trends';
+export const NATIONAL_TREND = 'NATIONAL';
+export const PROVINCE_TREND = 'PROVINCE';
+
function DashboardTrendsSidebar(props) {
const { countryISO, countryData } = props;
+ const [activeTrend, setActiveTrend] = useState(NATIONAL_TREND);
+
+ const handleActiveTrendUpdate = (trend) => {
+ setActiveTrend(trend);
+ };
+
return (
-
+
);
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/dashboard-trends-sidebar-styles.module.scss b/src/containers/sidebars/dashboard-trends-sidebar/dashboard-trends-sidebar-styles.module.scss
index f4f7a3104..b5cdedb2e 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/dashboard-trends-sidebar-styles.module.scss
+++ b/src/containers/sidebars/dashboard-trends-sidebar/dashboard-trends-sidebar-styles.module.scss
@@ -55,7 +55,6 @@ $info-width: 310px;
font-style: normal;
font-weight: 400;
line-height: normal;
- text-decoration: underline;
}
.spsSpecies{
@@ -124,6 +123,18 @@ $info-width: 310px;
row-gap: 8px;
margin-top: 10px;
+ .trendTypes{
+ display: flex;
+ gap: 3px;
+ padding: 2px;
+ border: 1px solid $brand-color-main;
+ border-radius: 5px;
+
+ .saveButton{
+ border: none;
+ }
+ }
+
.saveButton {
color: $dark-text;
background-color: $brand-color-main;
@@ -132,6 +143,12 @@ $info-width: 310px;
}
}
+ .notActive{
+ background-color: transparent;
+ color: $white;
+ border: 1px solid $brand-color-main;
+ }
+
.helpText{
color: $white;
font-family: "Open Sans";
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/score-distributions-chart/score-distribution-chart-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/score-distributions-chart/score-distribution-chart-component.jsx
index 9ff71201c..80c31020a 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/score-distributions-chart/score-distribution-chart-component.jsx
+++ b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/score-distributions-chart/score-distribution-chart-component.jsx
@@ -125,6 +125,7 @@ function ScoreDistributionChartComponent(props) {
},
grid: {
color: COLORS['oslo-gray'],
+ display: false,
},
ticks: {
color: COLORS['oslo-gray'],
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/score-distributions-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/score-distributions-component.jsx
index c1d0afcc9..5ee216777 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/score-distributions-component.jsx
+++ b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/score-distributions-component.jsx
@@ -1,5 +1,7 @@
import React from 'react';
+import cx from 'classnames';
+
import Button from 'components/button';
import styles from '../dashboard-trends-sidebar-styles.module.scss';
@@ -45,6 +47,7 @@ function ScoreDistributionsComponent(props) {
Species with SPS between 0.5:
+
);
}
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/index.js b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/index.js
index d42b387fb..bfa07ecdf 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/index.js
+++ b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/index.js
@@ -1,9 +1,20 @@
import React from 'react';
-import TemporalTrendsComponent from './temporal-trends-component';
+import TemporalTrendsShiComponent from './shi/temporal-trends-shi-component';
+import TemporalTrendsSpiComponent from './spi/temporal-trends-spi-component';
+import TemporalTrendsSiiComponent from './sii/temporal-trends-sii-component';
function TemporalTrendsContainer(props) {
- return ;
+ const {selectedIndex} = props;
+
+ if(selectedIndex === 1){
+ return
+ } else if (selectedIndex === 2){
+ return
+ } else if (selectedIndex === 3){
+ return
+ }
+ return ;
}
export default TemporalTrendsContainer;
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/shi/national-chart/index.js b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/shi/national-chart/index.js
new file mode 100644
index 000000000..06e126933
--- /dev/null
+++ b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/shi/national-chart/index.js
@@ -0,0 +1,9 @@
+import React from 'react';
+
+import NationalChartComponent from './national-chart-component';
+
+function NationalChartContainer(props) {
+ return ;
+}
+
+export default NationalChartContainer;
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/shi/national-chart/national-chart-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/shi/national-chart/national-chart-component.jsx
new file mode 100644
index 000000000..1be02f6b9
--- /dev/null
+++ b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/shi/national-chart/national-chart-component.jsx
@@ -0,0 +1,183 @@
+import React, { useEffect, useState } from 'react';
+import { Line } from 'react-chartjs-2';
+
+import {
+ Chart as ChartJS,
+ LinearScale,
+ PointElement,
+ LineElement,
+ Tooltip,
+ Legend,
+} from 'chart.js';
+
+import SpiArcChartComponent from 'components/charts/spi-arc-chart/spi-arc-chart-component';
+
+import { getCSSVariable } from 'utils/css-utils';
+
+import styles from './national-chart-styles.module.scss';
+
+ChartJS.register(LinearScale, LineElement, PointElement, Tooltip, Legend);
+
+function NationalChartComponent(props) {
+ const { countryData, nationalChartData } = props;
+ const [data, setData] = useState();
+ const [areaProtected, setAreaProtected] = useState(0);
+ const [spiValue, setSpiValue] = useState(0);
+
+ const blankData = {
+ labels: ['Global SPI', 'Remaining'],
+ datasets: [
+ {
+ label: '',
+ data: [0, 0],
+ backgroundColor: [getCSSVariable('temporal-spi'), getCSSVariable('white-opacity-20')],
+ borderColor: [getCSSVariable('temporal-spi'), getCSSVariable('white-opacity-20')],
+ borderWidth: 1,
+ },
+ ],
+ };
+ const [spiData, setSpiData] = useState(blankData);
+
+ const options = {
+ plugins: {
+ title: {
+ display: false,
+ },
+ legend: {
+ display: false,
+ },
+ },
+ scales: {
+ x: {
+ beginAtZero: false,
+ display: true,
+ title: {
+ display: true,
+ text: 'Year',
+ color: getCSSVariable('white'),
+ },
+ grid: {
+ color: getCSSVariable('oslo-gray'),
+ },
+ ticks: {
+ color: getCSSVariable('oslo-gray'),
+ },
+ },
+ y: {
+ beginAtZero: true,
+ display: true,
+ title: {
+ display: true,
+ text: 'Species Habitat Index',
+ color: getCSSVariable('white'),
+ },
+ grid: {
+ color: getCSSVariable('oslo-gray'),
+ },
+ ticks: {
+ color: getCSSVariable('oslo-gray'),
+ },
+ },
+ },
+ };
+
+ // useEffect(() => {
+ // console.log(countryData)
+ // if (countryData) {
+ // const spi = {
+ // labels: ['Global SPI', 'Remaining'],
+ // datasets: [
+ // {
+ // label: '',
+ // data: [
+ // countryData.Global_SPI_ter,
+ // 100 - countryData.Global_SPI_ter,
+ // ],
+ // backgroundColor: [
+ // getCSSVariable('temporal-spi'),
+ // getCSSVariable('white-opacity-20'),
+ // ],
+ // borderColor: [getCSSVariable('temporal-spi'), getCSSVariable('white-opacity-20')],
+ // borderWidth: 1,
+ // },
+ // ],
+ // };
+
+ // setSpiData(spi);
+ // }
+ // }, [countryData]);
+
+ useEffect(() => {
+ if (nationalChartData.area_values.length) {
+ console.log(nationalChartData);
+ setData({
+ labels: nationalChartData.spi_values.map(item => item[0]),
+ datasets: [
+ {
+ label: 'SHI',
+ data: nationalChartData.spi_values.map(item => item[1]),
+ borderColor: getCSSVariable('birds'),
+ },
+ {
+ label: 'Area protected',
+ data: nationalChartData.area_values.map(item => item[1]),
+ borderColor: getCSSVariable('mammals'),
+ },
+ ],
+ });
+ const spiVal = nationalChartData.spi_values[nationalChartData.spi_values.length - 1][1];
+
+ const spi = {
+ labels: ['Global SPI', 'Remaining'],
+ datasets: [
+ {
+ label: '',
+ data: [
+ spiVal,
+ 100 - spiVal,
+ ],
+ backgroundColor: [
+ getCSSVariable('temporal-spi'),
+ getCSSVariable('white-opacity-20'),
+ ],
+ borderColor: [getCSSVariable('temporal-spi'), getCSSVariable('white-opacity-20')],
+ borderWidth: 1,
+ },
+ ],
+ };
+
+
+ setSpiValue(spiVal);
+ setSpiData(spi);
+ }
+ }, [nationalChartData])
+
+ return (
+
+
+
+ 2024
+ 98.37
+
+ 98.88
+ {countryData?.prop_protected_ter}
+ Year
+ Area Score
+ SHI
+ Connectivity Score
+ Global Ranking
+
+
+ {data &&
+
+
}
+
+ );
+}
+
+export default NationalChartComponent;
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/shi/national-chart/national-chart-styles.module.scss b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/shi/national-chart/national-chart-styles.module.scss
new file mode 100644
index 000000000..7d9af52c8
--- /dev/null
+++ b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/shi/national-chart/national-chart-styles.module.scss
@@ -0,0 +1,94 @@
+@import 'styles/ui.module';
+@import 'styles/settings';
+@import 'styles/typography-extends';
+@import 'styles/common-animations.module';
+
+.container{
+ display: flex;
+ flex-direction: column;
+ padding: 10px 5px 10px 26px;
+ flex-grow: 1;
+
+ .info{
+ display: flex;
+ gap: 15px;
+
+ .specs{
+ display: flex;
+ flex-direction: column;
+ row-gap: 8px;
+
+ span{
+ color: #FFF;
+ font-family: "Open Sans";
+ font-size: 13px;
+ font-style: italic;
+ font-weight: 400;
+ line-height: normal;
+
+ b{
+ color: #FFF;
+ font-family: "Open Sans";
+ font-size: 14px;
+ font-style: normal;
+ font-weight: 600;
+ line-height: normal;
+ }
+ }
+ }
+
+ .arcGrid{
+ display: grid;
+ grid-template-columns: repeat(5, 1fr);
+ grid-template-rows: 70px 30px;
+ width: 100%;
+ justify-items: center;
+ border-radius: 5px;
+ height: 120px;
+ border: 1.5px solid #18bab4;
+
+ .spi{
+ display: flex;
+ flex-direction: column;
+ justify-content: center;
+ align-items: center;
+
+ .score{
+ color: #FFF;
+ text-align: center;
+ font-family: "Open Sans";
+ font-size: 20px;
+ font-style: normal;
+ font-weight: 700;
+ line-height: normal;
+ margin-top: -35px;
+ }
+ }
+
+ b {
+ color: #FFF;
+ font-family: "Open Sans";
+ font-size: 16px;
+ font-style: normal;
+ font-weight: 600;
+ line-height: normal;
+ align-self: end;
+ }
+
+ span{
+ color: #FFF;
+ font-family: "Open Sans";
+ font-size: 12px;
+ font-style: italic;
+ font-weight: 600;
+ line-height: normal;
+ text-transform: uppercase;
+ text-align: center;
+ }
+ }
+ }
+ .chart{
+ width: 100%;
+ margin-top: 25px;
+ }
+}
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/shi/temporal-trends-shi-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/shi/temporal-trends-shi-component.jsx
new file mode 100644
index 000000000..a80c194b0
--- /dev/null
+++ b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/shi/temporal-trends-shi-component.jsx
@@ -0,0 +1,82 @@
+import React, { useEffect, useState } from 'react';
+
+import cx from 'classnames';
+
+import Button from 'components/button';
+
+import {
+ NATIONAL_TREND,
+ PROVINCE_TREND,
+} from '../../dashboard-trends-sidebar-component';
+import styles from '../../dashboard-trends-sidebar-styles.module.scss';
+import NationalChartContainer from './national-chart';
+
+
+function TemporalTrendsShiComponent(props) {
+ const { activeTrend, updateActiveTrend, countryData, selectedIndex } = props;
+
+ const [nationalChartData, setNationalChartData] = useState({ area_values: [], spi_values: [] });
+
+ const getNationalData = async () => {
+ const region_id = '90b03e87-3880-4164-a310-339994e3f919';
+ const taxa = 'all_terr_verts';
+ const url = `https://next-api-dot-api-2-x-dot-map-of-life.appspot.com/2.x/indicators/nrc?region_id=${region_id}&taxa=${taxa}`;
+
+ const response = await fetch(url);
+ const data = await response.json();
+ const { area_values, spi_values } = data[0].values;
+ setNationalChartData({ area_values, spi_values });
+ }
+
+ useEffect(() => {
+ getNationalData();
+ }, []);
+
+
+ const handleActionChange = (event) => {
+ updateActiveTrend(event.currentTarget.innerText);
+ };
+
+
+
+ return (
+
+
+
Temporal Trends
+
+ Since 2001, the terrestrial vertebrate species of the Democratic Republic of the Congo have lost an average of 1.37% of their suitable habitat, leading to the country having a Species Habitat Index of 98.63.
+
+
+ The Area Score addresses changes in habitat extent while the Connectivity Score addresses changes in the fragmentation of habitat.
+
+
+
+
+
+
+ Toggle national SPI and province-level breakdown.
+
+
+
+ View how the percent of area protected, SPI, and score distributions
+ have changed over time.
+
+
+
+
+
+ );
+}
+
+export default TemporalTrendsShiComponent;
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/shi/temporal-trends-shi-styles.module.scss b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/shi/temporal-trends-shi-styles.module.scss
new file mode 100644
index 000000000..c709bfc60
--- /dev/null
+++ b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/shi/temporal-trends-shi-styles.module.scss
@@ -0,0 +1,4 @@
+@import 'styles/ui.module';
+@import 'styles/settings';
+@import 'styles/typography-extends';
+@import 'styles/common-animations.module';
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/sii/national-chart/index.js b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/sii/national-chart/index.js
new file mode 100644
index 000000000..06e126933
--- /dev/null
+++ b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/sii/national-chart/index.js
@@ -0,0 +1,9 @@
+import React from 'react';
+
+import NationalChartComponent from './national-chart-component';
+
+function NationalChartContainer(props) {
+ return ;
+}
+
+export default NationalChartContainer;
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/temporal-trends-national-chart/temporal-trends-national-chart-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/sii/national-chart/national-chart-component.jsx
similarity index 60%
rename from src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/temporal-trends-national-chart/temporal-trends-national-chart-component.jsx
rename to src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/sii/national-chart/national-chart-component.jsx
index 9aeb90db1..e55adc613 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/temporal-trends-national-chart/temporal-trends-national-chart-component.jsx
+++ b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/sii/national-chart/national-chart-component.jsx
@@ -14,12 +14,15 @@ import SpiArcChartComponent from 'components/charts/spi-arc-chart/spi-arc-chart-
import { getCSSVariable } from 'utils/css-utils';
-import styles from './temporal-trends-national-chart-styles.module.scss';
+import styles from './national-chart-styles.module.scss';
ChartJS.register(LinearScale, LineElement, PointElement, Tooltip, Legend);
-function TemporalTrendsNationalChartComponent(props) {
- const { countryData } = props;
+function NationalChartComponent(props) {
+ const { countryData, nationalChartData } = props;
+ const [data, setData] = useState();
+ const [spiValue, setSpiValue] = useState(0);
+
const blankData = {
labels: ['Global SPI', 'Remaining'],
datasets: [
@@ -64,7 +67,7 @@ function TemporalTrendsNationalChartComponent(props) {
display: true,
title: {
display: true,
- text: 'SPI / Percent of Area Protected',
+ text: 'Species Information Index',
color: getCSSVariable('white'),
},
grid: {
@@ -77,43 +80,55 @@ function TemporalTrendsNationalChartComponent(props) {
},
};
- const data = {
- labels: [
- '1980',
- '1985',
- '1990',
- '1995',
- '2000',
- '2005',
- '2010',
- '2015',
- '2020',
- '2025',
- ],
- datasets: [
- {
- label: 'SPI',
- data: [20, 20, 20, 30, 30, 38, 38, 43, 45, 60],
- borderColor: getCSSVariable('birds'),
- },
- {
- label: 'Area protected',
- data: [10, 10, 10, 14, 15, 18, 25, 28, 30, 50],
- borderColor: getCSSVariable('mammals'),
- },
- ],
- };
+ // useEffect(() => {
+ // console.log(countryData)
+ // if (countryData) {
+ // const spi = {
+ // labels: ['Global SPI', 'Remaining'],
+ // datasets: [
+ // {
+ // label: '',
+ // data: [
+ // countryData.Global_SPI_ter,
+ // 100 - countryData.Global_SPI_ter,
+ // ],
+ // backgroundColor: [
+ // getCSSVariable('temporal-spi'),
+ // getCSSVariable('white-opacity-20'),
+ // ],
+ // borderColor: [getCSSVariable('temporal-spi'), getCSSVariable('white-opacity-20')],
+ // borderWidth: 1,
+ // },
+ // ],
+ // };
+
+ // setSpiData(spi);
+ // }
+ // }, [countryData]);
useEffect(() => {
- if (countryData) {
+ if (nationalChartData.area_values.length) {
+ console.log(nationalChartData);
+ setData({
+ labels: nationalChartData.spi_values.map(item => item[0]),
+ datasets: [
+ {
+ label: 'SII',
+ data: nationalChartData.spi_values.map(item => item[1]),
+ borderColor: getCSSVariable('birds'),
+ },
+ ],
+ });
+ const spiVal = nationalChartData.spi_values[nationalChartData.spi_values.length - 1][1];
+
const spi = {
labels: ['Global SPI', 'Remaining'],
datasets: [
{
label: '',
data: [
- countryData.Global_SPI_ter,
- 100 - countryData.Global_SPI_ter,
+ spiVal,
+ 100 - spiVal,
],
backgroundColor: [
getCSSVariable('temporal-spi'),
@@ -125,9 +140,11 @@ function TemporalTrendsNationalChartComponent(props) {
],
};
+
+ setSpiValue(spiVal);
setSpiData(spi);
}
- }, [countryData]);
+ }, [nationalChartData])
return (
@@ -138,26 +155,19 @@ function TemporalTrendsNationalChartComponent(props) {
width="125x"
height="75px"
data={spiData}
- value={countryData?.Global_SPI_ter}
- />
-
{countryData?.prop_protected_ter}
Year
- SPI
- Area Protected
+ SII
Global Ranking
-
}
);
}
-export default TemporalTrendsNationalChartComponent;
+export default NationalChartComponent;
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/sii/national-chart/national-chart-styles.module.scss b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/sii/national-chart/national-chart-styles.module.scss
new file mode 100644
index 000000000..93f2f001a
--- /dev/null
+++ b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/sii/national-chart/national-chart-styles.module.scss
@@ -0,0 +1,94 @@
+@import 'styles/ui.module';
+@import 'styles/settings';
+@import 'styles/typography-extends';
+@import 'styles/common-animations.module';
+
+.container{
+ display: flex;
+ flex-direction: column;
+ padding: 10px 5px 10px 26px;
+ flex-grow: 1;
+
+ .info{
+ display: flex;
+ gap: 15px;
+
+ .specs{
+ display: flex;
+ flex-direction: column;
+ row-gap: 8px;
+
+ span{
+ color: #FFF;
+ font-family: "Open Sans";
+ font-size: 13px;
+ font-style: italic;
+ font-weight: 400;
+ line-height: normal;
+
+ b{
+ color: #FFF;
+ font-family: "Open Sans";
+ font-size: 14px;
+ font-style: normal;
+ font-weight: 600;
+ line-height: normal;
+ }
+ }
+ }
+
+ .arcGrid{
+ display: grid;
+ grid-template-columns: repeat(3, 1fr);
+ grid-template-rows: 70px 30px;
+ width: 100%;
+ justify-items: center;
+ border-radius: 5px;
+ height: 100px;
+ border: 1.5px solid #18bab4;
+
+ .spi{
+ display: flex;
+ flex-direction: column;
+ justify-content: center;
+ align-items: center;
+
+ .score{
+ color: #FFF;
+ text-align: center;
+ font-family: "Open Sans";
+ font-size: 20px;
+ font-style: normal;
+ font-weight: 700;
+ line-height: normal;
+ margin-top: -35px;
+ }
+ }
+
+ b {
+ color: #FFF;
+ font-family: "Open Sans";
+ font-size: 16px;
+ font-style: normal;
+ font-weight: 600;
+ line-height: normal;
+ align-self: end;
+ }
+
+ span{
+ color: #FFF;
+ font-family: "Open Sans";
+ font-size: 12px;
+ font-style: italic;
+ font-weight: 600;
+ line-height: normal;
+ text-transform: uppercase;
+ text-align: center;
+ }
+ }
+ }
+ .chart{
+ width: 100%;
+ margin-top: 25px;
+ }
+}
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/sii/temporal-trends-sii-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/sii/temporal-trends-sii-component.jsx
new file mode 100644
index 000000000..7cf311b94
--- /dev/null
+++ b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/sii/temporal-trends-sii-component.jsx
@@ -0,0 +1,82 @@
+import React, { useEffect, useState } from 'react';
+
+import cx from 'classnames';
+
+import Button from 'components/button';
+
+import {
+ NATIONAL_TREND,
+ PROVINCE_TREND,
+} from '../../dashboard-trends-sidebar-component';
+import styles from '../../dashboard-trends-sidebar-styles.module.scss';
+import NationalChartContainer from './national-chart';
+
+
+function TemporalTrendsSiiComponent(props) {
+ const { activeTrend, updateActiveTrend, countryData, selectedIndex } = props;
+
+ const [nationalChartData, setNationalChartData] = useState({ area_values: [], spi_values: [] });
+
+ const getNationalData = async () => {
+ const region_id = '90b03e87-3880-4164-a310-339994e3f919';
+ const taxa = 'all_terr_verts';
+ const url = `https://next-api-dot-api-2-x-dot-map-of-life.appspot.com/2.x/indicators/nrc?region_id=${region_id}&taxa=${taxa}`;
+
+ const response = await fetch(url);
+ const data = await response.json();
+ const { area_values, spi_values } = data[0].values;
+ setNationalChartData({ area_values, spi_values });
+ }
+
+ useEffect(() => {
+ getNationalData();
+ }, []);
+
+
+ const handleActionChange = (event) => {
+ updateActiveTrend(event.currentTarget.innerText);
+ };
+
+
+
+ return (
+
+
+
Temporal Trends
+
+ Since 1980, the {countryData?.NAME_0} has added 328357 km2
+ of land into its protected area network, representing 14% of the total
+ land in the country, increasing its Species Protection Index from
+ 27.21 in 1980 to 63 in 2023.
+
+
+
+
+
+
+ Toggle national SPI and province-level breakdown.
+
+
+
+ View how the percent of area protected, SPI, and score distributions
+ have changed over time.
+
+
+
+
+
+ );
+}
+
+export default TemporalTrendsSiiComponent;
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/sii/temporal-trends-sii-styles.module.scss b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/sii/temporal-trends-sii-styles.module.scss
new file mode 100644
index 000000000..c709bfc60
--- /dev/null
+++ b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/sii/temporal-trends-sii-styles.module.scss
@@ -0,0 +1,4 @@
+@import 'styles/ui.module';
+@import 'styles/settings';
+@import 'styles/typography-extends';
+@import 'styles/common-animations.module';
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/spi/national-chart/index.js b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/spi/national-chart/index.js
new file mode 100644
index 000000000..06e126933
--- /dev/null
+++ b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/spi/national-chart/index.js
@@ -0,0 +1,9 @@
+import React from 'react';
+
+import NationalChartComponent from './national-chart-component';
+
+function NationalChartContainer(props) {
+ return
;
+}
+
+export default NationalChartContainer;
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/spi/national-chart/national-chart-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/spi/national-chart/national-chart-component.jsx
new file mode 100644
index 000000000..528dc7de6
--- /dev/null
+++ b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/spi/national-chart/national-chart-component.jsx
@@ -0,0 +1,209 @@
+import React, { useEffect, useState } from 'react';
+import { Line } from 'react-chartjs-2';
+
+import {
+ Chart as ChartJS,
+ LinearScale,
+ PointElement,
+ LineElement,
+ Tooltip,
+ Legend,
+} from 'chart.js';
+
+import SpiArcChartComponent from 'components/charts/spi-arc-chart/spi-arc-chart-component';
+
+import { getCSSVariable } from 'utils/css-utils';
+
+import styles from './national-chart-styles.module.scss';
+
+ChartJS.register(LinearScale, LineElement, PointElement, Tooltip, Legend);
+
+function TemporalTrendsSpiNationalChartComponent(props) {
+ const { countryData, nationalChartData } = props;
+ const [data, setData] = useState();
+ const [areaProtected, setAreaProtected] = useState(0);
+ const [spiValue, setSpiValue] = useState(0);
+
+ const blankData = {
+ labels: ['Global SPI', 'Remaining'],
+ datasets: [
+ {
+ label: '',
+ data: [0, 0],
+ backgroundColor: [getCSSVariable('temporal-spi'), getCSSVariable('white-opacity-20')],
+ borderColor: [getCSSVariable('temporal-spi'), getCSSVariable('white-opacity-20')],
+ borderWidth: 1,
+ },
+ ],
+ };
+ const [spiData, setSpiData] = useState(blankData);
+ const [areaProtectedData, setAreaProtectedData] = useState(blankData);
+
+ const options = {
+ plugins: {
+ title: {
+ display: false,
+ },
+ legend: {
+ display: false,
+ },
+ },
+ scales: {
+ x: {
+ beginAtZero: false,
+ display: true,
+ title: {
+ display: true,
+ text: 'Year',
+ color: getCSSVariable('white'),
+ },
+ grid: {
+ color: getCSSVariable('oslo-gray'),
+ },
+ ticks: {
+ color: getCSSVariable('oslo-gray'),
+ },
+ },
+ y: {
+ beginAtZero: true,
+ display: true,
+ title: {
+ display: true,
+ text: 'SPI / Percent of Area Protected',
+ color: getCSSVariable('white'),
+ },
+ grid: {
+ color: getCSSVariable('oslo-gray'),
+ },
+ ticks: {
+ color: getCSSVariable('oslo-gray'),
+ },
+ },
+ },
+ };
+
+ // useEffect(() => {
+ // console.log(countryData)
+ // if (countryData) {
+ // const spi = {
+ // labels: ['Global SPI', 'Remaining'],
+ // datasets: [
+ // {
+ // label: '',
+ // data: [
+ // countryData.Global_SPI_ter,
+ // 100 - countryData.Global_SPI_ter,
+ // ],
+ // backgroundColor: [
+ // getCSSVariable('temporal-spi'),
+ // getCSSVariable('white-opacity-20'),
+ // ],
+ // borderColor: [getCSSVariable('temporal-spi'), getCSSVariable('white-opacity-20')],
+ // borderWidth: 1,
+ // },
+ // ],
+ // };
+
+ // setSpiData(spi);
+ // }
+ // }, [countryData]);
+
+ useEffect(() => {
+ if (nationalChartData.area_values.length) {
+ console.log(nationalChartData);
+ setData({
+ labels: nationalChartData.spi_values.map(item => item[0]),
+ datasets: [
+ {
+ label: 'SPI',
+ data: nationalChartData.spi_values.map(item => item[1]),
+ borderColor: getCSSVariable('birds'),
+ },
+ {
+ label: 'Area protected',
+ data: nationalChartData.area_values.map(item => item[1]),
+ borderColor: getCSSVariable('mammals'),
+ },
+ ],
+ });
+
+ const areaProtected = nationalChartData.area_values[nationalChartData.area_values.length - 1][1];
+ const spiVal = nationalChartData.spi_values[nationalChartData.spi_values.length - 1][1];
+
+ const spi = {
+ labels: ['Global SPI', 'Remaining'],
+ datasets: [
+ {
+ label: '',
+ data: [
+ spiVal,
+ 100 - spiVal,
+ ],
+ backgroundColor: [
+ getCSSVariable('temporal-spi'),
+ getCSSVariable('white-opacity-20'),
+ ],
+ borderColor: [getCSSVariable('temporal-spi'), getCSSVariable('white-opacity-20')],
+ borderWidth: 1,
+ },
+ ],
+ };
+
+ const areaProt = {
+ labels: ['Area Protected', 'Remaining'],
+ datasets: [
+ {
+ label: '',
+ data: [
+ areaProtected,
+ 100 - areaProtected,
+ ],
+ backgroundColor: [
+ getCSSVariable('temporal-spi'),
+ getCSSVariable('white-opacity-20'),
+ ],
+ borderColor: [getCSSVariable('temporal-spi'), getCSSVariable('white-opacity-20')],
+ borderWidth: 1,
+ },
+ ],
+ };
+
+ setSpiValue(spiVal);
+ setSpiData(spi);
+ setAreaProtected(areaProtected);
+ setAreaProtectedData(areaProt);
+ }
+ }, [nationalChartData])
+
+ return (
+
+
+
+ 2024
+
+
+ {countryData?.prop_protected_ter}
+ Year
+ SPI
+ Area Protected
+ Global Ranking
+
+
+ {data &&
+
+
}
+
+ );
+}
+
+export default TemporalTrendsSpiNationalChartComponent;
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/temporal-trends-national-chart/temporal-trends-national-chart-styles.module.scss b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/spi/national-chart/national-chart-styles.module.scss
similarity index 100%
rename from src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/temporal-trends-national-chart/temporal-trends-national-chart-styles.module.scss
rename to src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/spi/national-chart/national-chart-styles.module.scss
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/spi/province-chart/index.js b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/spi/province-chart/index.js
new file mode 100644
index 000000000..4f795d4a8
--- /dev/null
+++ b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/spi/province-chart/index.js
@@ -0,0 +1,9 @@
+import React from 'react';
+
+import ProvinceChartComponent from './province-chart-component';
+
+function ProvinceChartContainer(props) {
+ return
;
+}
+
+export default ProvinceChartContainer;
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/temporal-trends-province-chart/temporal-trends-province-chart-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/spi/province-chart/province-chart-component.jsx
similarity index 97%
rename from src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/temporal-trends-province-chart/temporal-trends-province-chart-component.jsx
rename to src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/spi/province-chart/province-chart-component.jsx
index 2fdfc6310..edeae530a 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/temporal-trends-province-chart/temporal-trends-province-chart-component.jsx
+++ b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/spi/province-chart/province-chart-component.jsx
@@ -16,11 +16,11 @@ import SpiArcChartComponent from 'components/charts/spi-arc-chart/spi-arc-chart-
import { getCSSVariable } from 'utils/css-utils';
-import styles from './temporal-trends-province-chart-styles.module.scss';
+import styles from './province-chart-styles.module.scss';
ChartJS.register(LinearScale, ArcElement, PointElement, Tooltip, Legend);
-function TemporalTrendsProvinceChartComponent(props) {
+function ProvinceChartComponent(props) {
const { countryData } = props;
const blankData = {
labels: ['Global SPI', 'Remaining'],
@@ -218,4 +218,4 @@ function TemporalTrendsProvinceChartComponent(props) {
);
}
-export default TemporalTrendsProvinceChartComponent;
+export default ProvinceChartComponent;
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/temporal-trends-province-chart/temporal-trends-province-chart-styles.module.scss b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/spi/province-chart/province-chart-styles.module.scss
similarity index 100%
rename from src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/temporal-trends-province-chart/temporal-trends-province-chart-styles.module.scss
rename to src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/spi/province-chart/province-chart-styles.module.scss
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/temporal-trends-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/spi/temporal-trends-spi-component.jsx
similarity index 64%
rename from src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/temporal-trends-component.jsx
rename to src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/spi/temporal-trends-spi-component.jsx
index 3a78e5298..8581b5299 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/temporal-trends-component.jsx
+++ b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/spi/temporal-trends-spi-component.jsx
@@ -1,4 +1,4 @@
-import React from 'react';
+import React, { useEffect, useState } from 'react';
import cx from 'classnames';
@@ -7,25 +7,45 @@ import Button from 'components/button';
import {
NATIONAL_TREND,
PROVINCE_TREND,
-} from '../dashboard-trends-sidebar-component';
-import styles from '../dashboard-trends-sidebar-styles.module.scss';
+} from '../../dashboard-trends-sidebar-component';
+import styles from '../../dashboard-trends-sidebar-styles.module.scss';
+import NationalChartContainer from './national-chart';
+import ProvinceChartContainer from './province-chart';
-import TemporalTrendsNationalChartContainer from './temporal-trends-national-chart';
-import TemporalTrendsProvinceChartContainer from './temporal-trends-province-chart';
-function TemporalTrendsComponent(props) {
- const { activeTrend, updateActiveTrend } = props;
+function TemporalTrendsSpiComponent(props) {
+ const { activeTrend, updateActiveTrend, countryData, selectedIndex } = props;
+
+ const [nationalChartData, setNationalChartData] = useState({ area_values: [], spi_values: [] });
+
+ const getNationalData = async () => {
+ const region_id = '90b03e87-3880-4164-a310-339994e3f919';
+ const taxa = 'all_terr_verts';
+ const url = `https://next-api-dot-api-2-x-dot-map-of-life.appspot.com/2.x/indicators/nrc?region_id=${region_id}&taxa=${taxa}`;
+
+ const response = await fetch(url);
+ const data = await response.json();
+ const { area_values, spi_values } = data[0].values;
+ setNationalChartData({ area_values, spi_values });
+ }
+
+ useEffect(() => {
+ getNationalData();
+ }, []);
+
const handleActionChange = (event) => {
updateActiveTrend(event.currentTarget.innerText);
};
+
+
return (
Temporal Trends
- Since 1980, the Democratic Republic of the Congo has added 328357 km2
+ Since 1980, the {countryData?.NAME_0} has added 328357 km2
of land into its protected area network, representing 14% of the total
land in the country, increasing its Species Protection Index from
27.21 in 1980 to 63 in 2023.
@@ -78,13 +98,13 @@ function TemporalTrendsComponent(props) {
{activeTrend === NATIONAL_TREND && (
-
+
)}
{activeTrend === PROVINCE_TREND && (
-
+
)}
);
}
-export default TemporalTrendsComponent;
+export default TemporalTrendsSpiComponent;
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/spi/temporal-trends-spi-styles.module.scss b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/spi/temporal-trends-spi-styles.module.scss
new file mode 100644
index 000000000..c709bfc60
--- /dev/null
+++ b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/spi/temporal-trends-spi-styles.module.scss
@@ -0,0 +1,4 @@
+@import 'styles/ui.module';
+@import 'styles/settings';
+@import 'styles/typography-extends';
+@import 'styles/common-animations.module';
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/temporal-trends-national-chart/index.js b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/temporal-trends-national-chart/index.js
deleted file mode 100644
index 59c74027e..000000000
--- a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/temporal-trends-national-chart/index.js
+++ /dev/null
@@ -1,9 +0,0 @@
-import React from 'react';
-
-import TemporalTrendsNationalChartComponent from './temporal-trends-national-chart-component';
-
-function TemporalTrendsNationalChartContainer(props) {
- return
;
-}
-
-export default TemporalTrendsNationalChartContainer;
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/temporal-trends-province-chart/index.js b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/temporal-trends-province-chart/index.js
deleted file mode 100644
index 33458517d..000000000
--- a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/temporal-trends-province-chart/index.js
+++ /dev/null
@@ -1,9 +0,0 @@
-import React from 'react';
-
-import TemporalTrendsProvinceChartComponent from './temporal-trends-province-chart-component';
-
-function TemporalTrendsProvinceChartContainer(props) {
- return
;
-}
-
-export default TemporalTrendsProvinceChartContainer;
From 39e324d2d695402166dafbca082a2a2c9830a555 Mon Sep 17 00:00:00 2001
From: Chris Manciero
Date: Thu, 11 Jul 2024 14:57:56 -0400
Subject: [PATCH 030/350] rename/move components around
---
.eslintrc.js => .eslintrc.cjs | 0
.../dashboard-trends-sidebar-component.jsx | 9 ---
.../temporal-trends/index.js | 18 +++---
.../national-chart-component.jsx | 47 +++++++++------
.../shi/temporal-trends-shi-component.jsx | 25 +++++---
.../national-chart-component.jsx | 44 ++++++++------
.../sii/temporal-trends-sii-component.jsx | 45 ++++++--------
.../national-chart-component.jsx | 60 ++++++++++++-------
.../province-chart-component.jsx | 19 ++++--
.../spi/temporal-trends-spi-component.jsx | 6 +-
10 files changed, 154 insertions(+), 119 deletions(-)
rename .eslintrc.js => .eslintrc.cjs (100%)
diff --git a/.eslintrc.js b/.eslintrc.cjs
similarity index 100%
rename from .eslintrc.js
rename to .eslintrc.cjs
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/dashboard-trends-sidebar-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/dashboard-trends-sidebar-component.jsx
index 9e3afa20c..45f2d2854 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/dashboard-trends-sidebar-component.jsx
+++ b/src/containers/sidebars/dashboard-trends-sidebar/dashboard-trends-sidebar-component.jsx
@@ -12,12 +12,6 @@ function DashboardTrendsSidebar(props) {
const { countryISO, countryData } = props;
const [selectedIndex, setSelectedIndex] = useState(1);
- const [activeTrend, setActiveTrend] = useState(NATIONAL_TREND);
-
- const handleActiveTrendUpdate = (trend) => {
- setActiveTrend(trend);
- };
-
return (
@@ -61,13 +55,10 @@ function DashboardTrendsSidebar(props) {
);
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/index.js b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/index.js
index bfa07ecdf..fd8b4b1ab 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/index.js
+++ b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/index.js
@@ -1,18 +1,20 @@
import React from 'react';
import TemporalTrendsShiComponent from './shi/temporal-trends-shi-component';
-import TemporalTrendsSpiComponent from './spi/temporal-trends-spi-component';
import TemporalTrendsSiiComponent from './sii/temporal-trends-sii-component';
+import TemporalTrendsSpiComponent from './spi/temporal-trends-spi-component';
function TemporalTrendsContainer(props) {
- const {selectedIndex} = props;
+ const { selectedIndex } = props;
- if(selectedIndex === 1){
- return
- } else if (selectedIndex === 2){
- return
- } else if (selectedIndex === 3){
- return
+ if (selectedIndex === 1) {
+ return ;
+ }
+ if (selectedIndex === 2) {
+ return ;
+ }
+ if (selectedIndex === 3) {
+ return ;
}
return ;
}
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/shi/national-chart/national-chart-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/shi/national-chart/national-chart-component.jsx
index 1be02f6b9..2964cca08 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/shi/national-chart/national-chart-component.jsx
+++ b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/shi/national-chart/national-chart-component.jsx
@@ -1,6 +1,8 @@
import React, { useEffect, useState } from 'react';
import { Line } from 'react-chartjs-2';
+import { getCSSVariable } from 'utils/css-utils';
+
import {
Chart as ChartJS,
LinearScale,
@@ -12,8 +14,6 @@ import {
import SpiArcChartComponent from 'components/charts/spi-arc-chart/spi-arc-chart-component';
-import { getCSSVariable } from 'utils/css-utils';
-
import styles from './national-chart-styles.module.scss';
ChartJS.register(LinearScale, LineElement, PointElement, Tooltip, Legend);
@@ -21,7 +21,6 @@ ChartJS.register(LinearScale, LineElement, PointElement, Tooltip, Legend);
function NationalChartComponent(props) {
const { countryData, nationalChartData } = props;
const [data, setData] = useState();
- const [areaProtected, setAreaProtected] = useState(0);
const [spiValue, setSpiValue] = useState(0);
const blankData = {
@@ -30,8 +29,14 @@ function NationalChartComponent(props) {
{
label: '',
data: [0, 0],
- backgroundColor: [getCSSVariable('temporal-spi'), getCSSVariable('white-opacity-20')],
- borderColor: [getCSSVariable('temporal-spi'), getCSSVariable('white-opacity-20')],
+ backgroundColor: [
+ getCSSVariable('temporal-spi'),
+ getCSSVariable('white-opacity-20'),
+ ],
+ borderColor: [
+ getCSSVariable('temporal-spi'),
+ getCSSVariable('white-opacity-20'),
+ ],
borderWidth: 1,
},
],
@@ -111,46 +116,48 @@ function NationalChartComponent(props) {
if (nationalChartData.area_values.length) {
console.log(nationalChartData);
setData({
- labels: nationalChartData.spi_values.map(item => item[0]),
+ labels: nationalChartData.spi_values.map((item) => item[0]),
datasets: [
{
label: 'SHI',
- data: nationalChartData.spi_values.map(item => item[1]),
+ data: nationalChartData.spi_values.map((item) => item[1]),
borderColor: getCSSVariable('birds'),
},
{
label: 'Area protected',
- data: nationalChartData.area_values.map(item => item[1]),
+ data: nationalChartData.area_values.map((item) => item[1]),
borderColor: getCSSVariable('mammals'),
},
],
});
- const spiVal = nationalChartData.spi_values[nationalChartData.spi_values.length - 1][1];
+ const spiVal =
+ nationalChartData.spi_values[
+ nationalChartData.spi_values.length - 1
+ ][1];
const spi = {
labels: ['Global SPI', 'Remaining'],
datasets: [
{
label: '',
- data: [
- spiVal,
- 100 - spiVal,
- ],
+ data: [spiVal, 100 - spiVal],
backgroundColor: [
getCSSVariable('temporal-spi'),
getCSSVariable('white-opacity-20'),
],
- borderColor: [getCSSVariable('temporal-spi'), getCSSVariable('white-opacity-20')],
+ borderColor: [
+ getCSSVariable('temporal-spi'),
+ getCSSVariable('white-opacity-20'),
+ ],
borderWidth: 1,
},
],
};
-
setSpiValue(spiVal);
setSpiData(spi);
}
- }, [nationalChartData])
+ }, [nationalChartData]);
return (
@@ -173,9 +180,11 @@ function NationalChartComponent(props) {
Global Ranking
- {data &&
-
-
}
+ {data && (
+
+
+
+ )}
);
}
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/shi/temporal-trends-shi-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/shi/temporal-trends-shi-component.jsx
index a80c194b0..c515f0d04 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/shi/temporal-trends-shi-component.jsx
+++ b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/shi/temporal-trends-shi-component.jsx
@@ -9,13 +9,16 @@ import {
PROVINCE_TREND,
} from '../../dashboard-trends-sidebar-component';
import styles from '../../dashboard-trends-sidebar-styles.module.scss';
-import NationalChartContainer from './national-chart';
+import NationalChartContainer from './national-chart';
function TemporalTrendsShiComponent(props) {
const { activeTrend, updateActiveTrend, countryData, selectedIndex } = props;
- const [nationalChartData, setNationalChartData] = useState({ area_values: [], spi_values: [] });
+ const [nationalChartData, setNationalChartData] = useState({
+ area_values: [],
+ spi_values: [],
+ });
const getNationalData = async () => {
const region_id = '90b03e87-3880-4164-a310-339994e3f919';
@@ -26,28 +29,29 @@ function TemporalTrendsShiComponent(props) {
const data = await response.json();
const { area_values, spi_values } = data[0].values;
setNationalChartData({ area_values, spi_values });
- }
+ };
useEffect(() => {
getNationalData();
}, []);
-
const handleActionChange = (event) => {
updateActiveTrend(event.currentTarget.innerText);
};
-
-
return (
Temporal Trends
- Since 2001, the terrestrial vertebrate species of the Democratic Republic of the Congo have lost an average of 1.37% of their suitable habitat, leading to the country having a Species Habitat Index of 98.63.
+ Since 2001, the terrestrial vertebrate species of the Democratic
+ Republic of the Congo have lost an average of 1.37% of their suitable
+ habitat, leading to the country having a Species Habitat Index of
+ 98.63.
- The Area Score addresses changes in habitat extent while the Connectivity Score addresses changes in the fragmentation of habitat.
+ The Area Score addresses changes in habitat extent while the
+ Connectivity Score addresses changes in the fragmentation of habitat.
@@ -74,7 +78,10 @@ function TemporalTrendsShiComponent(props) {
-
+
);
}
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/sii/national-chart/national-chart-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/sii/national-chart/national-chart-component.jsx
index e55adc613..1c382fd33 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/sii/national-chart/national-chart-component.jsx
+++ b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/sii/national-chart/national-chart-component.jsx
@@ -1,6 +1,8 @@
import React, { useEffect, useState } from 'react';
import { Line } from 'react-chartjs-2';
+import { getCSSVariable } from 'utils/css-utils';
+
import {
Chart as ChartJS,
LinearScale,
@@ -12,8 +14,6 @@ import {
import SpiArcChartComponent from 'components/charts/spi-arc-chart/spi-arc-chart-component';
-import { getCSSVariable } from 'utils/css-utils';
-
import styles from './national-chart-styles.module.scss';
ChartJS.register(LinearScale, LineElement, PointElement, Tooltip, Legend);
@@ -29,8 +29,14 @@ function NationalChartComponent(props) {
{
label: '',
data: [0, 0],
- backgroundColor: [getCSSVariable('temporal-spi'), getCSSVariable('white-opacity-20')],
- borderColor: [getCSSVariable('temporal-spi'), getCSSVariable('white-opacity-20')],
+ backgroundColor: [
+ getCSSVariable('temporal-spi'),
+ getCSSVariable('white-opacity-20'),
+ ],
+ borderColor: [
+ getCSSVariable('temporal-spi'),
+ getCSSVariable('white-opacity-20'),
+ ],
borderWidth: 1,
},
],
@@ -110,41 +116,43 @@ function NationalChartComponent(props) {
if (nationalChartData.area_values.length) {
console.log(nationalChartData);
setData({
- labels: nationalChartData.spi_values.map(item => item[0]),
+ labels: nationalChartData.spi_values.map((item) => item[0]),
datasets: [
{
label: 'SII',
- data: nationalChartData.spi_values.map(item => item[1]),
+ data: nationalChartData.spi_values.map((item) => item[1]),
borderColor: getCSSVariable('birds'),
},
],
});
- const spiVal = nationalChartData.spi_values[nationalChartData.spi_values.length - 1][1];
+ const spiVal =
+ nationalChartData.spi_values[
+ nationalChartData.spi_values.length - 1
+ ][1];
const spi = {
labels: ['Global SPI', 'Remaining'],
datasets: [
{
label: '',
- data: [
- spiVal,
- 100 - spiVal,
- ],
+ data: [spiVal, 100 - spiVal],
backgroundColor: [
getCSSVariable('temporal-spi'),
getCSSVariable('white-opacity-20'),
],
- borderColor: [getCSSVariable('temporal-spi'), getCSSVariable('white-opacity-20')],
+ borderColor: [
+ getCSSVariable('temporal-spi'),
+ getCSSVariable('white-opacity-20'),
+ ],
borderWidth: 1,
},
],
};
-
setSpiValue(spiVal);
setSpiData(spi);
}
- }, [nationalChartData])
+ }, [nationalChartData]);
return (
@@ -163,9 +171,11 @@ function NationalChartComponent(props) {
Global Ranking
- {data &&
-
-
}
+ {data && (
+
+
+
+ )}
);
}
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/sii/temporal-trends-sii-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/sii/temporal-trends-sii-component.jsx
index 7cf311b94..a1a38fe1f 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/sii/temporal-trends-sii-component.jsx
+++ b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/sii/temporal-trends-sii-component.jsx
@@ -4,60 +4,48 @@ import cx from 'classnames';
import Button from 'components/button';
-import {
- NATIONAL_TREND,
- PROVINCE_TREND,
-} from '../../dashboard-trends-sidebar-component';
+import { NATIONAL_TREND } from '../../dashboard-trends-sidebar-component';
import styles from '../../dashboard-trends-sidebar-styles.module.scss';
-import NationalChartContainer from './national-chart';
+import NationalChartContainer from './national-chart';
function TemporalTrendsSiiComponent(props) {
- const { activeTrend, updateActiveTrend, countryData, selectedIndex } = props;
-
- const [nationalChartData, setNationalChartData] = useState({ area_values: [], spi_values: [] });
+ const [nationalChartData, setNationalChartData] = useState({
+ area_values: [],
+ spi_values: [],
+ });
const getNationalData = async () => {
- const region_id = '90b03e87-3880-4164-a310-339994e3f919';
+ const regionId = '90b03e87-3880-4164-a310-339994e3f919';
const taxa = 'all_terr_verts';
- const url = `https://next-api-dot-api-2-x-dot-map-of-life.appspot.com/2.x/indicators/nrc?region_id=${region_id}&taxa=${taxa}`;
+ const url = `https://next-api-dot-api-2-x-dot-map-of-life.appspot.com/2.x/indicators/nrc?region_id=${regionId}&taxa=${taxa}`;
const response = await fetch(url);
const data = await response.json();
const { area_values, spi_values } = data[0].values;
setNationalChartData({ area_values, spi_values });
- }
+ };
useEffect(() => {
getNationalData();
}, []);
-
- const handleActionChange = (event) => {
- updateActiveTrend(event.currentTarget.innerText);
- };
-
-
-
return (
Temporal Trends
- Since 1980, the {countryData?.NAME_0} has added 328357 km2
- of land into its protected area network, representing 14% of the total
- land in the country, increasing its Species Protection Index from
- 27.21 in 1980 to 63 in 2023.
+ Species data coverage remains low in Democratic Republic of Congo. In
+ 2023, 0.44% of the expected ranges of terrestrial vertebrate species
+ here had a recorded observation of that species. Since 1950, the
+ annual SII has fluctuated between 1.6 and 0.0.
@@ -74,7 +62,10 @@ function TemporalTrendsSiiComponent(props) {
-
+
);
}
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/spi/national-chart/national-chart-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/spi/national-chart/national-chart-component.jsx
index 528dc7de6..2a25c5758 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/spi/national-chart/national-chart-component.jsx
+++ b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/spi/national-chart/national-chart-component.jsx
@@ -1,6 +1,8 @@
import React, { useEffect, useState } from 'react';
import { Line } from 'react-chartjs-2';
+import { getCSSVariable } from 'utils/css-utils';
+
import {
Chart as ChartJS,
LinearScale,
@@ -12,8 +14,6 @@ import {
import SpiArcChartComponent from 'components/charts/spi-arc-chart/spi-arc-chart-component';
-import { getCSSVariable } from 'utils/css-utils';
-
import styles from './national-chart-styles.module.scss';
ChartJS.register(LinearScale, LineElement, PointElement, Tooltip, Legend);
@@ -30,8 +30,14 @@ function TemporalTrendsSpiNationalChartComponent(props) {
{
label: '',
data: [0, 0],
- backgroundColor: [getCSSVariable('temporal-spi'), getCSSVariable('white-opacity-20')],
- borderColor: [getCSSVariable('temporal-spi'), getCSSVariable('white-opacity-20')],
+ backgroundColor: [
+ getCSSVariable('temporal-spi'),
+ getCSSVariable('white-opacity-20'),
+ ],
+ borderColor: [
+ getCSSVariable('temporal-spi'),
+ getCSSVariable('white-opacity-20'),
+ ],
borderWidth: 1,
},
],
@@ -112,38 +118,44 @@ function TemporalTrendsSpiNationalChartComponent(props) {
if (nationalChartData.area_values.length) {
console.log(nationalChartData);
setData({
- labels: nationalChartData.spi_values.map(item => item[0]),
+ labels: nationalChartData.spi_values.map((item) => item[0]),
datasets: [
{
label: 'SPI',
- data: nationalChartData.spi_values.map(item => item[1]),
+ data: nationalChartData.spi_values.map((item) => item[1]),
borderColor: getCSSVariable('birds'),
},
{
label: 'Area protected',
- data: nationalChartData.area_values.map(item => item[1]),
+ data: nationalChartData.area_values.map((item) => item[1]),
borderColor: getCSSVariable('mammals'),
},
],
});
- const areaProtected = nationalChartData.area_values[nationalChartData.area_values.length - 1][1];
- const spiVal = nationalChartData.spi_values[nationalChartData.spi_values.length - 1][1];
+ const areaProtected =
+ nationalChartData.area_values[
+ nationalChartData.area_values.length - 1
+ ][1];
+ const spiVal =
+ nationalChartData.spi_values[
+ nationalChartData.spi_values.length - 1
+ ][1];
const spi = {
labels: ['Global SPI', 'Remaining'],
datasets: [
{
label: '',
- data: [
- spiVal,
- 100 - spiVal,
- ],
+ data: [spiVal, 100 - spiVal],
backgroundColor: [
getCSSVariable('temporal-spi'),
getCSSVariable('white-opacity-20'),
],
- borderColor: [getCSSVariable('temporal-spi'), getCSSVariable('white-opacity-20')],
+ borderColor: [
+ getCSSVariable('temporal-spi'),
+ getCSSVariable('white-opacity-20'),
+ ],
borderWidth: 1,
},
],
@@ -154,15 +166,15 @@ function TemporalTrendsSpiNationalChartComponent(props) {
datasets: [
{
label: '',
- data: [
- areaProtected,
- 100 - areaProtected,
- ],
+ data: [areaProtected, 100 - areaProtected],
backgroundColor: [
getCSSVariable('temporal-spi'),
getCSSVariable('white-opacity-20'),
],
- borderColor: [getCSSVariable('temporal-spi'), getCSSVariable('white-opacity-20')],
+ borderColor: [
+ getCSSVariable('temporal-spi'),
+ getCSSVariable('white-opacity-20'),
+ ],
borderWidth: 1,
},
],
@@ -173,7 +185,7 @@ function TemporalTrendsSpiNationalChartComponent(props) {
setAreaProtected(areaProtected);
setAreaProtectedData(areaProt);
}
- }, [nationalChartData])
+ }, [nationalChartData]);
return (
@@ -199,9 +211,11 @@ function TemporalTrendsSpiNationalChartComponent(props) {
Global Ranking
- {data &&
-
-
}
+ {data && (
+
+
+
+ )}
);
}
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/spi/province-chart/province-chart-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/spi/province-chart/province-chart-component.jsx
index edeae530a..9e63bbcbf 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/spi/province-chart/province-chart-component.jsx
+++ b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/spi/province-chart/province-chart-component.jsx
@@ -2,6 +2,8 @@ import React, { useEffect, useState } from 'react';
import { Bubble } from 'react-chartjs-2';
import Select from 'react-select';
+import { getCSSVariable } from 'utils/css-utils';
+
import { faker } from '@faker-js/faker';
import {
Chart as ChartJS,
@@ -14,8 +16,6 @@ import {
import SpiArcChartComponent from 'components/charts/spi-arc-chart/spi-arc-chart-component';
-import { getCSSVariable } from 'utils/css-utils';
-
import styles from './province-chart-styles.module.scss';
ChartJS.register(LinearScale, ArcElement, PointElement, Tooltip, Legend);
@@ -28,8 +28,14 @@ function ProvinceChartComponent(props) {
{
label: '',
data: [0, 0],
- backgroundColor: [getCSSVariable('temporal-spi'), getCSSVariable('white-opacity-20')],
- borderColor: [getCSSVariable('temporal-spi'), getCSSVariable('white-opacity-20')],
+ backgroundColor: [
+ getCSSVariable('temporal-spi'),
+ getCSSVariable('white-opacity-20'),
+ ],
+ borderColor: [
+ getCSSVariable('temporal-spi'),
+ getCSSVariable('white-opacity-20'),
+ ],
borderWidth: 1,
},
],
@@ -164,7 +170,10 @@ function ProvinceChartComponent(props) {
getCSSVariable('temporal-spi'),
getCSSVariable('white-opacity-20'),
],
- borderColor: [getCSSVariable('temporal-spi'), getCSSVariable('white-opacity-20')],
+ borderColor: [
+ getCSSVariable('temporal-spi'),
+ getCSSVariable('white-opacity-20'),
+ ],
borderWidth: 1,
},
],
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/spi/temporal-trends-spi-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/spi/temporal-trends-spi-component.jsx
index 8581b5299..06e2d80c6 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/spi/temporal-trends-spi-component.jsx
+++ b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/spi/temporal-trends-spi-component.jsx
@@ -14,8 +14,9 @@ import ProvinceChartContainer from './province-chart';
function TemporalTrendsSpiComponent(props) {
- const { activeTrend, updateActiveTrend, countryData, selectedIndex } = props;
+ const { countryData } = props;
+ const [activeTrend, setActiveTrend] = useState(NATIONAL_TREND);
const [nationalChartData, setNationalChartData] = useState({ area_values: [], spi_values: [] });
const getNationalData = async () => {
@@ -29,13 +30,14 @@ function TemporalTrendsSpiComponent(props) {
setNationalChartData({ area_values, spi_values });
}
+
useEffect(() => {
getNationalData();
}, []);
const handleActionChange = (event) => {
- updateActiveTrend(event.currentTarget.innerText);
+ setActiveTrend(event.currentTarget.innerText);
};
From ca02f4b9e4ec538aecc695a5bb38df595caaf8c5 Mon Sep 17 00:00:00 2001
From: Chris Manciero
Date: Mon, 15 Jul 2024 11:51:17 -0400
Subject: [PATCH 031/350] new components for SHI, SPI, SII
---
.../dashboard-trends-sidebar-component.jsx | 13 +-
...ashboard-trends-sidebar-styles.module.scss | 55 +--
.../score-distributions/index.js | 17 +-
.../score-distributions-chart/index.js | 9 -
.../distributions-chart-component.jsx | 336 ++++++++++++++++++
.../distributions-chart-styles.module.scss} | 0
.../shi/distributions-chart/index.js | 9 +
.../shi/score-distributions-shi-component.jsx | 142 ++++++++
...score-distributions-shi-styles.module.scss | 11 +
.../score-distributions-sii-component.jsx} | 18 +-
...score-distributions-sii-styles.module.scss | 4 +
.../spi/score-distributions-chart/index.js | 9 +
.../score-distributions-chart-component.jsx} | 137 ++++---
...ore-distributions-chart-styles.module.scss | 82 +++++
.../spi/score-distributions-spi-component.jsx | 107 ++++++
...score-distributions-spi-styles.module.scss | 4 +
.../shi/temporal-trends-shi-component.jsx | 17 +-
.../spi/temporal-trends-spi-component.jsx | 28 +-
18 files changed, 871 insertions(+), 127 deletions(-)
delete mode 100644 src/containers/sidebars/dashboard-trends-sidebar/score-distributions/score-distributions-chart/index.js
create mode 100644 src/containers/sidebars/dashboard-trends-sidebar/score-distributions/shi/distributions-chart/distributions-chart-component.jsx
rename src/containers/sidebars/dashboard-trends-sidebar/score-distributions/{score-distributions-chart/score-distribution-chart-styles.module.scss => shi/distributions-chart/distributions-chart-styles.module.scss} (100%)
create mode 100644 src/containers/sidebars/dashboard-trends-sidebar/score-distributions/shi/distributions-chart/index.js
create mode 100644 src/containers/sidebars/dashboard-trends-sidebar/score-distributions/shi/score-distributions-shi-component.jsx
create mode 100644 src/containers/sidebars/dashboard-trends-sidebar/score-distributions/shi/score-distributions-shi-styles.module.scss
rename src/containers/sidebars/dashboard-trends-sidebar/score-distributions/{score-distributions-component.jsx => sii/score-distributions-sii-component.jsx} (86%)
create mode 100644 src/containers/sidebars/dashboard-trends-sidebar/score-distributions/sii/score-distributions-sii-styles.module.scss
create mode 100644 src/containers/sidebars/dashboard-trends-sidebar/score-distributions/spi/score-distributions-chart/index.js
rename src/containers/sidebars/dashboard-trends-sidebar/score-distributions/{score-distributions-chart/score-distribution-chart-component.jsx => spi/score-distributions-chart/score-distributions-chart-component.jsx} (66%)
create mode 100644 src/containers/sidebars/dashboard-trends-sidebar/score-distributions/spi/score-distributions-chart/score-distributions-chart-styles.module.scss
create mode 100644 src/containers/sidebars/dashboard-trends-sidebar/score-distributions/spi/score-distributions-spi-component.jsx
create mode 100644 src/containers/sidebars/dashboard-trends-sidebar/score-distributions/spi/score-distributions-spi-styles.module.scss
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/dashboard-trends-sidebar-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/dashboard-trends-sidebar-component.jsx
index 45f2d2854..7f23c4df8 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/dashboard-trends-sidebar-component.jsx
+++ b/src/containers/sidebars/dashboard-trends-sidebar/dashboard-trends-sidebar-component.jsx
@@ -1,9 +1,10 @@
import React, { useState } from 'react';
+import cx from 'classnames';
+
import styles from './dashboard-trends-sidebar-styles.module.scss';
import ScoreDistributionsContainer from './score-distributions';
import TemporalTrendsContainer from './temporal-trends';
-import cx from 'classnames';
export const NATIONAL_TREND = 'NATIONAL';
export const PROVINCE_TREND = 'PROVINCE';
@@ -26,7 +27,8 @@ function DashboardTrendsSidebar(props) {
className={cx({
[styles.selected]: selectedIndex === 1,
})}
- onClick={() => setSelectedIndex(1)}>
+ onClick={() => setSelectedIndex(1)}
+ >
98.63
Species Habitat Index
@@ -36,7 +38,8 @@ function DashboardTrendsSidebar(props) {
className={cx({
[styles.selected]: selectedIndex === 2,
})}
- onClick={() => setSelectedIndex(2)}>
+ onClick={() => setSelectedIndex(2)}
+ >
62.73
Species Protection Index
@@ -46,7 +49,8 @@ function DashboardTrendsSidebar(props) {
className={cx({
[styles.selected]: selectedIndex === 3,
})}
- onClick={() => setSelectedIndex(3)}>
+ onClick={() => setSelectedIndex(3)}
+ >
0.49
Species Information Index
@@ -57,6 +61,7 @@ function DashboardTrendsSidebar(props) {
countryData={countryData}
/>
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/dashboard-trends-sidebar-styles.module.scss b/src/containers/sidebars/dashboard-trends-sidebar/dashboard-trends-sidebar-styles.module.scss
index 53847e796..91a8fcb09 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/dashboard-trends-sidebar-styles.module.scss
+++ b/src/containers/sidebars/dashboard-trends-sidebar/dashboard-trends-sidebar-styles.module.scss
@@ -78,11 +78,12 @@ $trends-width: 950px;
}
-$info-width: 310px;
+$info-width: 300px;
.trends{
display: flex;
padding: $paragraph-gutter;
+ gap: 10px;
.info{
width: $info-width;
@@ -179,32 +180,6 @@ $info-width: 310px;
row-gap: 8px;
margin-top: 10px;
- .trendTypes{
- display: flex;
- gap: 3px;
- padding: 2px;
- border: 1px solid $brand-color-main;
- border-radius: 5px;
-
- .saveButton{
- border: none;
- }
- }
-
- .saveButton {
- color: $dark-text;
- background-color: $brand-color-main;
- &:hover {
- background-color: $brand-color-main-hover;
- }
- }
-
- .notActive{
- background-color: transparent;
- color: $white;
- border: 1px solid $brand-color-main;
- }
-
.helpText{
color: $white;
font-family: "Open Sans";
@@ -215,4 +190,30 @@ $info-width: 310px;
}
}
}
+
+ .btnGroup{
+ display: flex;
+ gap: 3px;
+ padding: 2px;
+ border: 1px solid $brand-color-main;
+ border-radius: 5px;
+
+ .saveButton{
+ border: none;
+ }
+ }
+
+ .saveButton {
+ color: $dark-text;
+ background-color: $brand-color-main;
+ &:hover {
+ background-color: $brand-color-main-hover;
+ }
+ }
+
+ .notActive{
+ background-color: transparent;
+ color: $white;
+ border: 1px solid $brand-color-main;
+ }
}
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/index.js b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/index.js
index 4da31c401..3aa9c05b9 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/index.js
+++ b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/index.js
@@ -1,9 +1,22 @@
import React from 'react';
-import ScoreDistributionsComponent from './score-distributions-component';
+import ScoreDistributionsShiComponent from './shi/score-distributions-shi-component';
+import ScoreDistributionsSiiComponent from './sii/score-distributions-sii-component';
+import ScoreDistributionsSpiComponent from './spi/score-distributions-spi-component';
function ScoreDistributionsContainer(props) {
- return ;
+ const { selectedIndex } = props;
+
+ if (selectedIndex === 1) {
+ return ;
+ }
+ if (selectedIndex === 2) {
+ return ;
+ }
+ if (selectedIndex === 3) {
+ return ;
+ }
+ return ;
}
export default ScoreDistributionsContainer;
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/score-distributions-chart/index.js b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/score-distributions-chart/index.js
deleted file mode 100644
index 128f1a7fe..000000000
--- a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/score-distributions-chart/index.js
+++ /dev/null
@@ -1,9 +0,0 @@
-import React from 'react';
-
-import ScoreDistributionChartComponent from './score-distribution-chart-component';
-
-function ScoreDistributionChartContainer(props) {
- return ;
-}
-
-export default ScoreDistributionChartContainer;
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/shi/distributions-chart/distributions-chart-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/shi/distributions-chart/distributions-chart-component.jsx
new file mode 100644
index 000000000..5b73f9ac0
--- /dev/null
+++ b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/shi/distributions-chart/distributions-chart-component.jsx
@@ -0,0 +1,336 @@
+/* eslint-disable camelcase */
+import React, { useEffect, useState } from 'react';
+import { Bar } from 'react-chartjs-2';
+
+import { getCSSVariable } from 'utils/css-utils';
+
+import {
+ Chart as ChartJS,
+ CategoryScale,
+ LinearScale,
+ ArcElement,
+ BarElement,
+ Title,
+ Tooltip,
+ Legend,
+} from 'chart.js';
+// import cx from 'classnames';
+
+// import Button from 'components/button';
+import SpiArcChartComponent from 'components/charts/spi-arc-chart/spi-arc-chart-component';
+
+import Amphibians from 'images/amphibians.svg';
+import Birds from 'images/birds.svg';
+import Mammals from 'images/mammals.svg';
+import Reptiles from 'images/reptiles.svg';
+
+// import dashStyles from '../../../dashboard-trends-sidebar-styles.module.scss';
+
+import styles from './distributions-chart-styles.module.scss';
+
+ChartJS.register(
+ CategoryScale,
+ LinearScale,
+ ArcElement,
+ BarElement,
+ Title,
+ Tooltip,
+ Legend
+);
+
+function DistributionsChartComponent(props) {
+ const { countryData, scoreDistributionData } = props;
+ const [scores, setScores] = useState({
+ birds: {
+ count: 0,
+ total: 0,
+ percentage: 0,
+ },
+ mammals: {
+ count: 0,
+ total: 0,
+ percentage: 0,
+ },
+ reptiles: {
+ count: 0,
+ total: 0,
+ percentage: 0,
+ },
+ amphibians: {
+ count: 0,
+ total: 0,
+ percentage: 0,
+ },
+ });
+
+ const [data, setData] = useState();
+
+ const getPercentage = (species) => {
+ const { count, total } = scores[species];
+ const percent = (count / total) * 100 || 0;
+ return [percent, 100 - percent];
+ };
+
+ const labels = [
+ '0',
+ '10',
+ '20',
+ '30',
+ '40',
+ '50',
+ '60',
+ '70',
+ '80',
+ '90',
+ '100',
+ ];
+
+ useEffect(() => {
+ if (countryData) {
+ const {
+ endemic_birds,
+ birds,
+ endemic_mammals,
+ mammals,
+ endemic_reptiles,
+ reptiles,
+ endemic_amphibians,
+ amphibians,
+ } = countryData;
+
+ setScores({
+ birds: {
+ count: endemic_birds,
+ total: birds,
+ },
+ mammals: {
+ count: endemic_mammals,
+ total: mammals,
+ },
+ reptiles: {
+ count: endemic_reptiles,
+ total: reptiles,
+ },
+ amphibians: {
+ count: endemic_amphibians,
+ total: amphibians,
+ },
+ });
+ }
+ }, [countryData]);
+
+ useEffect(() => {
+ if (scoreDistributionData) {
+ setData({
+ labels,
+ datasets: [
+ {
+ data: scoreDistributionData.map((item) => item[0]),
+ backgroundColor: getCSSVariable('birds'),
+ },
+ ],
+ });
+ }
+ }, [scoreDistributionData]);
+
+ const options = {
+ plugins: {
+ title: {
+ display: false,
+ },
+ legend: {
+ display: false,
+ },
+ },
+ responsive: true,
+ interaction: {
+ mode: 'index',
+ intersect: false,
+ },
+ scales: {
+ x: {
+ stacked: true,
+ display: true,
+ title: {
+ display: true,
+ text: 'Protection Score',
+ color: getCSSVariable('white'),
+ },
+ grid: {
+ color: getCSSVariable('oslo-gray'),
+ display: false,
+ },
+ ticks: {
+ color: getCSSVariable('oslo-gray'),
+ },
+ },
+ y: {
+ stacked: true,
+ display: true,
+ title: {
+ display: true,
+ text: 'Number of Species',
+ color: getCSSVariable('white'),
+ },
+ grid: {
+ color: getCSSVariable('oslo-gray'),
+ },
+ ticks: {
+ color: getCSSVariable('oslo-gray'),
+ },
+ },
+ },
+ };
+
+ // const labels = [
+ // '0', '10', '20', '30', '40', '50', '60', '70', '80', '90', '100'
+ // ];
+
+ // const data = {
+ // labels,
+ // datasets: [
+ // {
+ // label: 'Dataset 1',
+ // data: labels.map(() => faker.datatype.number({ min: 0, max: 250 })),
+ // backgroundColor: getCSSVariable('birds'),
+ // stack: 'Stack 0',
+ // },
+ // {
+ // label: 'Dataset 2',
+ // data: labels.map(() => faker.datatype.number({ min: 0, max: 250 })),
+ // backgroundColor: getCSSVariable('mammals'),
+ // stack: 'Stack 0',
+ // },
+ // {
+ // label: 'Dataset 3',
+ // data: labels.map(() => faker.datatype.number({ min: 0, max: 250 })),
+ // backgroundColor: getCSSVariable('reptiles'),
+ // stack: 'Stack 0',
+ // },
+ // {
+ // label: 'Dataset 4',
+ // data: labels.map(() => faker.datatype.number({ min: 0, max: 250 })),
+ // backgroundColor: getCSSVariable('amphibians'),
+ // stack: 'Stack 0',
+ // },
+ // ],
+ // };
+
+ const birdData = {
+ labels: ['Birds', 'Remaining'],
+ datasets: [
+ {
+ label: '',
+ data: getPercentage('birds'),
+ backgroundColor: [
+ getCSSVariable('birds'),
+ getCSSVariable('white-opacity-20'),
+ ],
+ borderColor: [
+ getCSSVariable('birds'),
+ getCSSVariable('white-opacity-20'),
+ ],
+ borderWidth: 1,
+ },
+ ],
+ };
+
+ const mammalsData = {
+ labels: ['Mammals', 'Remaining'],
+ datasets: [
+ {
+ label: '',
+ data: getPercentage('mammals'),
+ backgroundColor: [
+ getCSSVariable('mammals'),
+ getCSSVariable('white-opacity-20'),
+ ],
+ borderColor: [
+ getCSSVariable('mammals'),
+ getCSSVariable('white-opacity-20'),
+ ],
+ borderWidth: 1,
+ },
+ ],
+ };
+
+ const reptilesData = {
+ labels: ['Reptiles', 'Remaining'],
+ datasets: [
+ {
+ label: '',
+ data: getPercentage('reptiles'),
+ backgroundColor: [
+ getCSSVariable('reptiles'),
+ getCSSVariable('white-opacity-20'),
+ ],
+ borderColor: [
+ getCSSVariable('reptiles'),
+ getCSSVariable('white-opacity-20'),
+ ],
+ borderWidth: 1,
+ },
+ ],
+ };
+
+ const amphibianData = {
+ labels: ['Amphibians', 'Remaining'],
+ datasets: [
+ {
+ label: '',
+ data: getPercentage('amphibians'),
+ backgroundColor: [
+ getCSSVariable('amphibians'),
+ getCSSVariable('white-opacity-20'),
+ ],
+ borderColor: [
+ getCSSVariable('amphibians'),
+ getCSSVariable('white-opacity-20'),
+ ],
+ borderWidth: 1,
+ },
+ ],
+ };
+
+ return (
+
+
+
+
+
+
+
+
+
+
+
+ {data && (
+
+
+
+ )}
+
+ );
+}
+
+export default DistributionsChartComponent;
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/score-distributions-chart/score-distribution-chart-styles.module.scss b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/shi/distributions-chart/distributions-chart-styles.module.scss
similarity index 100%
rename from src/containers/sidebars/dashboard-trends-sidebar/score-distributions/score-distributions-chart/score-distribution-chart-styles.module.scss
rename to src/containers/sidebars/dashboard-trends-sidebar/score-distributions/shi/distributions-chart/distributions-chart-styles.module.scss
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/shi/distributions-chart/index.js b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/shi/distributions-chart/index.js
new file mode 100644
index 000000000..917872f80
--- /dev/null
+++ b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/shi/distributions-chart/index.js
@@ -0,0 +1,9 @@
+import React from 'react';
+
+import DistributionsChartComponent from './distributions-chart-component';
+
+function DistributionsChartContainer(props) {
+ return ;
+}
+
+export default DistributionsChartContainer;
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/shi/score-distributions-shi-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/shi/score-distributions-shi-component.jsx
new file mode 100644
index 000000000..f296706e4
--- /dev/null
+++ b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/shi/score-distributions-shi-component.jsx
@@ -0,0 +1,142 @@
+import React, { useEffect, useState } from 'react';
+
+import cx from 'classnames';
+
+import Button from 'components/button';
+
+import styles from '../../dashboard-trends-sidebar-styles.module.scss';
+
+import DistributionsChartComponent from './distributions-chart/distributions-chart-component';
+import compStyles from './score-distributions-shi-styles.module.scss';
+
+function ScoreDistributionsShiComponent(props) {
+ const { countryISO } = props;
+
+ const lowAvg = 'Amphibians';
+ const highAvg = 'birds';
+
+ const spsSpecies = [
+ {
+ name: 'Black-collared Apalis',
+ scientificname: 'Oreolais puncher',
+ },
+ {
+ name: 'Lomami Red Colobus',
+ scientificname: 'Piliocolobus parmentieri',
+ },
+ {
+ name: 'Grey-Winged Robin-Chat',
+ scientificname: 'Cossypha polioptera',
+ },
+ {
+ name: 'Palm Egg-Eater',
+ scientificname: 'Dasypeltis palmarum',
+ },
+ ];
+
+ const [scoreDistributionData, setScoreDistributionData] = useState();
+
+ const getScoreDistributionData = async () => {
+ const year = '2023';
+ const taxa = 'all_terr_verts';
+ const url = `https://next-api-dot-api-2-x-dot-map-of-life.appspot.com/2.x/indicators/sps/values?iso=${countryISO}&year=${year}&taxa=${taxa}`;
+
+ const response = await fetch(url);
+ const data = await response.json();
+ setScoreDistributionData(data.map((item) => [item.protection_score]));
+ console.log(scoreDistributionData);
+ };
+
+ useEffect(() => {
+ getScoreDistributionData();
+ }, []);
+
+ const [activeScore, setActiveScore] = useState('area');
+ const handleActiveChange = (event) => {
+ setActiveScore(event.currentTarget.innerText.toLowerCase());
+ };
+
+ return (
+
+
+
Score Distributions
+
+
+ View the distribution of the individual Species Protection Scores for
+ all terrestrial vertebrates. {lowAvg} have the lowest average
+ protection score while {highAvg} have the highest.
+
+
+
+ Species with SPS between 0.5:
+
+
+
+
+
+
+ Open and download a full table of species SPS and relevant traits at
+ national and province levels for a selected year.
+
+
+
+
+
+ );
+}
+
+export default ScoreDistributionsShiComponent;
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/shi/score-distributions-shi-styles.module.scss b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/shi/score-distributions-shi-styles.module.scss
new file mode 100644
index 000000000..beab144dc
--- /dev/null
+++ b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/shi/score-distributions-shi-styles.module.scss
@@ -0,0 +1,11 @@
+@import 'styles/ui.module';
+@import 'styles/settings';
+@import 'styles/typography-extends';
+@import 'styles/common-animations.module';
+
+.chartArea{
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ flex-grow: 1;
+}
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/score-distributions-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/sii/score-distributions-sii-component.jsx
similarity index 86%
rename from src/containers/sidebars/dashboard-trends-sidebar/score-distributions/score-distributions-component.jsx
rename to src/containers/sidebars/dashboard-trends-sidebar/score-distributions/sii/score-distributions-sii-component.jsx
index bc4151824..dc4b5b603 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/score-distributions-component.jsx
+++ b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/sii/score-distributions-sii-component.jsx
@@ -4,12 +4,10 @@ import cx from 'classnames';
import Button from 'components/button';
-import styles from '../dashboard-trends-sidebar-styles.module.scss';
+import styles from '../../dashboard-trends-sidebar-styles.module.scss';
-import ScoreDistributionChartContainer from './score-distributions-chart';
-
-function ScoreDistributionsComponent(props) {
- const {countryISO} = props;
+function ScoreDistributionsSiiComponent(props) {
+ const { countryISO } = props;
const lowAvg = 'Amphibians';
const highAvg = 'birds';
@@ -33,7 +31,7 @@ function ScoreDistributionsComponent(props) {
},
];
- const [scoreDistributionData, setScoreDistributionData] = useState()
+ const [scoreDistributionData, setScoreDistributionData] = useState();
const getScoreDistributionData = async () => {
const year = '2023';
@@ -42,8 +40,8 @@ function ScoreDistributionsComponent(props) {
const response = await fetch(url);
const data = await response.json();
- setScoreDistributionData(data.map(item => [item.protection_score]));
- }
+ setScoreDistributionData(data.map((item) => [item.protection_score]));
+ };
useEffect(() => {
getScoreDistributionData();
@@ -95,10 +93,8 @@ function ScoreDistributionsComponent(props) {
-
-
);
}
-export default ScoreDistributionsComponent;
+export default ScoreDistributionsSiiComponent;
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/sii/score-distributions-sii-styles.module.scss b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/sii/score-distributions-sii-styles.module.scss
new file mode 100644
index 000000000..c709bfc60
--- /dev/null
+++ b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/sii/score-distributions-sii-styles.module.scss
@@ -0,0 +1,4 @@
+@import 'styles/ui.module';
+@import 'styles/settings';
+@import 'styles/typography-extends';
+@import 'styles/common-animations.module';
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/spi/score-distributions-chart/index.js b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/spi/score-distributions-chart/index.js
new file mode 100644
index 000000000..ab5e996ea
--- /dev/null
+++ b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/spi/score-distributions-chart/index.js
@@ -0,0 +1,9 @@
+import React from 'react';
+
+import ScoreDistributionsChartComponent from './score-distributions-chart-component';
+
+function ScoreDistributionsChartContainer(props) {
+ return ;
+}
+
+export default ScoreDistributionsChartContainer;
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/score-distributions-chart/score-distribution-chart-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/spi/score-distributions-chart/score-distributions-chart-component.jsx
similarity index 66%
rename from src/containers/sidebars/dashboard-trends-sidebar/score-distributions/score-distributions-chart/score-distribution-chart-component.jsx
rename to src/containers/sidebars/dashboard-trends-sidebar/score-distributions/spi/score-distributions-chart/score-distributions-chart-component.jsx
index d5e9b5c68..eea7499c4 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/score-distributions-chart/score-distribution-chart-component.jsx
+++ b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/spi/score-distributions-chart/score-distributions-chart-component.jsx
@@ -2,7 +2,8 @@
import React, { useEffect, useState } from 'react';
import { Bar } from 'react-chartjs-2';
-import { faker } from '@faker-js/faker';
+import { getCSSVariable } from 'utils/css-utils';
+
import {
Chart as ChartJS,
CategoryScale,
@@ -16,14 +17,12 @@ import {
import SpiArcChartComponent from 'components/charts/spi-arc-chart/spi-arc-chart-component';
-import { getCSSVariable } from 'utils/css-utils';
-
import Amphibians from 'images/amphibians.svg';
import Birds from 'images/birds.svg';
import Mammals from 'images/mammals.svg';
import Reptiles from 'images/reptiles.svg';
-import styles from './score-distribution-chart-styles.module.scss';
+import styles from './score-distributions-chart-styles.module.scss';
ChartJS.register(
CategoryScale,
@@ -35,7 +34,7 @@ ChartJS.register(
Legend
);
-function ScoreDistributionChartComponent(props) {
+function ScoreDistributionsChartComponent(props) {
const { countryData, scoreDistributionData } = props;
const [scores, setScores] = useState({
birds: {
@@ -69,8 +68,18 @@ function ScoreDistributionChartComponent(props) {
};
const labels = [
- '0', '10', '20', '30', '40', '50', '60', '70', '80', '90', '100'
- ];
+ '0',
+ '10',
+ '20',
+ '30',
+ '40',
+ '50',
+ '60',
+ '70',
+ '80',
+ '90',
+ '100',
+ ];
useEffect(() => {
if (countryData) {
@@ -107,13 +116,15 @@ function ScoreDistributionChartComponent(props) {
}, [countryData]);
useEffect(() => {
- if(scoreDistributionData){
+ if (scoreDistributionData) {
setData({
labels,
- datasets: [{
- data: scoreDistributionData.map(item => item[0]),
- backgroundColor: getCSSVariable('birds'),
- }]
+ datasets: [
+ {
+ data: scoreDistributionData.map((item) => item[0]),
+ backgroundColor: getCSSVariable('birds'),
+ },
+ ],
});
}
}, [scoreDistributionData]);
@@ -173,32 +184,32 @@ function ScoreDistributionChartComponent(props) {
// const data = {
// labels,
- // datasets: [
- // {
- // label: 'Dataset 1',
- // data: labels.map(() => faker.datatype.number({ min: 0, max: 250 })),
- // backgroundColor: getCSSVariable('birds'),
- // stack: 'Stack 0',
- // },
- // {
- // label: 'Dataset 2',
- // data: labels.map(() => faker.datatype.number({ min: 0, max: 250 })),
- // backgroundColor: getCSSVariable('mammals'),
- // stack: 'Stack 0',
- // },
- // {
- // label: 'Dataset 3',
- // data: labels.map(() => faker.datatype.number({ min: 0, max: 250 })),
- // backgroundColor: getCSSVariable('reptiles'),
- // stack: 'Stack 0',
- // },
- // {
- // label: 'Dataset 4',
- // data: labels.map(() => faker.datatype.number({ min: 0, max: 250 })),
- // backgroundColor: getCSSVariable('amphibians'),
- // stack: 'Stack 0',
- // },
- // ],
+ // datasets: [
+ // {
+ // label: 'Dataset 1',
+ // data: labels.map(() => faker.datatype.number({ min: 0, max: 250 })),
+ // backgroundColor: getCSSVariable('birds'),
+ // stack: 'Stack 0',
+ // },
+ // {
+ // label: 'Dataset 2',
+ // data: labels.map(() => faker.datatype.number({ min: 0, max: 250 })),
+ // backgroundColor: getCSSVariable('mammals'),
+ // stack: 'Stack 0',
+ // },
+ // {
+ // label: 'Dataset 3',
+ // data: labels.map(() => faker.datatype.number({ min: 0, max: 250 })),
+ // backgroundColor: getCSSVariable('reptiles'),
+ // stack: 'Stack 0',
+ // },
+ // {
+ // label: 'Dataset 4',
+ // data: labels.map(() => faker.datatype.number({ min: 0, max: 250 })),
+ // backgroundColor: getCSSVariable('amphibians'),
+ // stack: 'Stack 0',
+ // },
+ // ],
// };
const birdData = {
@@ -207,8 +218,14 @@ function ScoreDistributionChartComponent(props) {
{
label: '',
data: getPercentage('birds'),
- backgroundColor: [getCSSVariable('birds'), getCSSVariable('white-opacity-20')],
- borderColor: [getCSSVariable('birds'), getCSSVariable('white-opacity-20')],
+ backgroundColor: [
+ getCSSVariable('birds'),
+ getCSSVariable('white-opacity-20'),
+ ],
+ borderColor: [
+ getCSSVariable('birds'),
+ getCSSVariable('white-opacity-20'),
+ ],
borderWidth: 1,
},
],
@@ -220,8 +237,14 @@ function ScoreDistributionChartComponent(props) {
{
label: '',
data: getPercentage('mammals'),
- backgroundColor: [getCSSVariable('mammals'), getCSSVariable('white-opacity-20')],
- borderColor: [getCSSVariable('mammals'), getCSSVariable('white-opacity-20')],
+ backgroundColor: [
+ getCSSVariable('mammals'),
+ getCSSVariable('white-opacity-20'),
+ ],
+ borderColor: [
+ getCSSVariable('mammals'),
+ getCSSVariable('white-opacity-20'),
+ ],
borderWidth: 1,
},
],
@@ -233,8 +256,14 @@ function ScoreDistributionChartComponent(props) {
{
label: '',
data: getPercentage('reptiles'),
- backgroundColor: [getCSSVariable('reptiles'), getCSSVariable('white-opacity-20')],
- borderColor: [getCSSVariable('reptiles'), getCSSVariable('white-opacity-20')],
+ backgroundColor: [
+ getCSSVariable('reptiles'),
+ getCSSVariable('white-opacity-20'),
+ ],
+ borderColor: [
+ getCSSVariable('reptiles'),
+ getCSSVariable('white-opacity-20'),
+ ],
borderWidth: 1,
},
],
@@ -246,8 +275,14 @@ function ScoreDistributionChartComponent(props) {
{
label: '',
data: getPercentage('amphibians'),
- backgroundColor: [getCSSVariable('amphibians'), getCSSVariable('white-opacity-20')],
- borderColor: [getCSSVariable('amphibians'), getCSSVariable('white-opacity-20')],
+ backgroundColor: [
+ getCSSVariable('amphibians'),
+ getCSSVariable('white-opacity-20'),
+ ],
+ borderColor: [
+ getCSSVariable('amphibians'),
+ getCSSVariable('white-opacity-20'),
+ ],
borderWidth: 1,
},
],
@@ -286,11 +321,13 @@ function ScoreDistributionChartComponent(props) {
/>
- {data &&
-
-
}
+ {data && (
+
+
+
+ )}
);
}
-export default ScoreDistributionChartComponent;
+export default ScoreDistributionsChartComponent;
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/spi/score-distributions-chart/score-distributions-chart-styles.module.scss b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/spi/score-distributions-chart/score-distributions-chart-styles.module.scss
new file mode 100644
index 000000000..8b31c12e8
--- /dev/null
+++ b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/spi/score-distributions-chart/score-distributions-chart-styles.module.scss
@@ -0,0 +1,82 @@
+@import 'styles/ui.module';
+@import 'styles/settings';
+@import 'styles/typography-extends';
+@import 'styles/common-animations.module';
+
+.container{
+ display: flex;
+ flex-direction: column;
+ padding: 10px 5px 10px 26px;
+ flex-grow: 1;
+ align-items: center;
+ gap: 8px;
+
+ .title{
+ color: $white;
+ font-family: "Open Sans";
+ font-size: 15px;
+ font-style: normal;
+ font-weight: 700;
+ line-height: normal;
+ text-transform: uppercase;
+ }
+
+ .spis{
+ display: flex;
+ gap: 10px;
+ align-items: center;
+ width: 100%;
+ justify-content: center;
+ border-radius: 5px;
+ border: 1.5px solid $brand-color-main;
+ box-shadow: -2px 4px 4px 0px rgba(0, 0, 0, 0.25);
+ padding: 15px 0;
+
+ .spi{
+ display: flex;
+ flex-direction: column;
+ justify-content: center;
+ align-items: center;
+
+ .score{
+ color: #FFF;
+ text-align: center;
+ font-family: "Open Sans";
+ font-size: 20px;
+ font-style: normal;
+ font-weight: 700;
+ line-height: normal;
+ margin-bottom: -20px;
+ }
+
+ .taxoGroup{
+ display: flex;
+ flex-direction: column;
+ margin-top: -60px;
+ align-items: center;
+
+ .richness{
+ color: #FFF;
+ text-align: center;
+ font-family: "Open Sans";
+ font-size: 11px;
+ font-style: italic;
+ font-weight: 400;
+ line-height: normal;
+ }
+
+ .score{
+ font-size: 16px;
+ font-weight: 600;
+ text-transform: uppercase;
+ margin-bottom: 0;
+ }
+ }
+ }
+ }
+
+ .chart{
+ width: 100%;
+ margin-top: 25px;
+ }
+}
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/spi/score-distributions-spi-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/spi/score-distributions-spi-component.jsx
new file mode 100644
index 000000000..58689d85e
--- /dev/null
+++ b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/spi/score-distributions-spi-component.jsx
@@ -0,0 +1,107 @@
+import React, { useEffect, useState } from 'react';
+
+import cx from 'classnames';
+
+import Button from 'components/button';
+
+import styles from '../../dashboard-trends-sidebar-styles.module.scss';
+
+import ScoreDistributionsChartContainer from './score-distributions-chart';
+
+function ScoreDistributionsSpiComponent(props) {
+ const { countryISO } = props;
+
+ const lowAvg = 'Amphibians';
+ const highAvg = 'birds';
+
+ const spsSpecies = [
+ {
+ name: 'Black-collared Apalis',
+ scientificname: 'Oreolais puncher',
+ },
+ {
+ name: 'Lomami Red Colobus',
+ scientificname: 'Piliocolobus parmentieri',
+ },
+ {
+ name: 'Grey-Winged Robin-Chat',
+ scientificname: 'Cossypha polioptera',
+ },
+ {
+ name: 'Palm Egg-Eater',
+ scientificname: 'Dasypeltis palmarum',
+ },
+ ];
+
+ const [scoreDistributionData, setScoreDistributionData] = useState();
+
+ const getScoreDistributionData = async () => {
+ const year = '2023';
+ const taxa = 'all_terr_verts';
+ const url = `https://next-api-dot-api-2-x-dot-map-of-life.appspot.com/2.x/indicators/sps/values?iso=${countryISO}&year=${year}&taxa=${taxa}`;
+
+ const response = await fetch(url);
+ const data = await response.json();
+ setScoreDistributionData(data.map((item) => [item.protection_score]));
+ };
+
+ useEffect(() => {
+ getScoreDistributionData();
+ }, []);
+
+ return (
+
+
+
Score Distributions
+
+
+ View the distribution of the individual Species Protection Scores for
+ all terrestrial vertebrates. {lowAvg} have the lowest average
+ protection score while {highAvg} have the highest.
+
+
+
+ Species with SPS between 0.5:
+
+
+
+
+
+
+ Open and download a full table of species SPS and relevant traits at
+ national and province levels for a selected year.
+
+
+
+
+
+
+ );
+}
+
+export default ScoreDistributionsSpiComponent;
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/spi/score-distributions-spi-styles.module.scss b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/spi/score-distributions-spi-styles.module.scss
new file mode 100644
index 000000000..c709bfc60
--- /dev/null
+++ b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/spi/score-distributions-spi-styles.module.scss
@@ -0,0 +1,4 @@
+@import 'styles/ui.module';
+@import 'styles/settings';
+@import 'styles/typography-extends';
+@import 'styles/common-animations.module';
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/shi/temporal-trends-shi-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/shi/temporal-trends-shi-component.jsx
index c515f0d04..430774599 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/shi/temporal-trends-shi-component.jsx
+++ b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/shi/temporal-trends-shi-component.jsx
@@ -54,16 +54,13 @@ function TemporalTrendsShiComponent(props) {
Connectivity Score addresses changes in the fragmentation of habitat.
-
-
-
+
+
Toggle national SPI and province-level breakdown.
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/spi/temporal-trends-spi-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/spi/temporal-trends-spi-component.jsx
index 06e2d80c6..17775a7b7 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/spi/temporal-trends-spi-component.jsx
+++ b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/spi/temporal-trends-spi-component.jsx
@@ -9,15 +9,18 @@ import {
PROVINCE_TREND,
} from '../../dashboard-trends-sidebar-component';
import styles from '../../dashboard-trends-sidebar-styles.module.scss';
+
import NationalChartContainer from './national-chart';
import ProvinceChartContainer from './province-chart';
-
function TemporalTrendsSpiComponent(props) {
const { countryData } = props;
const [activeTrend, setActiveTrend] = useState(NATIONAL_TREND);
- const [nationalChartData, setNationalChartData] = useState({ area_values: [], spi_values: [] });
+ const [nationalChartData, setNationalChartData] = useState({
+ area_values: [],
+ spi_values: [],
+ });
const getNationalData = async () => {
const region_id = '90b03e87-3880-4164-a310-339994e3f919';
@@ -28,32 +31,28 @@ function TemporalTrendsSpiComponent(props) {
const data = await response.json();
const { area_values, spi_values } = data[0].values;
setNationalChartData({ area_values, spi_values });
- }
-
+ };
useEffect(() => {
getNationalData();
}, []);
-
const handleActionChange = (event) => {
setActiveTrend(event.currentTarget.innerText);
};
-
-
return (
Temporal Trends
- Since 1980, the {countryData?.NAME_0} has added 328357 km2
- of land into its protected area network, representing 14% of the total
+ Since 1980, the {countryData?.NAME_0} has added 328357 km2 of
+ land into its protected area network, representing 14% of the total
land in the country, increasing its Species Protection Index from
27.21 in 1980 to 63 in 2023.
-
+
{activeTrend === NATIONAL_TREND && (
-
- )}
- {activeTrend === PROVINCE_TREND && (
-
+
)}
+ {activeTrend === PROVINCE_TREND && }
);
}
From 3602bb58f4ba7ef6f7d16d1aa1fae5f8cdaa317a Mon Sep 17 00:00:00 2001
From: Chris Manciero
Date: Tue, 16 Jul 2024 11:06:56 -0400
Subject: [PATCH 032/350] shi temporal trend chart
---
.../dashboard-trends-sidebar-component.jsx | 1 +
.../distributions-chart-component.jsx | 142 ++++++++++--------
.../distributions-chart-styles.module.scss | 1 +
.../shi/score-distributions-shi-component.jsx | 18 ++-
...score-distributions-shi-styles.module.scss | 4 +
.../national-chart-component.jsx | 70 ++++-----
.../shi/temporal-trends-shi-component.jsx | 15 +-
7 files changed, 147 insertions(+), 104 deletions(-)
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/dashboard-trends-sidebar-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/dashboard-trends-sidebar-component.jsx
index 7f23c4df8..ff56d7830 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/dashboard-trends-sidebar-component.jsx
+++ b/src/containers/sidebars/dashboard-trends-sidebar/dashboard-trends-sidebar-component.jsx
@@ -59,6 +59,7 @@ function DashboardTrendsSidebar(props) {
{
- if (countryData) {
+ if (chartData) {
+
const {
endemic_birds,
birds,
@@ -117,21 +99,75 @@ function DistributionsChartComponent(props) {
},
});
}
- }, [countryData]);
+ }, [chartData]);
useEffect(() => {
- if (scoreDistributionData) {
+ if (chartData) {
+ const ampSet = getHistogramData('AMPHIBIA');
+ const mamSet = getHistogramData('MAMMALIA');
+ const repSet = getHistogramData('REPTILIA');
+ const birdSet = getHistogramData('AVES');
+
+ const taxaSet = {};
+
+ chartData.forEach(a => {
+ let floorScore;
+ if (chartType === 'area') {
+ floorScore = Math.floor(a.area_score);
+ } else if (chartType === 'habitat score') {
+ floorScore = Math.floor((a.area_score + a.connectivity_score) / 2);
+ } else if (chartType === 'connectivity') {
+ floorScore = Math.floor(a.connectivity_score);
+ }
+
+ if (!taxaSet.hasOwnProperty(floorScore)) {
+ taxaSet[floorScore] = 1;
+ } else {
+ taxaSet[floorScore] += 1;
+ }
+ });
+
setData({
- labels,
datasets: [
+ // {
+ // label: '# of occurance',
+ // data: ampSet,
+ // backgroundColor: getCSSVariable('amphibians'),
+ // stack: 'Stack 0',
+ // barPercentage: 1,
+ // },
+ // {
+ // label: '# of occurance',
+ // data: mamSet,
+ // backgroundColor: getCSSVariable('mammals'),
+ // stack: 'Stack 0',
+ // barPercentage: 1,
+ // },
+ // {
+ // label: '# of occurance',
+ // data: repSet,
+ // backgroundColor: getCSSVariable('reptiles'),
+ // stack: 'Stack 0',
+ // barPercentage: 1,
+ // },
+ // {
+ // label: '# of occurance',
+ // data: birdSet,
+ // backgroundColor: getCSSVariable('birds'),
+ // stack: 'Stack 0',
+ // barPercentage: 1,
+ // },
{
- data: scoreDistributionData.map((item) => item[0]),
+ label: '# of occurance',
+ data: taxaSet,
backgroundColor: getCSSVariable('birds'),
+ stack: 'Stack 0',
+ barPercentage: 1,
},
],
});
}
- }, [scoreDistributionData]);
+ }, [chartData, chartType]);
const options = {
plugins: {
@@ -149,6 +185,8 @@ function DistributionsChartComponent(props) {
},
scales: {
x: {
+ type: 'linear',
+ offset: false,
stacked: true,
display: true,
title: {
@@ -159,9 +197,11 @@ function DistributionsChartComponent(props) {
grid: {
color: getCSSVariable('oslo-gray'),
display: false,
+ offset: false,
},
ticks: {
color: getCSSVariable('oslo-gray'),
+ stepSize: 25,
},
},
y: {
@@ -177,45 +217,12 @@ function DistributionsChartComponent(props) {
},
ticks: {
color: getCSSVariable('oslo-gray'),
+ stepSize: 10,
},
},
},
};
- // const labels = [
- // '0', '10', '20', '30', '40', '50', '60', '70', '80', '90', '100'
- // ];
-
- // const data = {
- // labels,
- // datasets: [
- // {
- // label: 'Dataset 1',
- // data: labels.map(() => faker.datatype.number({ min: 0, max: 250 })),
- // backgroundColor: getCSSVariable('birds'),
- // stack: 'Stack 0',
- // },
- // {
- // label: 'Dataset 2',
- // data: labels.map(() => faker.datatype.number({ min: 0, max: 250 })),
- // backgroundColor: getCSSVariable('mammals'),
- // stack: 'Stack 0',
- // },
- // {
- // label: 'Dataset 3',
- // data: labels.map(() => faker.datatype.number({ min: 0, max: 250 })),
- // backgroundColor: getCSSVariable('reptiles'),
- // stack: 'Stack 0',
- // },
- // {
- // label: 'Dataset 4',
- // data: labels.map(() => faker.datatype.number({ min: 0, max: 250 })),
- // backgroundColor: getCSSVariable('amphibians'),
- // stack: 'Stack 0',
- // },
- // ],
- // };
-
const birdData = {
labels: ['Birds', 'Remaining'],
datasets: [
@@ -292,6 +299,21 @@ function DistributionsChartComponent(props) {
],
};
+ const getHistogramData = (taxa) => {
+ const taxaGroup = chartData.filter(item => item.taxa === taxa);
+ const taxaSet = {};
+
+ taxaGroup.forEach(a => {
+ const floorScore = Math.floor(a.area_score);
+ if (!taxaSet.hasOwnProperty(floorScore)) {
+ taxaSet[floorScore] = 1;
+ } else {
+ taxaSet[floorScore] += 1;
+ }
+ });
+ return taxaSet;
+ }
+
return (
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/shi/distributions-chart/distributions-chart-styles.module.scss b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/shi/distributions-chart/distributions-chart-styles.module.scss
index 8b31c12e8..3785faf6c 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/shi/distributions-chart/distributions-chart-styles.module.scss
+++ b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/shi/distributions-chart/distributions-chart-styles.module.scss
@@ -10,6 +10,7 @@
flex-grow: 1;
align-items: center;
gap: 8px;
+ width: 100%;
.title{
color: $white;
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/shi/score-distributions-shi-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/shi/score-distributions-shi-component.jsx
index f296706e4..3b3d64311 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/shi/score-distributions-shi-component.jsx
+++ b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/shi/score-distributions-shi-component.jsx
@@ -35,6 +35,7 @@ function ScoreDistributionsShiComponent(props) {
];
const [scoreDistributionData, setScoreDistributionData] = useState();
+ const [chartData, setChartData] = useState();
const getScoreDistributionData = async () => {
const year = '2023';
@@ -43,12 +44,23 @@ function ScoreDistributionsShiComponent(props) {
const response = await fetch(url);
const data = await response.json();
+
setScoreDistributionData(data.map((item) => [item.protection_score]));
- console.log(scoreDistributionData);
};
+ const getChartData = async () => {
+ const year = '2021';
+ const url = `https://next-api-dot-api-2-x-dot-map-of-life.appspot.com/2.x/indicators/shs/values?iso=${countryISO}&year=${year}`;
+
+ const response = await fetch(url);
+ const data = await response.json();
+ console.log(data);
+ setChartData(data);
+ }
+
useEffect(() => {
getScoreDistributionData();
+ getChartData();
}, []);
const [activeScore, setActiveScore] = useState('area');
@@ -103,7 +115,7 @@ function ScoreDistributionsShiComponent(props) {
-
+
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/shi/score-distributions-shi-styles.module.scss b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/shi/score-distributions-shi-styles.module.scss
index beab144dc..bb6ddb8b7 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/shi/score-distributions-shi-styles.module.scss
+++ b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/shi/score-distributions-shi-styles.module.scss
@@ -8,4 +8,8 @@
flex-direction: column;
align-items: center;
flex-grow: 1;
+
+ .btnGroup{
+ width: 75%;
+ }
}
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/shi/national-chart/national-chart-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/shi/national-chart/national-chart-component.jsx
index 2964cca08..d4af14a2c 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/shi/national-chart/national-chart-component.jsx
+++ b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/shi/national-chart/national-chart-component.jsx
@@ -19,7 +19,7 @@ import styles from './national-chart-styles.module.scss';
ChartJS.register(LinearScale, LineElement, PointElement, Tooltip, Legend);
function NationalChartComponent(props) {
- const { countryData, nationalChartData } = props;
+ const { countryData, nationalChartData, chartData } = props;
const [data, setData] = useState();
const [spiValue, setSpiValue] = useState(0);
@@ -66,6 +66,7 @@ function NationalChartComponent(props) {
},
ticks: {
color: getCSSVariable('oslo-gray'),
+ maxTicksLimit: 8
},
},
y: {
@@ -86,50 +87,10 @@ function NationalChartComponent(props) {
},
};
- // useEffect(() => {
- // console.log(countryData)
- // if (countryData) {
- // const spi = {
- // labels: ['Global SPI', 'Remaining'],
- // datasets: [
- // {
- // label: '',
- // data: [
- // countryData.Global_SPI_ter,
- // 100 - countryData.Global_SPI_ter,
- // ],
- // backgroundColor: [
- // getCSSVariable('temporal-spi'),
- // getCSSVariable('white-opacity-20'),
- // ],
- // borderColor: [getCSSVariable('temporal-spi'), getCSSVariable('white-opacity-20')],
- // borderWidth: 1,
- // },
- // ],
- // };
-
- // setSpiData(spi);
- // }
- // }, [countryData]);
useEffect(() => {
if (nationalChartData.area_values.length) {
console.log(nationalChartData);
- setData({
- labels: nationalChartData.spi_values.map((item) => item[0]),
- datasets: [
- {
- label: 'SHI',
- data: nationalChartData.spi_values.map((item) => item[1]),
- borderColor: getCSSVariable('birds'),
- },
- {
- label: 'Area protected',
- data: nationalChartData.area_values.map((item) => item[1]),
- borderColor: getCSSVariable('mammals'),
- },
- ],
- });
const spiVal =
nationalChartData.spi_values[
nationalChartData.spi_values.length - 1
@@ -159,6 +120,33 @@ function NationalChartComponent(props) {
}
}, [nationalChartData]);
+ useEffect(() => {
+ if (chartData) {
+ setData({
+ labels: chartData.map((item) => item.year),
+ datasets: [
+ {
+ label: 'Average Area Score',
+ data: chartData.map((item) => item.avg_area),
+ borderColor: getCSSVariable('birds'),
+ },
+ {
+ label: 'Average Connectivity Score',
+ data: chartData.map((item) => item.avg_conn),
+ borderColor: getCSSVariable('mammals'),
+ },
+ {
+ label: 'Average Habitat Score',
+ data: chartData.map((item) => (item.avg_area + item.avg_conn) / 2),
+ borderColor: getCSSVariable('reptiles'),
+ },
+ ],
+ });
+ }
+
+ }, [chartData])
+
+
return (
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/shi/temporal-trends-shi-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/shi/temporal-trends-shi-component.jsx
index 430774599..c639aaa2e 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/shi/temporal-trends-shi-component.jsx
+++ b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/shi/temporal-trends-shi-component.jsx
@@ -13,13 +13,15 @@ import styles from '../../dashboard-trends-sidebar-styles.module.scss';
import NationalChartContainer from './national-chart';
function TemporalTrendsShiComponent(props) {
- const { activeTrend, updateActiveTrend, countryData, selectedIndex } = props;
+ const { activeTrend, updateActiveTrend, countryData, selectedIndex, countryISO } = props;
const [nationalChartData, setNationalChartData] = useState({
area_values: [],
spi_values: [],
});
+ const [chartData, setChartData] = useState();
+
const getNationalData = async () => {
const region_id = '90b03e87-3880-4164-a310-339994e3f919';
const taxa = 'all_terr_verts';
@@ -31,8 +33,18 @@ function TemporalTrendsShiComponent(props) {
setNationalChartData({ area_values, spi_values });
};
+ const getChartData = async () => {
+ const url = `https://next-api-dot-api-2-x-dot-map-of-life.appspot.com/2.x/indicators/shs/trend?iso=${countryISO}`;
+
+ const response = await fetch(url);
+ const data = await response.json();
+ console.log(data);
+ setChartData(data);
+ }
+
useEffect(() => {
getNationalData();
+ getChartData();
}, []);
const handleActionChange = (event) => {
@@ -77,6 +89,7 @@ function TemporalTrendsShiComponent(props) {
From 008ad85a3fa34d437ec5c7d7d3f873e8e10dbd51 Mon Sep 17 00:00:00 2001
From: Chris Manciero
Date: Wed, 17 Jul 2024 10:38:59 -0400
Subject: [PATCH 033/350] bunch of refactoring
---
.../distribution-chart-component.jsx | 40 ++
.../distribution-chart-styles.module.scss | 28 ++
.../charts/distribution-chart/index.js | 3 +
src/components/species-richness/index.js | 3 +
.../species-richness-component.jsx} | 148 +-------
.../species-richness-styles.module.scss} | 15 -
.../distributions-chart-component.jsx | 358 ------------------
.../shi/distributions-chart/index.js | 9 -
.../distributions-table-component.jsx | 168 ++++++++
.../distributions-table-styles.module.scss | 27 ++
.../shi/distributions-table/index.js | 9 +
.../shi/score-distributions-shi-component.jsx | 239 +++++++++---
.../sii/score-distributions-sii-component.jsx | 105 ++++-
...score-distributions-sii-styles.module.scss | 11 +
.../spi/score-distributions-chart/index.js | 9 -
...ore-distributions-chart-styles.module.scss | 82 ----
.../spi/score-distributions-spi-component.jsx | 109 +++++-
...score-distributions-spi-styles.module.scss | 21 +
.../national-chart-component.jsx | 2 +-
.../shi/temporal-trends-shi-component.jsx | 1 -
.../national-chart-component.jsx | 15 +-
.../sii/temporal-trends-sii-component.jsx | 12 +-
.../national-chart-component.jsx | 1 -
.../dashboard-trends-view-component.jsx | 2 -
24 files changed, 720 insertions(+), 697 deletions(-)
create mode 100644 src/components/charts/distribution-chart/distribution-chart-component.jsx
create mode 100644 src/components/charts/distribution-chart/distribution-chart-styles.module.scss
create mode 100644 src/components/charts/distribution-chart/index.js
create mode 100644 src/components/species-richness/index.js
rename src/{containers/sidebars/dashboard-trends-sidebar/score-distributions/spi/score-distributions-chart/score-distributions-chart-component.jsx => components/species-richness/species-richness-component.jsx} (57%)
rename src/{containers/sidebars/dashboard-trends-sidebar/score-distributions/shi/distributions-chart/distributions-chart-styles.module.scss => components/species-richness/species-richness-styles.module.scss} (85%)
delete mode 100644 src/containers/sidebars/dashboard-trends-sidebar/score-distributions/shi/distributions-chart/distributions-chart-component.jsx
delete mode 100644 src/containers/sidebars/dashboard-trends-sidebar/score-distributions/shi/distributions-chart/index.js
create mode 100644 src/containers/sidebars/dashboard-trends-sidebar/score-distributions/shi/distributions-table/distributions-table-component.jsx
create mode 100644 src/containers/sidebars/dashboard-trends-sidebar/score-distributions/shi/distributions-table/distributions-table-styles.module.scss
create mode 100644 src/containers/sidebars/dashboard-trends-sidebar/score-distributions/shi/distributions-table/index.js
delete mode 100644 src/containers/sidebars/dashboard-trends-sidebar/score-distributions/spi/score-distributions-chart/index.js
delete mode 100644 src/containers/sidebars/dashboard-trends-sidebar/score-distributions/spi/score-distributions-chart/score-distributions-chart-styles.module.scss
diff --git a/src/components/charts/distribution-chart/distribution-chart-component.jsx b/src/components/charts/distribution-chart/distribution-chart-component.jsx
new file mode 100644
index 000000000..bb9a8f7b1
--- /dev/null
+++ b/src/components/charts/distribution-chart/distribution-chart-component.jsx
@@ -0,0 +1,40 @@
+/* eslint-disable camelcase */
+import React from 'react';
+import { Bar } from 'react-chartjs-2';
+
+import {
+ Chart as ChartJS,
+ CategoryScale,
+ LinearScale,
+ BarElement,
+ Title,
+ Tooltip,
+ Legend,
+} from 'chart.js';
+
+import styles from './distribution-chart-styles.module.scss';
+
+ChartJS.register(
+ CategoryScale,
+ LinearScale,
+ BarElement,
+ Title,
+ Tooltip,
+ Legend
+);
+
+function DistributionsChartComponent(props) {
+ const { options, data } = props;
+
+ return (
+
+ {data && (
+
+
+
+ )}
+
+ );
+}
+
+export default DistributionsChartComponent;
diff --git a/src/components/charts/distribution-chart/distribution-chart-styles.module.scss b/src/components/charts/distribution-chart/distribution-chart-styles.module.scss
new file mode 100644
index 000000000..5e1cc4611
--- /dev/null
+++ b/src/components/charts/distribution-chart/distribution-chart-styles.module.scss
@@ -0,0 +1,28 @@
+@import 'styles/ui.module';
+@import 'styles/settings';
+@import 'styles/typography-extends';
+@import 'styles/common-animations.module';
+
+.container{
+ display: flex;
+ flex-direction: column;
+ padding: 10px 5px 10px 26px;
+ flex-grow: 1;
+ align-items: center;
+ gap: 8px;
+ width: 100%;
+
+ .title{
+ color: $white;
+ font-family: "Open Sans";
+ font-size: 15px;
+ font-style: normal;
+ font-weight: 700;
+ line-height: normal;
+ text-transform: uppercase;
+ }
+
+ .chart{
+ width: 100%;
+ }
+}
diff --git a/src/components/charts/distribution-chart/index.js b/src/components/charts/distribution-chart/index.js
new file mode 100644
index 000000000..2a8b8c479
--- /dev/null
+++ b/src/components/charts/distribution-chart/index.js
@@ -0,0 +1,3 @@
+import Component from './distribution-chart-component';
+
+export default Component;
diff --git a/src/components/species-richness/index.js b/src/components/species-richness/index.js
new file mode 100644
index 000000000..f6a16c2e1
--- /dev/null
+++ b/src/components/species-richness/index.js
@@ -0,0 +1,3 @@
+import Component from './species-richness-component';
+
+export default Component;
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/spi/score-distributions-chart/score-distributions-chart-component.jsx b/src/components/species-richness/species-richness-component.jsx
similarity index 57%
rename from src/containers/sidebars/dashboard-trends-sidebar/score-distributions/spi/score-distributions-chart/score-distributions-chart-component.jsx
rename to src/components/species-richness/species-richness-component.jsx
index eea7499c4..f6ded7064 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/spi/score-distributions-chart/score-distributions-chart-component.jsx
+++ b/src/components/species-richness/species-richness-component.jsx
@@ -1,9 +1,11 @@
-/* eslint-disable camelcase */
import React, { useEffect, useState } from 'react';
-import { Bar } from 'react-chartjs-2';
-
+import styles from './species-richness-styles.module.scss';
+import SpiArcChartComponent from '../charts/spi-arc-chart/spi-arc-chart-component';
+import Amphibians from 'images/amphibians.svg';
+import Birds from 'images/birds.svg';
+import Mammals from 'images/mammals.svg';
import { getCSSVariable } from 'utils/css-utils';
-
+import Reptiles from 'images/reptiles.svg';
import {
Chart as ChartJS,
CategoryScale,
@@ -15,15 +17,6 @@ import {
Legend,
} from 'chart.js';
-import SpiArcChartComponent from 'components/charts/spi-arc-chart/spi-arc-chart-component';
-
-import Amphibians from 'images/amphibians.svg';
-import Birds from 'images/birds.svg';
-import Mammals from 'images/mammals.svg';
-import Reptiles from 'images/reptiles.svg';
-
-import styles from './score-distributions-chart-styles.module.scss';
-
ChartJS.register(
CategoryScale,
LinearScale,
@@ -34,8 +27,9 @@ ChartJS.register(
Legend
);
-function ScoreDistributionsChartComponent(props) {
- const { countryData, scoreDistributionData } = props;
+function SpeciesRichnessComponent(props) {
+ const { countryData } = props;
+
const [scores, setScores] = useState({
birds: {
count: 0,
@@ -59,28 +53,12 @@ function ScoreDistributionsChartComponent(props) {
},
});
- const [data, setData] = useState();
-
const getPercentage = (species) => {
const { count, total } = scores[species];
const percent = (count / total) * 100 || 0;
return [percent, 100 - percent];
};
- const labels = [
- '0',
- '10',
- '20',
- '30',
- '40',
- '50',
- '60',
- '70',
- '80',
- '90',
- '100',
- ];
-
useEffect(() => {
if (countryData) {
const {
@@ -115,103 +93,6 @@ function ScoreDistributionsChartComponent(props) {
}
}, [countryData]);
- useEffect(() => {
- if (scoreDistributionData) {
- setData({
- labels,
- datasets: [
- {
- data: scoreDistributionData.map((item) => item[0]),
- backgroundColor: getCSSVariable('birds'),
- },
- ],
- });
- }
- }, [scoreDistributionData]);
-
- const options = {
- plugins: {
- title: {
- display: false,
- },
- legend: {
- display: false,
- },
- },
- responsive: true,
- interaction: {
- mode: 'index',
- intersect: false,
- },
- scales: {
- x: {
- stacked: true,
- display: true,
- title: {
- display: true,
- text: 'Protection Score',
- color: getCSSVariable('white'),
- },
- grid: {
- color: getCSSVariable('oslo-gray'),
- display: false,
- },
- ticks: {
- color: getCSSVariable('oslo-gray'),
- },
- },
- y: {
- stacked: true,
- display: true,
- title: {
- display: true,
- text: 'Number of Species',
- color: getCSSVariable('white'),
- },
- grid: {
- color: getCSSVariable('oslo-gray'),
- },
- ticks: {
- color: getCSSVariable('oslo-gray'),
- },
- },
- },
- };
-
- // const labels = [
- // '0', '10', '20', '30', '40', '50', '60', '70', '80', '90', '100'
- // ];
-
- // const data = {
- // labels,
- // datasets: [
- // {
- // label: 'Dataset 1',
- // data: labels.map(() => faker.datatype.number({ min: 0, max: 250 })),
- // backgroundColor: getCSSVariable('birds'),
- // stack: 'Stack 0',
- // },
- // {
- // label: 'Dataset 2',
- // data: labels.map(() => faker.datatype.number({ min: 0, max: 250 })),
- // backgroundColor: getCSSVariable('mammals'),
- // stack: 'Stack 0',
- // },
- // {
- // label: 'Dataset 3',
- // data: labels.map(() => faker.datatype.number({ min: 0, max: 250 })),
- // backgroundColor: getCSSVariable('reptiles'),
- // stack: 'Stack 0',
- // },
- // {
- // label: 'Dataset 4',
- // data: labels.map(() => faker.datatype.number({ min: 0, max: 250 })),
- // backgroundColor: getCSSVariable('amphibians'),
- // stack: 'Stack 0',
- // },
- // ],
- // };
-
const birdData = {
labels: ['Birds', 'Remaining'],
datasets: [
@@ -290,7 +171,6 @@ function ScoreDistributionsChartComponent(props) {
return (
-
NATIONAL SPI BY TAXONOMIC GROUP
-
- {data && (
-
-
-
- )}
- );
+ )
}
-export default ScoreDistributionsChartComponent;
+export default SpeciesRichnessComponent
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/shi/distributions-chart/distributions-chart-styles.module.scss b/src/components/species-richness/species-richness-styles.module.scss
similarity index 85%
rename from src/containers/sidebars/dashboard-trends-sidebar/score-distributions/shi/distributions-chart/distributions-chart-styles.module.scss
rename to src/components/species-richness/species-richness-styles.module.scss
index 3785faf6c..e3df439f6 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/shi/distributions-chart/distributions-chart-styles.module.scss
+++ b/src/components/species-richness/species-richness-styles.module.scss
@@ -12,16 +12,6 @@
gap: 8px;
width: 100%;
- .title{
- color: $white;
- font-family: "Open Sans";
- font-size: 15px;
- font-style: normal;
- font-weight: 700;
- line-height: normal;
- text-transform: uppercase;
- }
-
.spis{
display: flex;
gap: 10px;
@@ -75,9 +65,4 @@
}
}
}
-
- .chart{
- width: 100%;
- margin-top: 25px;
- }
}
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/shi/distributions-chart/distributions-chart-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/shi/distributions-chart/distributions-chart-component.jsx
deleted file mode 100644
index 4d4784613..000000000
--- a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/shi/distributions-chart/distributions-chart-component.jsx
+++ /dev/null
@@ -1,358 +0,0 @@
-/* eslint-disable camelcase */
-import React, { useEffect, useState } from 'react';
-import { Bar } from 'react-chartjs-2';
-
-import { getCSSVariable } from 'utils/css-utils';
-
-import {
- Chart as ChartJS,
- CategoryScale,
- LinearScale,
- ArcElement,
- BarElement,
- Title,
- Tooltip,
- Legend,
-} from 'chart.js';
-import SpiArcChartComponent from 'components/charts/spi-arc-chart/spi-arc-chart-component';
-
-import Amphibians from 'images/amphibians.svg';
-import Birds from 'images/birds.svg';
-import Mammals from 'images/mammals.svg';
-import Reptiles from 'images/reptiles.svg';
-
-import styles from './distributions-chart-styles.module.scss';
-
-ChartJS.register(
- CategoryScale,
- LinearScale,
- ArcElement,
- BarElement,
- Title,
- Tooltip,
- Legend
-);
-
-function DistributionsChartComponent(props) {
- const { countryData, scoreDistributionData, chartData, chartType } = props;
- const [scores, setScores] = useState({
- birds: {
- count: 0,
- total: 0,
- percentage: 0,
- },
- mammals: {
- count: 0,
- total: 0,
- percentage: 0,
- },
- reptiles: {
- count: 0,
- total: 0,
- percentage: 0,
- },
- amphibians: {
- count: 0,
- total: 0,
- percentage: 0,
- },
- });
-
- const [data, setData] = useState();
-
- const getPercentage = (species) => {
- const { count, total } = scores[species];
- const percent = (count / total) * 100 || 0;
- return [percent, 100 - percent];
- };
-
- useEffect(() => {
- if (chartData) {
-
- const {
- endemic_birds,
- birds,
- endemic_mammals,
- mammals,
- endemic_reptiles,
- reptiles,
- endemic_amphibians,
- amphibians,
- } = countryData;
-
- setScores({
- birds: {
- count: endemic_birds,
- total: birds,
- },
- mammals: {
- count: endemic_mammals,
- total: mammals,
- },
- reptiles: {
- count: endemic_reptiles,
- total: reptiles,
- },
- amphibians: {
- count: endemic_amphibians,
- total: amphibians,
- },
- });
- }
- }, [chartData]);
-
- useEffect(() => {
- if (chartData) {
- const ampSet = getHistogramData('AMPHIBIA');
- const mamSet = getHistogramData('MAMMALIA');
- const repSet = getHistogramData('REPTILIA');
- const birdSet = getHistogramData('AVES');
-
- const taxaSet = {};
-
- chartData.forEach(a => {
- let floorScore;
- if (chartType === 'area') {
- floorScore = Math.floor(a.area_score);
- } else if (chartType === 'habitat score') {
- floorScore = Math.floor((a.area_score + a.connectivity_score) / 2);
- } else if (chartType === 'connectivity') {
- floorScore = Math.floor(a.connectivity_score);
- }
-
- if (!taxaSet.hasOwnProperty(floorScore)) {
- taxaSet[floorScore] = 1;
- } else {
- taxaSet[floorScore] += 1;
- }
- });
-
- setData({
- datasets: [
- // {
- // label: '# of occurance',
- // data: ampSet,
- // backgroundColor: getCSSVariable('amphibians'),
- // stack: 'Stack 0',
- // barPercentage: 1,
- // },
- // {
- // label: '# of occurance',
- // data: mamSet,
- // backgroundColor: getCSSVariable('mammals'),
- // stack: 'Stack 0',
- // barPercentage: 1,
- // },
- // {
- // label: '# of occurance',
- // data: repSet,
- // backgroundColor: getCSSVariable('reptiles'),
- // stack: 'Stack 0',
- // barPercentage: 1,
- // },
- // {
- // label: '# of occurance',
- // data: birdSet,
- // backgroundColor: getCSSVariable('birds'),
- // stack: 'Stack 0',
- // barPercentage: 1,
- // },
- {
- label: '# of occurance',
- data: taxaSet,
- backgroundColor: getCSSVariable('birds'),
- stack: 'Stack 0',
- barPercentage: 1,
- },
- ],
- });
- }
- }, [chartData, chartType]);
-
- const options = {
- plugins: {
- title: {
- display: false,
- },
- legend: {
- display: false,
- },
- },
- responsive: true,
- interaction: {
- mode: 'index',
- intersect: false,
- },
- scales: {
- x: {
- type: 'linear',
- offset: false,
- stacked: true,
- display: true,
- title: {
- display: true,
- text: 'Protection Score',
- color: getCSSVariable('white'),
- },
- grid: {
- color: getCSSVariable('oslo-gray'),
- display: false,
- offset: false,
- },
- ticks: {
- color: getCSSVariable('oslo-gray'),
- stepSize: 25,
- },
- },
- y: {
- stacked: true,
- display: true,
- title: {
- display: true,
- text: 'Number of Species',
- color: getCSSVariable('white'),
- },
- grid: {
- color: getCSSVariable('oslo-gray'),
- },
- ticks: {
- color: getCSSVariable('oslo-gray'),
- stepSize: 10,
- },
- },
- },
- };
-
- const birdData = {
- labels: ['Birds', 'Remaining'],
- datasets: [
- {
- label: '',
- data: getPercentage('birds'),
- backgroundColor: [
- getCSSVariable('birds'),
- getCSSVariable('white-opacity-20'),
- ],
- borderColor: [
- getCSSVariable('birds'),
- getCSSVariable('white-opacity-20'),
- ],
- borderWidth: 1,
- },
- ],
- };
-
- const mammalsData = {
- labels: ['Mammals', 'Remaining'],
- datasets: [
- {
- label: '',
- data: getPercentage('mammals'),
- backgroundColor: [
- getCSSVariable('mammals'),
- getCSSVariable('white-opacity-20'),
- ],
- borderColor: [
- getCSSVariable('mammals'),
- getCSSVariable('white-opacity-20'),
- ],
- borderWidth: 1,
- },
- ],
- };
-
- const reptilesData = {
- labels: ['Reptiles', 'Remaining'],
- datasets: [
- {
- label: '',
- data: getPercentage('reptiles'),
- backgroundColor: [
- getCSSVariable('reptiles'),
- getCSSVariable('white-opacity-20'),
- ],
- borderColor: [
- getCSSVariable('reptiles'),
- getCSSVariable('white-opacity-20'),
- ],
- borderWidth: 1,
- },
- ],
- };
-
- const amphibianData = {
- labels: ['Amphibians', 'Remaining'],
- datasets: [
- {
- label: '',
- data: getPercentage('amphibians'),
- backgroundColor: [
- getCSSVariable('amphibians'),
- getCSSVariable('white-opacity-20'),
- ],
- borderColor: [
- getCSSVariable('amphibians'),
- getCSSVariable('white-opacity-20'),
- ],
- borderWidth: 1,
- },
- ],
- };
-
- const getHistogramData = (taxa) => {
- const taxaGroup = chartData.filter(item => item.taxa === taxa);
- const taxaSet = {};
-
- taxaGroup.forEach(a => {
- const floorScore = Math.floor(a.area_score);
- if (!taxaSet.hasOwnProperty(floorScore)) {
- taxaSet[floorScore] = 1;
- } else {
- taxaSet[floorScore] += 1;
- }
- });
- return taxaSet;
- }
-
- return (
-
-
-
-
-
-
-
-
-
-
-
- {data && (
-
-
-
- )}
-
- );
-}
-
-export default DistributionsChartComponent;
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/shi/distributions-chart/index.js b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/shi/distributions-chart/index.js
deleted file mode 100644
index 917872f80..000000000
--- a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/shi/distributions-chart/index.js
+++ /dev/null
@@ -1,9 +0,0 @@
-import React from 'react';
-
-import DistributionsChartComponent from './distributions-chart-component';
-
-function DistributionsChartContainer(props) {
- return ;
-}
-
-export default DistributionsChartContainer;
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/shi/distributions-table/distributions-table-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/shi/distributions-table/distributions-table-component.jsx
new file mode 100644
index 000000000..b87e161bf
--- /dev/null
+++ b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/shi/distributions-table/distributions-table-component.jsx
@@ -0,0 +1,168 @@
+import React from 'react'
+import styles from './distributions-table-styles.module.scss';
+import tableStyles from 'components/protected-areas-table/protected-areas-table-styles.module.scss';
+import { useT, useLocale } from '@transifex/react';
+import ArrowDown from 'icons/arrow_down.svg?react';
+import ArrowUp from 'icons/arrow_up.svg?react';
+
+
+function DistributionsTableComponent(props) {
+ const { chartData } = props;
+ const t = useT();
+ const locale = useLocale();
+
+ console.log(chartData)
+
+ return (
+
+
+
+
+
+
+
+
{t('Taxa')}
+
+
+ handleSortChange({ value: 'NAME', ascending: true })
+ }
+ />
+
+ handleSortChange({ value: 'NAME', ascending: false })
+ }
+ />
+
+
+
+
+
+
{t('Scientific Name')}
+
+
+ handleSortChange({ value: 'GOV_TYPE', ascending: true })
+ }
+ />
+
+ handleSortChange({ value: 'GOV_TYPE', ascending: false })
+ }
+ />
+
+
+
+
+
+
{t('Stewardship')}
+
+
+ handleSortChange({ value: 'DESIG', ascending: true })
+ }
+ />
+
+ handleSortChange({ value: 'DESIG', ascending: false })
+ }
+ />
+
+
+
+
+
+
{t('Range Size')}
+
+
+ handleSortChange({ value: 'DESIG_TYPE', ascending: true })
+ }
+ />
+
+ handleSortChange({ value: 'DESIG_TYPE', ascending: false })
+ }
+ />
+
+
+
+
+
+
{t('Area Score')}
+
+
+ handleSortChange({ value: 'STATUS', ascending: true })
+ }
+ />
+
+ handleSortChange({ value: 'STATUS', ascending: false })
+ }
+ />
+
+
+
+
+
+
{t('Connectivity Score')}
+
+
+ handleSortChange({ value: 'STATUS_YR', ascending: true })
+ }
+ />
+
+ handleSortChange({ value: 'STATUS_YR', ascending: false })
+ }
+ />
+
+
+
+
+
+
+ {t('Habitat Score')}
+
+
+
+ handleSortChange({ value: 'AREA_KM', ascending: true })
+ }
+ />
+
+ handleSortChange({ value: 'AREA_KM', ascending: false })
+ }
+ />
+
+
+
+
+
+
+ {chartData &&
+ chartData.map((row, index) => (
+ // eslint-disable-next-line react/no-array-index-key
+
+ {row.taxa}
+ {row.scientificname}
+ {row.steward_score.toFixed(2)}
+ {(row.area_score + row.connectivity_score / 2).toFixed(2)}2
+ {row.area_score.toFixed(2)}
+ {row.connectivity_score.toFixed(2)}
+
+ {((row.area_score + row.connectivity_score) / 2).toFixed(2)}
+
+
+ ))}
+
+
+
+
+ )
+}
+
+export default DistributionsTableComponent
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/shi/distributions-table/distributions-table-styles.module.scss b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/shi/distributions-table/distributions-table-styles.module.scss
new file mode 100644
index 000000000..0d9c17558
--- /dev/null
+++ b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/shi/distributions-table/distributions-table-styles.module.scss
@@ -0,0 +1,27 @@
+@import 'styles/ui.module';
+@import 'styles/settings';
+@import 'styles/typography-extends';
+@import 'styles/common-animations.module';
+
+.container{
+ display: flex;
+ flex-direction: column;
+ padding: 10px 5px 10px 26px;
+ flex-grow: 1;
+ align-items: center;
+ gap: 8px;
+ width: 100%;
+
+ .tableWrapper{
+ background-color: rgba(255, 255, 255, 0.3);
+ height: 300px;
+ overflow-y: auto;
+
+ th{
+ span{
+ color: $white;
+ text-align: center;
+ }
+ }
+ }
+}
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/shi/distributions-table/index.js b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/shi/distributions-table/index.js
new file mode 100644
index 000000000..546156bff
--- /dev/null
+++ b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/shi/distributions-table/index.js
@@ -0,0 +1,9 @@
+import React from 'react';
+
+import DistributionsTableComponent from './distributions-table-component';
+
+function DistributionsTableContainer(props) {
+ return ;
+}
+
+export default DistributionsTableContainer;
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/shi/score-distributions-shi-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/shi/score-distributions-shi-component.jsx
index 3b3d64311..2740416ed 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/shi/score-distributions-shi-component.jsx
+++ b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/shi/score-distributions-shi-component.jsx
@@ -3,18 +3,19 @@ import React, { useEffect, useState } from 'react';
import cx from 'classnames';
import Button from 'components/button';
-
+import { getCSSVariable } from 'utils/css-utils';
import styles from '../../dashboard-trends-sidebar-styles.module.scss';
+import SpeciesRichnessComponent from 'components/species-richness/species-richness-component';
-import DistributionsChartComponent from './distributions-chart/distributions-chart-component';
import compStyles from './score-distributions-shi-styles.module.scss';
+import DistributionsTableContainer from './distributions-table';
+import DistributionsChartComponent from 'components/charts/distribution-chart/distribution-chart-component';
function ScoreDistributionsShiComponent(props) {
- const { countryISO } = props;
+ const { countryISO, countryData } = props;
const lowAvg = 'Amphibians';
const highAvg = 'birds';
-
const spsSpecies = [
{
name: 'Black-collared Apalis',
@@ -34,19 +35,10 @@ function ScoreDistributionsShiComponent(props) {
},
];
- const [scoreDistributionData, setScoreDistributionData] = useState();
const [chartData, setChartData] = useState();
-
- const getScoreDistributionData = async () => {
- const year = '2023';
- const taxa = 'all_terr_verts';
- const url = `https://next-api-dot-api-2-x-dot-map-of-life.appspot.com/2.x/indicators/sps/values?iso=${countryISO}&year=${year}&taxa=${taxa}`;
-
- const response = await fetch(url);
- const data = await response.json();
-
- setScoreDistributionData(data.map((item) => [item.protection_score]));
- };
+ const [responseData, setResponseData] = useState();
+ const [showTable, setShowTable] = useState(false);
+ const [activeScore, setActiveScore] = useState('area');
const getChartData = async () => {
const year = '2021';
@@ -54,18 +46,154 @@ function ScoreDistributionsShiComponent(props) {
const response = await fetch(url);
const data = await response.json();
- console.log(data);
- setChartData(data);
+
+ setResponseData(data);
+ displayData(data, activeScore);
+ }
+
+ const displayData = (data, activeScore) => {
+ // const ampSet = getHistogramData('AMPHIBIA');
+ // const mamSet = getHistogramData('MAMMALIA');
+ // const repSet = getHistogramData('REPTILIA');
+ // const birdSet = getHistogramData('AVES');
+ const taxaSet = {};
+
+ data.forEach(a => {
+ let floorScore;
+ if (activeScore === 'area') {
+ floorScore = Math.floor(a.area_score);
+ } else if (activeScore === 'habitat score') {
+ floorScore = Math.floor((a.area_score + a.connectivity_score) / 2);
+ } else if (activeScore === 'connectivity') {
+ floorScore = Math.floor(a.connectivity_score);
+ }
+
+ if (!taxaSet.hasOwnProperty(floorScore)) {
+ taxaSet[floorScore] = 1;
+ } else {
+ taxaSet[floorScore] += 1;
+ }
+ });
+
+ setChartData({
+ datasets: [
+ // {
+ // label: '# of occurance',
+ // data: ampSet,
+ // backgroundColor: getCSSVariable('amphibians'),
+ // stack: 'Stack 0',
+ // barPercentage: 1,
+ // },
+ // {
+ // label: '# of occurance',
+ // data: mamSet,
+ // backgroundColor: getCSSVariable('mammals'),
+ // stack: 'Stack 0',
+ // barPercentage: 1,
+ // },
+ // {
+ // label: '# of occurance',
+ // data: repSet,
+ // backgroundColor: getCSSVariable('reptiles'),
+ // stack: 'Stack 0',
+ // barPercentage: 1,
+ // },
+ // {
+ // label: '# of occurance',
+ // data: birdSet,
+ // backgroundColor: getCSSVariable('birds'),
+ // stack: 'Stack 0',
+ // barPercentage: 1,
+ // },
+ {
+ label: '# of occurance',
+ data: taxaSet,
+ backgroundColor: getCSSVariable('birds'),
+ stack: 'Stack 0',
+ barPercentage: 1,
+ },
+ ],
+ });
}
useEffect(() => {
- getScoreDistributionData();
getChartData();
}, []);
- const [activeScore, setActiveScore] = useState('area');
+
+ const getHistogramData = (taxa) => {
+ const taxaGroup = chartData.filter(item => item.taxa === taxa);
+ const taxaSet = {};
+
+ taxaGroup.forEach(a => {
+ const floorScore = Math.floor(a.area_score);
+ if (!taxaSet.hasOwnProperty(floorScore)) {
+ taxaSet[floorScore] = 1;
+ } else {
+ taxaSet[floorScore] += 1;
+ }
+ });
+ return taxaSet;
+ }
+
+
const handleActiveChange = (event) => {
setActiveScore(event.currentTarget.innerText.toLowerCase());
+ displayData(responseData, event.currentTarget.innerText.toLowerCase());
+ };
+
+ const options = {
+ plugins: {
+ title: {
+ display: false,
+ },
+ legend: {
+ display: false,
+ },
+ },
+ responsive: true,
+ interaction: {
+ mode: 'index',
+ intersect: false,
+ },
+ scales: {
+ x: {
+ type: 'linear',
+ offset: false,
+ stacked: true,
+ display: true,
+ title: {
+ display: true,
+ text: 'Protection Score',
+ color: getCSSVariable('white'),
+ },
+ grid: {
+ color: getCSSVariable('oslo-gray'),
+ display: false,
+ offset: false,
+ },
+ ticks: {
+ color: getCSSVariable('oslo-gray'),
+ stepSize: 25,
+ },
+ },
+ y: {
+ stacked: true,
+ display: true,
+ title: {
+ display: true,
+ text: 'Number of Species',
+ color: getCSSVariable('white'),
+ },
+ grid: {
+ color: getCSSVariable('oslo-gray'),
+ },
+ ticks: {
+ color: getCSSVariable('oslo-gray'),
+ stepSize: 10,
+ },
+ },
+ },
};
return (
@@ -107,6 +235,7 @@ function ScoreDistributionsShiComponent(props) {
type="rectangular"
className={cx(styles.saveButton, styles.notActive)}
label="view full table"
+ handleClick={() => setShowTable(true)}
/>
Open and download a full table of species SPS and relevant traits at
@@ -115,39 +244,45 @@ function ScoreDistributionsShiComponent(props) {
-
-
-
+ >)}
+ {showTable && (<>
+
+
+ >)}
);
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/sii/score-distributions-sii-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/sii/score-distributions-sii-component.jsx
index dc4b5b603..edb303e5a 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/sii/score-distributions-sii-component.jsx
+++ b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/sii/score-distributions-sii-component.jsx
@@ -3,11 +3,14 @@ import React, { useEffect, useState } from 'react';
import cx from 'classnames';
import Button from 'components/button';
-
+import { getCSSVariable } from 'utils/css-utils';
+import compStyles from './score-distributions-sii-styles.module.scss';
import styles from '../../dashboard-trends-sidebar-styles.module.scss';
+import SpeciesRichnessComponent from 'components/species-richness/species-richness-component';
+import DistributionsChartComponent from 'components/charts/distribution-chart/distribution-chart-component';
function ScoreDistributionsSiiComponent(props) {
- const { countryISO } = props;
+ const { countryISO, countryData } = props;
const lowAvg = 'Amphibians';
const highAvg = 'birds';
@@ -31,22 +34,96 @@ function ScoreDistributionsSiiComponent(props) {
},
];
- const [scoreDistributionData, setScoreDistributionData] = useState();
+ const [chartData, setChartData] = useState();
+ const [showTable, setShowTable] = useState(false);
- const getScoreDistributionData = async () => {
+ const getChartData = async () => {
const year = '2023';
const taxa = 'all_terr_verts';
const url = `https://next-api-dot-api-2-x-dot-map-of-life.appspot.com/2.x/indicators/sps/values?iso=${countryISO}&year=${year}&taxa=${taxa}`;
const response = await fetch(url);
const data = await response.json();
- setScoreDistributionData(data.map((item) => [item.protection_score]));
+ const taxaSet = {};
+
+ data.forEach(a => {
+ let floorScore = Math.floor(+a.protection_score)
+ if (!taxaSet.hasOwnProperty(floorScore)) {
+ taxaSet[floorScore] = 1;
+ } else {
+ taxaSet[floorScore] += 1;
+ }
+ });
+
+ setChartData({
+ datasets: [
+ {
+ label: 'Items',
+ data: taxaSet,
+ backgroundColor: getCSSVariable('birds'),
+ },
+ ],
+ });
};
useEffect(() => {
- getScoreDistributionData();
+ getChartData();
}, []);
+ const options = {
+ plugins: {
+ title: {
+ display: false,
+ },
+ legend: {
+ display: false,
+ },
+ },
+ responsive: true,
+ interaction: {
+ mode: 'index',
+ intersect: false,
+ },
+ scales: {
+ x: {
+ type: 'linear',
+ offset: false,
+ stacked: true,
+ display: true,
+ title: {
+ display: true,
+ text: 'Protection Score',
+ color: getCSSVariable('white'),
+ },
+ grid: {
+ color: getCSSVariable('oslo-gray'),
+ display: false,
+ offset: false,
+ },
+ ticks: {
+ color: getCSSVariable('oslo-gray'),
+ stepSize: 25,
+ },
+ },
+ y: {
+ stacked: true,
+ display: true,
+ title: {
+ display: true,
+ text: 'Number of Species',
+ color: getCSSVariable('white'),
+ },
+ grid: {
+ color: getCSSVariable('oslo-gray'),
+ },
+ ticks: {
+ color: getCSSVariable('oslo-gray'),
+ stepSize: 10,
+ },
+ },
+ },
+ };
+
return (
@@ -86,6 +163,7 @@ function ScoreDistributionsSiiComponent(props) {
type="rectangular"
className={cx(styles.saveButton, styles.notActive)}
label="view full table"
+ handleClick={() => setShowTable(true)}
/>
Open and download a full table of species SPS and relevant traits at
@@ -93,6 +171,21 @@ function ScoreDistributionsSiiComponent(props) {
+
+ {!showTable && (<>
+
+
+ >)}
+ {showTable && (<>
+
+ {/* */}
+ >)}
+
);
}
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/sii/score-distributions-sii-styles.module.scss b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/sii/score-distributions-sii-styles.module.scss
index c709bfc60..bb6ddb8b7 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/sii/score-distributions-sii-styles.module.scss
+++ b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/sii/score-distributions-sii-styles.module.scss
@@ -2,3 +2,14 @@
@import 'styles/settings';
@import 'styles/typography-extends';
@import 'styles/common-animations.module';
+
+.chartArea{
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ flex-grow: 1;
+
+ .btnGroup{
+ width: 75%;
+ }
+}
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/spi/score-distributions-chart/index.js b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/spi/score-distributions-chart/index.js
deleted file mode 100644
index ab5e996ea..000000000
--- a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/spi/score-distributions-chart/index.js
+++ /dev/null
@@ -1,9 +0,0 @@
-import React from 'react';
-
-import ScoreDistributionsChartComponent from './score-distributions-chart-component';
-
-function ScoreDistributionsChartContainer(props) {
- return
;
-}
-
-export default ScoreDistributionsChartContainer;
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/spi/score-distributions-chart/score-distributions-chart-styles.module.scss b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/spi/score-distributions-chart/score-distributions-chart-styles.module.scss
deleted file mode 100644
index 8b31c12e8..000000000
--- a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/spi/score-distributions-chart/score-distributions-chart-styles.module.scss
+++ /dev/null
@@ -1,82 +0,0 @@
-@import 'styles/ui.module';
-@import 'styles/settings';
-@import 'styles/typography-extends';
-@import 'styles/common-animations.module';
-
-.container{
- display: flex;
- flex-direction: column;
- padding: 10px 5px 10px 26px;
- flex-grow: 1;
- align-items: center;
- gap: 8px;
-
- .title{
- color: $white;
- font-family: "Open Sans";
- font-size: 15px;
- font-style: normal;
- font-weight: 700;
- line-height: normal;
- text-transform: uppercase;
- }
-
- .spis{
- display: flex;
- gap: 10px;
- align-items: center;
- width: 100%;
- justify-content: center;
- border-radius: 5px;
- border: 1.5px solid $brand-color-main;
- box-shadow: -2px 4px 4px 0px rgba(0, 0, 0, 0.25);
- padding: 15px 0;
-
- .spi{
- display: flex;
- flex-direction: column;
- justify-content: center;
- align-items: center;
-
- .score{
- color: #FFF;
- text-align: center;
- font-family: "Open Sans";
- font-size: 20px;
- font-style: normal;
- font-weight: 700;
- line-height: normal;
- margin-bottom: -20px;
- }
-
- .taxoGroup{
- display: flex;
- flex-direction: column;
- margin-top: -60px;
- align-items: center;
-
- .richness{
- color: #FFF;
- text-align: center;
- font-family: "Open Sans";
- font-size: 11px;
- font-style: italic;
- font-weight: 400;
- line-height: normal;
- }
-
- .score{
- font-size: 16px;
- font-weight: 600;
- text-transform: uppercase;
- margin-bottom: 0;
- }
- }
- }
- }
-
- .chart{
- width: 100%;
- margin-top: 25px;
- }
-}
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/spi/score-distributions-spi-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/spi/score-distributions-spi-component.jsx
index 58689d85e..cd444fa04 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/spi/score-distributions-spi-component.jsx
+++ b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/spi/score-distributions-spi-component.jsx
@@ -3,13 +3,15 @@ import React, { useEffect, useState } from 'react';
import cx from 'classnames';
import Button from 'components/button';
-
+import { getCSSVariable } from 'utils/css-utils';
import styles from '../../dashboard-trends-sidebar-styles.module.scss';
+import SpeciesRichnessComponent from 'components/species-richness/species-richness-component';
-import ScoreDistributionsChartContainer from './score-distributions-chart';
+import compStyles from './score-distributions-spi-styles.module.scss';
+import DistributionsChartComponent from 'components/charts/distribution-chart/distribution-chart-component';
function ScoreDistributionsSpiComponent(props) {
- const { countryISO } = props;
+ const { countryISO, countryData } = props;
const lowAvg = 'Amphibians';
const highAvg = 'birds';
@@ -33,22 +35,97 @@ function ScoreDistributionsSpiComponent(props) {
},
];
- const [scoreDistributionData, setScoreDistributionData] = useState();
+ const [chartData, setChartData] = useState();
+ const [showTable, setShowTable] = useState(false);
- const getScoreDistributionData = async () => {
+ const getChartData = async () => {
const year = '2023';
const taxa = 'all_terr_verts';
const url = `https://next-api-dot-api-2-x-dot-map-of-life.appspot.com/2.x/indicators/sps/values?iso=${countryISO}&year=${year}&taxa=${taxa}`;
const response = await fetch(url);
const data = await response.json();
- setScoreDistributionData(data.map((item) => [item.protection_score]));
+ const taxaSet = {};
+
+ data.forEach(a => {
+ let floorScore = Math.floor(+a.protection_score)
+ if (!taxaSet.hasOwnProperty(floorScore)) {
+ taxaSet[floorScore] = 1;
+ } else {
+ taxaSet[floorScore] += 1;
+ }
+ });
+
+
+ setChartData({
+ datasets: [
+ {
+ label: 'Items',
+ data: taxaSet,
+ backgroundColor: getCSSVariable('birds'),
+ },
+ ],
+ });
};
useEffect(() => {
- getScoreDistributionData();
+ getChartData();
}, []);
+ const options = {
+ plugins: {
+ title: {
+ display: false,
+ },
+ legend: {
+ display: false,
+ },
+ },
+ responsive: true,
+ interaction: {
+ mode: 'index',
+ intersect: false,
+ },
+ scales: {
+ x: {
+ type: 'linear',
+ offset: false,
+ stacked: true,
+ display: true,
+ title: {
+ display: true,
+ text: 'Protection Score',
+ color: getCSSVariable('white'),
+ },
+ grid: {
+ color: getCSSVariable('oslo-gray'),
+ display: false,
+ offset: false,
+ },
+ ticks: {
+ color: getCSSVariable('oslo-gray'),
+ stepSize: 25,
+ },
+ },
+ y: {
+ stacked: true,
+ display: true,
+ title: {
+ display: true,
+ text: 'Number of Species',
+ color: getCSSVariable('white'),
+ },
+ grid: {
+ color: getCSSVariable('oslo-gray'),
+ },
+ ticks: {
+ color: getCSSVariable('oslo-gray'),
+ stepSize: 10,
+ },
+ },
+ },
+ };
+
return (
@@ -88,6 +165,7 @@ function ScoreDistributionsSpiComponent(props) {
type="rectangular"
className={cx(styles.saveButton, styles.notActive)}
label="view full table"
+ handleClick={() => setShowTable(true)}
/>
Open and download a full table of species SPS and relevant traits at
@@ -95,11 +173,18 @@ function ScoreDistributionsSpiComponent(props) {
-
-
+
+ {!showTable && (<>
+
NATIONAL SPI BY TAXONOMIC GROUP
+
+
+ >)}
+ {showTable && (<>
+
+ {/*
*/}
+ >)}
+
);
}
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/spi/score-distributions-spi-styles.module.scss b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/spi/score-distributions-spi-styles.module.scss
index c709bfc60..3caf886f3 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/spi/score-distributions-spi-styles.module.scss
+++ b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/spi/score-distributions-spi-styles.module.scss
@@ -2,3 +2,24 @@
@import 'styles/settings';
@import 'styles/typography-extends';
@import 'styles/common-animations.module';
+
+.chartArea{
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ flex-grow: 1;
+
+ .btnGroup{
+ width: 75%;
+ }
+
+ .title{
+ color: $white;
+ font-family: "Open Sans";
+ font-size: 15px;
+ font-style: normal;
+ font-weight: 700;
+ line-height: normal;
+ text-transform: uppercase;
+ }
+}
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/shi/national-chart/national-chart-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/shi/national-chart/national-chart-component.jsx
index d4af14a2c..b3e1843ad 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/shi/national-chart/national-chart-component.jsx
+++ b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/shi/national-chart/national-chart-component.jsx
@@ -82,6 +82,7 @@ function NationalChartComponent(props) {
},
ticks: {
color: getCSSVariable('oslo-gray'),
+ maxTicksLimit: 4
},
},
},
@@ -90,7 +91,6 @@ function NationalChartComponent(props) {
useEffect(() => {
if (nationalChartData.area_values.length) {
- console.log(nationalChartData);
const spiVal =
nationalChartData.spi_values[
nationalChartData.spi_values.length - 1
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/shi/temporal-trends-shi-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/shi/temporal-trends-shi-component.jsx
index c639aaa2e..2d69cb638 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/shi/temporal-trends-shi-component.jsx
+++ b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/shi/temporal-trends-shi-component.jsx
@@ -38,7 +38,6 @@ function TemporalTrendsShiComponent(props) {
const response = await fetch(url);
const data = await response.json();
- console.log(data);
setChartData(data);
}
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/sii/national-chart/national-chart-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/sii/national-chart/national-chart-component.jsx
index 1c382fd33..eb0e6661b 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/sii/national-chart/national-chart-component.jsx
+++ b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/sii/national-chart/national-chart-component.jsx
@@ -113,22 +113,21 @@ function NationalChartComponent(props) {
// }, [countryData]);
useEffect(() => {
- if (nationalChartData.area_values.length) {
- console.log(nationalChartData);
+ if (nationalChartData.length) {
setData({
- labels: nationalChartData.spi_values.map((item) => item[0]),
+ labels: nationalChartData.map((item) => item[0]),
datasets: [
{
label: 'SII',
- data: nationalChartData.spi_values.map((item) => item[1]),
+ data: nationalChartData.map((item) => item[1]),
borderColor: getCSSVariable('birds'),
},
],
});
- const spiVal =
- nationalChartData.spi_values[
- nationalChartData.spi_values.length - 1
- ][1];
+ const spiVal = 0;
+ // nationalChartData.spi_values[
+ // nationalChartData.spi_values.length - 1
+ // ][1];
const spi = {
labels: ['Global SPI', 'Remaining'],
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/sii/temporal-trends-sii-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/sii/temporal-trends-sii-component.jsx
index a1a38fe1f..47a5c6fc7 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/sii/temporal-trends-sii-component.jsx
+++ b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/sii/temporal-trends-sii-component.jsx
@@ -15,15 +15,19 @@ function TemporalTrendsSiiComponent(props) {
spi_values: [],
});
+
+ const taxa = 'all_terr_verts';
+
const getNationalData = async () => {
const regionId = '90b03e87-3880-4164-a310-339994e3f919';
- const taxa = 'all_terr_verts';
- const url = `https://next-api-dot-api-2-x-dot-map-of-life.appspot.com/2.x/indicators/nrc?region_id=${regionId}&taxa=${taxa}`;
+ const url = `https://next-api-dot-api-2-x-dot-map-of-life.appspot.com/2.x/indicators/completeness?region_id=${regionId}&indicator=richness&version=2020&weight=national`;
const response = await fetch(url);
const data = await response.json();
- const { area_values, spi_values } = data[0].values;
- setNationalChartData({ area_values, spi_values });
+ const { groups } = data[0];
+ const allVertValues = groups.filter(group => group.taxa === taxa);
+
+ setNationalChartData(allVertValues[0].values);
};
useEffect(() => {
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/spi/national-chart/national-chart-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/spi/national-chart/national-chart-component.jsx
index 2a25c5758..163d9f00b 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/spi/national-chart/national-chart-component.jsx
+++ b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/spi/national-chart/national-chart-component.jsx
@@ -116,7 +116,6 @@ function TemporalTrendsSpiNationalChartComponent(props) {
useEffect(() => {
if (nationalChartData.area_values.length) {
- console.log(nationalChartData);
setData({
labels: nationalChartData.spi_values.map((item) => item[0]),
datasets: [
diff --git a/src/containers/views/dashboard-trends-view/dashboard-trends-view-component.jsx b/src/containers/views/dashboard-trends-view/dashboard-trends-view-component.jsx
index 92151622f..719c362c5 100644
--- a/src/containers/views/dashboard-trends-view/dashboard-trends-view-component.jsx
+++ b/src/containers/views/dashboard-trends-view/dashboard-trends-view-component.jsx
@@ -46,13 +46,11 @@ function DashboardTrendsViewComponent(props) {
returnGeometry: true,
}).then((features) => {
const { geometry, attributes } = features[0];
- console.log(features);
if (geometry && view) {
view.center = [geometry.longitude, geometry.latitude];
setGeo(geometry);
setCountryData(attributes);
- console.log(attributes);
}
});
}, [view, countryISO]);
From 71f563d6861fe0e9e034f2a5c3471bbe12d96262 Mon Sep 17 00:00:00 2001
From: Chris Manciero
Date: Thu, 18 Jul 2024 14:36:29 -0400
Subject: [PATCH 034/350] chart and data updates
---
...ashboard-trends-sidebar-styles.module.scss | 8 ++--
.../distributions-table-styles.module.scss | 12 +++--
.../shi/score-distributions-shi-component.jsx | 44 +++++++++++++++---
.../sii/score-distributions-sii-component.jsx | 29 ++++++++----
.../spi/score-distributions-spi-component.jsx | 45 +++++++++++++++----
.../national-chart-component.jsx | 14 ++++--
.../shi/temporal-trends-shi-component.jsx | 5 ++-
.../national-chart-component.jsx | 13 +++---
.../sii/temporal-trends-sii-component.jsx | 3 +-
9 files changed, 130 insertions(+), 43 deletions(-)
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/dashboard-trends-sidebar-styles.module.scss b/src/containers/sidebars/dashboard-trends-sidebar/dashboard-trends-sidebar-styles.module.scss
index 91a8fcb09..2c1b00be9 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/dashboard-trends-sidebar-styles.module.scss
+++ b/src/containers/sidebars/dashboard-trends-sidebar/dashboard-trends-sidebar-styles.module.scss
@@ -45,12 +45,10 @@ $trends-width: 950px;
display: flex;
flex-direction: column;
align-items: center;
- border-top-left-radius: 10px;
- border-top-right-radius: 10px;
padding: 10px;
label{
- color: #000;
+ color: $white;
text-align: center;
font-family: "Roboto Flex";
font-size: 22px;
@@ -60,7 +58,7 @@ $trends-width: 950px;
}
span{
- color: #000;
+ color: $white;
text-align: center;
font-family: "Roboto Condensed";
font-size: 12px;
@@ -70,7 +68,7 @@ $trends-width: 950px;
}
&.selected{
- background-color: $white;
+ background-color: $brand-color-main;
}
}
}
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/shi/distributions-table/distributions-table-styles.module.scss b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/shi/distributions-table/distributions-table-styles.module.scss
index 0d9c17558..cdacaec45 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/shi/distributions-table/distributions-table-styles.module.scss
+++ b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/shi/distributions-table/distributions-table-styles.module.scss
@@ -17,10 +17,14 @@
height: 300px;
overflow-y: auto;
- th{
- span{
- color: $white;
- text-align: center;
+ table{
+ font-size: 10px;
+
+ th{
+ span{
+ color: $white;
+ text-align: center;
+ }
}
}
}
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/shi/score-distributions-shi-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/shi/score-distributions-shi-component.jsx
index 2740416ed..6e08fb67d 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/shi/score-distributions-shi-component.jsx
+++ b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/shi/score-distributions-shi-component.jsx
@@ -58,6 +58,24 @@ function ScoreDistributionsShiComponent(props) {
// const birdSet = getHistogramData('AVES');
const taxaSet = {};
+ // data.forEach(a => {
+ // let floorScore;
+ // if (activeScore === 'area') {
+ // floorScore = Math.floor(a.area_score);
+ // } else if (activeScore === 'habitat score') {
+ // floorScore = Math.floor((a.area_score + a.connectivity_score) / 2);
+ // } else if (activeScore === 'connectivity') {
+ // floorScore = Math.floor(a.connectivity_score);
+ // }
+
+ // if (!taxaSet.hasOwnProperty(floorScore)) {
+ // taxaSet[floorScore] = 1;
+ // } else {
+ // taxaSet[floorScore] += 1;
+ // }
+ // });
+
+ // Loop through each number and place it in the appropriate bucket
data.forEach(a => {
let floorScore;
if (activeScore === 'area') {
@@ -68,14 +86,20 @@ function ScoreDistributionsShiComponent(props) {
floorScore = Math.floor(a.connectivity_score);
}
- if (!taxaSet.hasOwnProperty(floorScore)) {
- taxaSet[floorScore] = 1;
+ // Determine the bucket index based on the floor value of the number
+ let bucketIndex = Math.floor(floorScore / 5);
+
+ if (!taxaSet.hasOwnProperty(bucketIndex)) {
+ taxaSet[bucketIndex] = 1;
} else {
- taxaSet[floorScore] += 1;
+ taxaSet[bucketIndex] += 1;
}
});
+ const labels = Object.keys(taxaSet).map(key => key * 5);
+
setChartData({
+ labels,
datasets: [
// {
// label: '# of occurance',
@@ -107,7 +131,7 @@ function ScoreDistributionsShiComponent(props) {
// },
{
label: '# of occurance',
- data: taxaSet,
+ data: Object.values(taxaSet),
backgroundColor: getCSSVariable('birds'),
stack: 'Stack 0',
barPercentage: 1,
@@ -174,7 +198,7 @@ function ScoreDistributionsShiComponent(props) {
},
ticks: {
color: getCSSVariable('oslo-gray'),
- stepSize: 25,
+ stepSize: 5,
},
},
y: {
@@ -231,12 +255,18 @@ function ScoreDistributionsShiComponent(props) {
})}
-
setShowTable(true)}
- />
+ />}
+ {showTable && setShowTable(false)}
+ />}
Open and download a full table of species SPS and relevant traits at
national and province levels for a selected year.
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/sii/score-distributions-sii-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/sii/score-distributions-sii-component.jsx
index edb303e5a..c3b8049ff 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/sii/score-distributions-sii-component.jsx
+++ b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/sii/score-distributions-sii-component.jsx
@@ -46,20 +46,27 @@ function ScoreDistributionsSiiComponent(props) {
const data = await response.json();
const taxaSet = {};
+ // Loop through each number and place it in the appropriate bucket
data.forEach(a => {
- let floorScore = Math.floor(+a.protection_score)
- if (!taxaSet.hasOwnProperty(floorScore)) {
- taxaSet[floorScore] = 1;
+ const number = +a.protection_score;
+ // Determine the bucket index based on the floor value of the number
+ let bucketIndex = Math.floor(number / 5);
+
+ if (!taxaSet.hasOwnProperty(bucketIndex)) {
+ taxaSet[bucketIndex] = 1;
} else {
- taxaSet[floorScore] += 1;
+ taxaSet[bucketIndex] += 1;
}
});
+ const labels = Object.keys(taxaSet).map(key => +key * 5);
+
setChartData({
+ labels,
datasets: [
{
label: 'Items',
- data: taxaSet,
+ data: Object.values(taxaSet),
backgroundColor: getCSSVariable('birds'),
},
],
@@ -102,7 +109,7 @@ function ScoreDistributionsSiiComponent(props) {
},
ticks: {
color: getCSSVariable('oslo-gray'),
- stepSize: 25,
+ stepSize: 10,
},
},
y: {
@@ -159,12 +166,18 @@ function ScoreDistributionsSiiComponent(props) {
})}
-
setShowTable(true)}
- />
+ />}
+ {showTable && setShowTable(false)}
+ />}
Open and download a full table of species SPS and relevant traits at
national and province levels for a selected year.
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/spi/score-distributions-spi-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/spi/score-distributions-spi-component.jsx
index cd444fa04..f2d0ca606 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/spi/score-distributions-spi-component.jsx
+++ b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/spi/score-distributions-spi-component.jsx
@@ -16,6 +16,8 @@ function ScoreDistributionsSpiComponent(props) {
const lowAvg = 'Amphibians';
const highAvg = 'birds';
+ const taxas = ['birds', 'mammals', 'reptiles', 'amphibians'];
+
const spsSpecies = [
{
name: 'Black-collared Apalis',
@@ -47,28 +49,47 @@ function ScoreDistributionsSpiComponent(props) {
const data = await response.json();
const taxaSet = {};
+ // Loop through each number and place it in the appropriate bucket
data.forEach(a => {
- let floorScore = Math.floor(+a.protection_score)
- if (!taxaSet.hasOwnProperty(floorScore)) {
- taxaSet[floorScore] = 1;
+ const number = +a.protection_score;
+ // Determine the bucket index based on the floor value of the number
+ let bucketIndex = Math.floor(number / 5);
+
+ if (!taxaSet.hasOwnProperty(bucketIndex)) {
+ taxaSet[bucketIndex] = 1;
} else {
- taxaSet[floorScore] += 1;
+ taxaSet[bucketIndex] += 1;
}
});
+ const labels = Object.keys(taxaSet).map(key => +key * 5);
setChartData({
+ labels,
datasets: [
{
label: 'Items',
- data: taxaSet,
+ data: Object.values(taxaSet),
backgroundColor: getCSSVariable('birds'),
},
],
});
};
+ const getTaxaData = async () => {
+ const taxaCalls = await Promise.all(
+ taxas.map(async (taxa) => {
+ const response = await fetch(`https://next-api-dot-api-2-x-dot-map-of-life.appspot.com/2.x/indicators/nrc?region_id=90b03e87-3880-4164-a310-339994e3f919&taxa=${taxa}`);
+ const data = await response.json();
+ return data;
+ })
+ );
+
+ console.log(taxaCalls);
+ }
+
useEffect(() => {
+ getTaxaData();
getChartData();
}, []);
@@ -104,7 +125,7 @@ function ScoreDistributionsSpiComponent(props) {
},
ticks: {
color: getCSSVariable('oslo-gray'),
- stepSize: 25,
+ stepSize: 10,
},
},
y: {
@@ -120,7 +141,7 @@ function ScoreDistributionsSpiComponent(props) {
},
ticks: {
color: getCSSVariable('oslo-gray'),
- stepSize: 10,
+ stepSize: 100,
},
},
},
@@ -161,12 +182,18 @@ function ScoreDistributionsSpiComponent(props) {
})}
-
setShowTable(true)}
- />
+ />}
+ {showTable && setShowTable(false)}
+ />}
Open and download a full table of species SPS and relevant traits at
national and province levels for a selected year.
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/shi/national-chart/national-chart-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/shi/national-chart/national-chart-component.jsx
index b3e1843ad..02c54073c 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/shi/national-chart/national-chart-component.jsx
+++ b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/shi/national-chart/national-chart-component.jsx
@@ -22,6 +22,7 @@ function NationalChartComponent(props) {
const { countryData, nationalChartData, chartData } = props;
const [data, setData] = useState();
const [spiValue, setSpiValue] = useState(0);
+ const [nationalScores, setNationalScores] = useState({ areaScore: 0, connecivityScore: 0, year: 2001 })
const blankData = {
labels: ['Global SPI', 'Remaining'],
@@ -142,6 +143,13 @@ function NationalChartComponent(props) {
},
],
});
+
+ const lastValues = chartData[chartData.length - 1];
+ setNationalScores({
+ areaScore: lastValues.avg_area,
+ connecivityScore: lastValues.avg_conn,
+ year: lastValues.year
+ });
}
}, [chartData])
@@ -151,15 +159,15 @@ function NationalChartComponent(props) {
-
2024
-
98.37
+
{nationalScores.year}
+
{nationalScores.areaScore}
-
98.88
+
{nationalScores.connecivityScore}
{countryData?.prop_protected_ter}
Year
Area Score
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/shi/temporal-trends-shi-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/shi/temporal-trends-shi-component.jsx
index 2d69cb638..d7ce91deb 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/shi/temporal-trends-shi-component.jsx
+++ b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/shi/temporal-trends-shi-component.jsx
@@ -21,6 +21,7 @@ function TemporalTrendsShiComponent(props) {
});
const [chartData, setChartData] = useState();
+ const [lostAvg, setLostAvg] = useState(0)
const getNationalData = async () => {
const region_id = '90b03e87-3880-4164-a310-339994e3f919';
@@ -31,6 +32,8 @@ function TemporalTrendsShiComponent(props) {
const data = await response.json();
const { area_values, spi_values } = data[0].values;
setNationalChartData({ area_values, spi_values });
+
+ setLostAvg(100 - spi_values[spi_values.length - 1][1]);
};
const getChartData = async () => {
@@ -56,7 +59,7 @@ function TemporalTrendsShiComponent(props) {
Temporal Trends
Since 2001, the terrestrial vertebrate species of the Democratic
- Republic of the Congo have lost an average of 1.37% of their suitable
+ Republic of the Congo have lost an average of {lostAvg} % of their suitable
habitat, leading to the country having a Species Habitat Index of
98.63.
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/sii/national-chart/national-chart-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/sii/national-chart/national-chart-component.jsx
index eb0e6661b..65735f790 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/sii/national-chart/national-chart-component.jsx
+++ b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/sii/national-chart/national-chart-component.jsx
@@ -113,18 +113,21 @@ function NationalChartComponent(props) {
// }, [countryData]);
useEffect(() => {
- if (nationalChartData.length) {
+ if (nationalChartData && nationalChartData.values?.length) {
+ console.log(nationalChartData);
+ const values = nationalChartData.values;
+
setData({
- labels: nationalChartData.map((item) => item[0]),
+ labels: values.map((item) => item[0]),
datasets: [
{
label: 'SII',
- data: nationalChartData.map((item) => item[1]),
+ data: values.map((item) => (item[1] * 100)),
borderColor: getCSSVariable('birds'),
},
],
});
- const spiVal = 0;
+ const spiVal = nationalChartData.metrics[0] * 100;
// nationalChartData.spi_values[
// nationalChartData.spi_values.length - 1
// ][1];
@@ -164,7 +167,7 @@ function NationalChartComponent(props) {
data={spiData}
value={spiValue}
/>
-
{countryData?.prop_protected_ter}
+
{nationalChartData.metrics?.[1]}
Year
SII
Global Ranking
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/sii/temporal-trends-sii-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/sii/temporal-trends-sii-component.jsx
index 47a5c6fc7..67f418420 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/sii/temporal-trends-sii-component.jsx
+++ b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/sii/temporal-trends-sii-component.jsx
@@ -26,8 +26,9 @@ function TemporalTrendsSiiComponent(props) {
const data = await response.json();
const { groups } = data[0];
const allVertValues = groups.filter(group => group.taxa === taxa);
+ console.log(allVertValues[0]);
- setNationalChartData(allVertValues[0].values);
+ setNationalChartData(allVertValues[0]);
};
useEffect(() => {
From 39245f90f5bd2cb8c07104ef48d98ffb452e1513 Mon Sep 17 00:00:00 2001
From: Chris Manciero
Date: Fri, 19 Jul 2024 10:46:52 -0400
Subject: [PATCH 035/350] move api calls to parent component
---
.../dashboard-trends-sidebar-component.jsx | 66 ++++++++++++++++--
.../distributions-table-component.jsx | 2 -
.../shi/score-distributions-shi-component.jsx | 17 ++---
.../sii/score-distributions-sii-component.jsx | 67 +++++++++---------
.../spi/score-distributions-spi-component.jsx | 69 +++++++++----------
.../national-chart-component.jsx | 23 +++----
.../shi/temporal-trends-shi-component.jsx | 31 +++------
.../national-chart-component.jsx | 1 -
.../sii/temporal-trends-sii-component.jsx | 18 +++--
.../spi/temporal-trends-spi-component.jsx | 11 +--
10 files changed, 163 insertions(+), 142 deletions(-)
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/dashboard-trends-sidebar-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/dashboard-trends-sidebar-component.jsx
index ff56d7830..f74a332cc 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/dashboard-trends-sidebar-component.jsx
+++ b/src/containers/sidebars/dashboard-trends-sidebar/dashboard-trends-sidebar-component.jsx
@@ -1,4 +1,4 @@
-import React, { useState } from 'react';
+import React, { useEffect, useState } from 'react';
import cx from 'classnames';
@@ -12,6 +12,57 @@ export const PROVINCE_TREND = 'PROVINCE';
function DashboardTrendsSidebar(props) {
const { countryISO, countryData } = props;
const [selectedIndex, setSelectedIndex] = useState(1);
+ const [data, setData] = useState([]);
+ const [shiValue, setShiValue] = useState(0);
+ const [spiValue, setSpiValue] = useState(0);
+ const [siiValue, setSiiValue] = useState(0);
+
+ const getData = async () => {
+ const year = '2021';
+ const regionId = '90b03e87-3880-4164-a310-339994e3f919';
+ const taxa = 'all_terr_verts';
+
+ // SHI calls
+ const shiTrendsUrl = `https://next-api-dot-api-2-x-dot-map-of-life.appspot.com/2.x/indicators/shs/trend?iso=${countryISO}`;
+ const shiScoresUrl = `https://next-api-dot-api-2-x-dot-map-of-life.appspot.com/2.x/indicators/shs/values?iso=${countryISO}&year=${year}`;
+
+ // SPI calls
+ const spiTrendsUrl = `https://next-api-dot-api-2-x-dot-map-of-life.appspot.com/2.x/indicators/nrc?region_id=${regionId}&taxa=${taxa}`;
+ const spiScoresUrl = `https://next-api-dot-api-2-x-dot-map-of-life.appspot.com/2.x/indicators/sps/values?iso=${countryISO}&year=${year}&taxa=${taxa}`;
+
+ // SII calls
+ const siiTrendsUrl = `https://next-api-dot-api-2-x-dot-map-of-life.appspot.com/2.x/indicators/completeness?region_id=${regionId}&indicator=richness&version=2020&weight=national`;
+ const siiScoresUrl = `https://next-api-dot-api-2-x-dot-map-of-life.appspot.com/2.x/indicators/sps/values?iso=${countryISO}&year=${year}&taxa=${taxa}`;
+
+ const apiCalls = [shiTrendsUrl, shiScoresUrl, spiTrendsUrl, spiScoresUrl, siiTrendsUrl, siiScoresUrl];
+
+ const apiResponses = await Promise.all(apiCalls.map(async (url) => {
+ const response = await fetch(url);
+ const data = await response.json();
+ return data;
+ }));
+
+ const shiTrendData = apiResponses[0];
+ const lastValues = shiTrendData[shiTrendData.length - 1];
+
+ const spiTrendData = apiResponses[2];
+ const spiTrendsValues = spiTrendData[0].values;
+ const spiValues = spiTrendsValues.spi_values;
+ const spi = spiValues[spiValues.length - 1][1];
+ setSpiValue(spi);
+
+ const shi = (lastValues.avg_area + lastValues.avg_conn) / 2;
+ setShiValue(shi);
+ setData(apiResponses);
+
+ const siiTrendData = apiResponses[4];
+ setSiiValue((siiTrendData[0].all_taxa_avg * 100).toFixed(2));
+ }
+
+ useEffect(() => {
+ getData();
+ }, [])
+
return (
@@ -29,7 +80,7 @@ function DashboardTrendsSidebar(props) {
})}
onClick={() => setSelectedIndex(1)}
>
- 98.63
+ {shiValue}
Species Habitat Index
setSelectedIndex(2)}
>
- 62.73
+ {spiValue}
Species Protection Index
setSelectedIndex(3)}
>
- 0.49
+ {siiValue}
Species Information Index
@@ -60,11 +111,18 @@ function DashboardTrendsSidebar(props) {
selectedIndex={selectedIndex}
countryData={countryData}
countryISO={countryISO}
+ shiTrendData={data?.[0]}
+ shiNationalData={data?.[2]}
+ spiTrendsData={data?.[2]}
+ siiTrendsData={data?.[4]}
/>
);
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/shi/distributions-table/distributions-table-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/shi/distributions-table/distributions-table-component.jsx
index b87e161bf..f8606eb82 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/shi/distributions-table/distributions-table-component.jsx
+++ b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/shi/distributions-table/distributions-table-component.jsx
@@ -11,8 +11,6 @@ function DistributionsTableComponent(props) {
const t = useT();
const locale = useLocale();
- console.log(chartData)
-
return (
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/shi/score-distributions-shi-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/shi/score-distributions-shi-component.jsx
index 6e08fb67d..b5d0d6f2d 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/shi/score-distributions-shi-component.jsx
+++ b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/shi/score-distributions-shi-component.jsx
@@ -12,7 +12,7 @@ import DistributionsTableContainer from './distributions-table';
import DistributionsChartComponent from 'components/charts/distribution-chart/distribution-chart-component';
function ScoreDistributionsShiComponent(props) {
- const { countryISO, countryData } = props;
+ const { countryData, shiScoresData } = props;
const lowAvg = 'Amphibians';
const highAvg = 'birds';
@@ -41,14 +41,12 @@ function ScoreDistributionsShiComponent(props) {
const [activeScore, setActiveScore] = useState('area');
const getChartData = async () => {
- const year = '2021';
- const url = `https://next-api-dot-api-2-x-dot-map-of-life.appspot.com/2.x/indicators/shs/values?iso=${countryISO}&year=${year}`;
+ if (shiScoresData) {
+ const data = shiScoresData;//await response.json();
- const response = await fetch(url);
- const data = await response.json();
-
- setResponseData(data);
- displayData(data, activeScore);
+ setResponseData(data);
+ displayData(data, activeScore);
+ }
}
const displayData = (data, activeScore) => {
@@ -142,7 +140,7 @@ function ScoreDistributionsShiComponent(props) {
useEffect(() => {
getChartData();
- }, []);
+ }, [shiScoresData]);
const getHistogramData = (taxa) => {
@@ -160,7 +158,6 @@ function ScoreDistributionsShiComponent(props) {
return taxaSet;
}
-
const handleActiveChange = (event) => {
setActiveScore(event.currentTarget.innerText.toLowerCase());
displayData(responseData, event.currentTarget.innerText.toLowerCase());
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/sii/score-distributions-sii-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/sii/score-distributions-sii-component.jsx
index c3b8049ff..8fa0702a4 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/sii/score-distributions-sii-component.jsx
+++ b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/sii/score-distributions-sii-component.jsx
@@ -10,7 +10,7 @@ import SpeciesRichnessComponent from 'components/species-richness/species-richne
import DistributionsChartComponent from 'components/charts/distribution-chart/distribution-chart-component';
function ScoreDistributionsSiiComponent(props) {
- const { countryISO, countryData } = props;
+ const { countryData, siiScoresData } = props;
const lowAvg = 'Amphibians';
const highAvg = 'birds';
@@ -38,44 +38,41 @@ function ScoreDistributionsSiiComponent(props) {
const [showTable, setShowTable] = useState(false);
const getChartData = async () => {
- const year = '2023';
- const taxa = 'all_terr_verts';
- const url = `https://next-api-dot-api-2-x-dot-map-of-life.appspot.com/2.x/indicators/sps/values?iso=${countryISO}&year=${year}&taxa=${taxa}`;
-
- const response = await fetch(url);
- const data = await response.json();
- const taxaSet = {};
-
- // Loop through each number and place it in the appropriate bucket
- data.forEach(a => {
- const number = +a.protection_score;
- // Determine the bucket index based on the floor value of the number
- let bucketIndex = Math.floor(number / 5);
-
- if (!taxaSet.hasOwnProperty(bucketIndex)) {
- taxaSet[bucketIndex] = 1;
- } else {
- taxaSet[bucketIndex] += 1;
- }
- });
-
- const labels = Object.keys(taxaSet).map(key => +key * 5);
-
- setChartData({
- labels,
- datasets: [
- {
- label: 'Items',
- data: Object.values(taxaSet),
- backgroundColor: getCSSVariable('birds'),
- },
- ],
- });
+ if (siiScoresData) {
+ const data = siiScoresData; //await response.json();
+ const taxaSet = {};
+
+ // Loop through each number and place it in the appropriate bucket
+ data.forEach(a => {
+ const number = +a.protection_score;
+ // Determine the bucket index based on the floor value of the number
+ let bucketIndex = Math.floor(number / 5);
+
+ if (!taxaSet.hasOwnProperty(bucketIndex)) {
+ taxaSet[bucketIndex] = 1;
+ } else {
+ taxaSet[bucketIndex] += 1;
+ }
+ });
+
+ const labels = Object.keys(taxaSet).map(key => +key * 5);
+
+ setChartData({
+ labels,
+ datasets: [
+ {
+ label: 'Items',
+ data: Object.values(taxaSet),
+ backgroundColor: getCSSVariable('birds'),
+ },
+ ],
+ });
+ }
};
useEffect(() => {
getChartData();
- }, []);
+ }, [siiScoresData]);
const options = {
plugins: {
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/spi/score-distributions-spi-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/spi/score-distributions-spi-component.jsx
index f2d0ca606..b1bad4101 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/spi/score-distributions-spi-component.jsx
+++ b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/spi/score-distributions-spi-component.jsx
@@ -11,7 +11,7 @@ import compStyles from './score-distributions-spi-styles.module.scss';
import DistributionsChartComponent from 'components/charts/distribution-chart/distribution-chart-component';
function ScoreDistributionsSpiComponent(props) {
- const { countryISO, countryData } = props;
+ const { countryData, spiScoresData } = props;
const lowAvg = 'Amphibians';
const highAvg = 'birds';
@@ -41,39 +41,36 @@ function ScoreDistributionsSpiComponent(props) {
const [showTable, setShowTable] = useState(false);
const getChartData = async () => {
- const year = '2023';
- const taxa = 'all_terr_verts';
- const url = `https://next-api-dot-api-2-x-dot-map-of-life.appspot.com/2.x/indicators/sps/values?iso=${countryISO}&year=${year}&taxa=${taxa}`;
-
- const response = await fetch(url);
- const data = await response.json();
- const taxaSet = {};
-
- // Loop through each number and place it in the appropriate bucket
- data.forEach(a => {
- const number = +a.protection_score;
- // Determine the bucket index based on the floor value of the number
- let bucketIndex = Math.floor(number / 5);
-
- if (!taxaSet.hasOwnProperty(bucketIndex)) {
- taxaSet[bucketIndex] = 1;
- } else {
- taxaSet[bucketIndex] += 1;
- }
- });
-
- const labels = Object.keys(taxaSet).map(key => +key * 5);
-
- setChartData({
- labels,
- datasets: [
- {
- label: 'Items',
- data: Object.values(taxaSet),
- backgroundColor: getCSSVariable('birds'),
- },
- ],
- });
+ if (spiScoresData) {
+ const data = spiScoresData;//await response.json();
+ const taxaSet = {};
+
+ // Loop through each number and place it in the appropriate bucket
+ data.forEach(a => {
+ const number = +a.protection_score;
+ // Determine the bucket index based on the floor value of the number
+ let bucketIndex = Math.floor(number / 5);
+
+ if (!taxaSet.hasOwnProperty(bucketIndex)) {
+ taxaSet[bucketIndex] = 1;
+ } else {
+ taxaSet[bucketIndex] += 1;
+ }
+ });
+
+ const labels = Object.keys(taxaSet).map(key => +key * 5);
+
+ setChartData({
+ labels,
+ datasets: [
+ {
+ label: 'Items',
+ data: Object.values(taxaSet),
+ backgroundColor: getCSSVariable('birds'),
+ },
+ ],
+ });
+ }
};
const getTaxaData = async () => {
@@ -84,14 +81,12 @@ function ScoreDistributionsSpiComponent(props) {
return data;
})
);
-
- console.log(taxaCalls);
}
useEffect(() => {
getTaxaData();
getChartData();
- }, []);
+ }, [spiScoresData]);
const options = {
plugins: {
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/shi/national-chart/national-chart-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/shi/national-chart/national-chart-component.jsx
index 02c54073c..ce416025f 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/shi/national-chart/national-chart-component.jsx
+++ b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/shi/national-chart/national-chart-component.jsx
@@ -21,7 +21,7 @@ ChartJS.register(LinearScale, LineElement, PointElement, Tooltip, Legend);
function NationalChartComponent(props) {
const { countryData, nationalChartData, chartData } = props;
const [data, setData] = useState();
- const [spiValue, setSpiValue] = useState(0);
+ const [shiValue, setShiValue] = useState(0);
const [nationalScores, setNationalScores] = useState({ areaScore: 0, connecivityScore: 0, year: 2001 })
const blankData = {
@@ -42,7 +42,7 @@ function NationalChartComponent(props) {
},
],
};
- const [spiData, setSpiData] = useState(blankData);
+ const [shiData, setShiData] = useState(blankData);
const options = {
plugins: {
@@ -92,17 +92,14 @@ function NationalChartComponent(props) {
useEffect(() => {
if (nationalChartData.area_values.length) {
- const spiVal =
- nationalChartData.spi_values[
- nationalChartData.spi_values.length - 1
- ][1];
+ const shiVal = (nationalScores.areaScore + nationalScores.connecivityScore) / 2;
- const spi = {
- labels: ['Global SPI', 'Remaining'],
+ const shi = {
+ labels: ['Global SHI', 'Remaining'],
datasets: [
{
label: '',
- data: [spiVal, 100 - spiVal],
+ data: [shiVal, 100 - shiVal],
backgroundColor: [
getCSSVariable('temporal-spi'),
getCSSVariable('white-opacity-20'),
@@ -116,8 +113,8 @@ function NationalChartComponent(props) {
],
};
- setSpiValue(spiVal);
- setSpiData(spi);
+ setShiValue(shiVal);
+ setShiData(shi);
}
}, [nationalChartData]);
@@ -164,8 +161,8 @@ function NationalChartComponent(props) {
{nationalScores.connecivityScore}
{countryData?.prop_protected_ter}
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/shi/temporal-trends-shi-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/shi/temporal-trends-shi-component.jsx
index d7ce91deb..593e00f6f 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/shi/temporal-trends-shi-component.jsx
+++ b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/shi/temporal-trends-shi-component.jsx
@@ -13,41 +13,28 @@ import styles from '../../dashboard-trends-sidebar-styles.module.scss';
import NationalChartContainer from './national-chart';
function TemporalTrendsShiComponent(props) {
- const { activeTrend, updateActiveTrend, countryData, selectedIndex, countryISO } = props;
+ const { updateActiveTrend, shiTrendData, shiNationalData } = props;
const [nationalChartData, setNationalChartData] = useState({
area_values: [],
spi_values: [],
});
- const [chartData, setChartData] = useState();
+ // const [chartData, setChartData] = useState();
const [lostAvg, setLostAvg] = useState(0)
const getNationalData = async () => {
- const region_id = '90b03e87-3880-4164-a310-339994e3f919';
- const taxa = 'all_terr_verts';
- const url = `https://next-api-dot-api-2-x-dot-map-of-life.appspot.com/2.x/indicators/nrc?region_id=${region_id}&taxa=${taxa}`;
+ if (shiNationalData) {
+ const { area_values, spi_values } = shiNationalData[0].values;
+ setNationalChartData({ area_values, spi_values });
- const response = await fetch(url);
- const data = await response.json();
- const { area_values, spi_values } = data[0].values;
- setNationalChartData({ area_values, spi_values });
-
- setLostAvg(100 - spi_values[spi_values.length - 1][1]);
+ setLostAvg(100 - spi_values[spi_values.length - 1][1]);
+ }
};
- const getChartData = async () => {
- const url = `https://next-api-dot-api-2-x-dot-map-of-life.appspot.com/2.x/indicators/shs/trend?iso=${countryISO}`;
-
- const response = await fetch(url);
- const data = await response.json();
- setChartData(data);
- }
-
useEffect(() => {
getNationalData();
- getChartData();
- }, []);
+ }, [shiNationalData]);
const handleActionChange = (event) => {
updateActiveTrend(event.currentTarget.innerText);
@@ -91,7 +78,7 @@ function TemporalTrendsShiComponent(props) {
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/sii/national-chart/national-chart-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/sii/national-chart/national-chart-component.jsx
index 65735f790..3a859e1ad 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/sii/national-chart/national-chart-component.jsx
+++ b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/sii/national-chart/national-chart-component.jsx
@@ -114,7 +114,6 @@ function NationalChartComponent(props) {
useEffect(() => {
if (nationalChartData && nationalChartData.values?.length) {
- console.log(nationalChartData);
const values = nationalChartData.values;
setData({
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/sii/temporal-trends-sii-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/sii/temporal-trends-sii-component.jsx
index 67f418420..918197b04 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/sii/temporal-trends-sii-component.jsx
+++ b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/sii/temporal-trends-sii-component.jsx
@@ -10,6 +10,7 @@ import styles from '../../dashboard-trends-sidebar-styles.module.scss';
import NationalChartContainer from './national-chart';
function TemporalTrendsSiiComponent(props) {
+ const { siiTrendsData } = props;
const [nationalChartData, setNationalChartData] = useState({
area_values: [],
spi_values: [],
@@ -19,21 +20,18 @@ function TemporalTrendsSiiComponent(props) {
const taxa = 'all_terr_verts';
const getNationalData = async () => {
- const regionId = '90b03e87-3880-4164-a310-339994e3f919';
- const url = `https://next-api-dot-api-2-x-dot-map-of-life.appspot.com/2.x/indicators/completeness?region_id=${regionId}&indicator=richness&version=2020&weight=national`;
+ if (siiTrendsData) {
+ const data = siiTrendsData;
+ const { groups } = data[0];
+ const allVertValues = groups.filter(group => group.taxa === taxa);
- const response = await fetch(url);
- const data = await response.json();
- const { groups } = data[0];
- const allVertValues = groups.filter(group => group.taxa === taxa);
- console.log(allVertValues[0]);
-
- setNationalChartData(allVertValues[0]);
+ setNationalChartData(allVertValues[0]);
+ }
};
useEffect(() => {
getNationalData();
- }, []);
+ }, [siiTrendsData]);
return (
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/spi/temporal-trends-spi-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/spi/temporal-trends-spi-component.jsx
index 17775a7b7..b52055449 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/spi/temporal-trends-spi-component.jsx
+++ b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/spi/temporal-trends-spi-component.jsx
@@ -14,7 +14,7 @@ import NationalChartContainer from './national-chart';
import ProvinceChartContainer from './province-chart';
function TemporalTrendsSpiComponent(props) {
- const { countryData } = props;
+ const { countryData, spiTrendsData } = props;
const [activeTrend, setActiveTrend] = useState(NATIONAL_TREND);
const [nationalChartData, setNationalChartData] = useState({
@@ -23,19 +23,14 @@ function TemporalTrendsSpiComponent(props) {
});
const getNationalData = async () => {
- const region_id = '90b03e87-3880-4164-a310-339994e3f919';
- const taxa = 'all_terr_verts';
- const url = `https://next-api-dot-api-2-x-dot-map-of-life.appspot.com/2.x/indicators/nrc?region_id=${region_id}&taxa=${taxa}`;
-
- const response = await fetch(url);
- const data = await response.json();
+ const data = spiTrendsData;
const { area_values, spi_values } = data[0].values;
setNationalChartData({ area_values, spi_values });
};
useEffect(() => {
getNationalData();
- }, []);
+ }, [spiTrendsData]);
const handleActionChange = (event) => {
setActiveTrend(event.currentTarget.innerText);
From 8f8cbbe63ed703508933761ab820e477d69275a9 Mon Sep 17 00:00:00 2001
From: Chris Manciero
Date: Fri, 19 Jul 2024 11:38:29 -0400
Subject: [PATCH 036/350] refactor move values around
---
.../dashboard-trends-sidebar-component.jsx | 66 +--------------
.../dashboard-trends-sidebar/index.js | 84 ++++++++++++++++++-
.../dashboard-trends-sidebar/selectors.js | 4 +
.../national-chart-component.jsx | 55 ++++++------
.../shi/temporal-trends-shi-component.jsx | 4 +-
.../dashboard-trends-view-component.jsx | 4 +-
6 files changed, 118 insertions(+), 99 deletions(-)
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/dashboard-trends-sidebar-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/dashboard-trends-sidebar-component.jsx
index f74a332cc..9c0e49c7f 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/dashboard-trends-sidebar-component.jsx
+++ b/src/containers/sidebars/dashboard-trends-sidebar/dashboard-trends-sidebar-component.jsx
@@ -10,58 +10,9 @@ export const NATIONAL_TREND = 'NATIONAL';
export const PROVINCE_TREND = 'PROVINCE';
function DashboardTrendsSidebar(props) {
- const { countryISO, countryData } = props;
- const [selectedIndex, setSelectedIndex] = useState(1);
- const [data, setData] = useState([]);
- const [shiValue, setShiValue] = useState(0);
- const [spiValue, setSpiValue] = useState(0);
- const [siiValue, setSiiValue] = useState(0);
-
- const getData = async () => {
- const year = '2021';
- const regionId = '90b03e87-3880-4164-a310-339994e3f919';
- const taxa = 'all_terr_verts';
-
- // SHI calls
- const shiTrendsUrl = `https://next-api-dot-api-2-x-dot-map-of-life.appspot.com/2.x/indicators/shs/trend?iso=${countryISO}`;
- const shiScoresUrl = `https://next-api-dot-api-2-x-dot-map-of-life.appspot.com/2.x/indicators/shs/values?iso=${countryISO}&year=${year}`;
-
- // SPI calls
- const spiTrendsUrl = `https://next-api-dot-api-2-x-dot-map-of-life.appspot.com/2.x/indicators/nrc?region_id=${regionId}&taxa=${taxa}`;
- const spiScoresUrl = `https://next-api-dot-api-2-x-dot-map-of-life.appspot.com/2.x/indicators/sps/values?iso=${countryISO}&year=${year}&taxa=${taxa}`;
-
- // SII calls
- const siiTrendsUrl = `https://next-api-dot-api-2-x-dot-map-of-life.appspot.com/2.x/indicators/completeness?region_id=${regionId}&indicator=richness&version=2020&weight=national`;
- const siiScoresUrl = `https://next-api-dot-api-2-x-dot-map-of-life.appspot.com/2.x/indicators/sps/values?iso=${countryISO}&year=${year}&taxa=${taxa}`;
-
- const apiCalls = [shiTrendsUrl, shiScoresUrl, spiTrendsUrl, spiScoresUrl, siiTrendsUrl, siiScoresUrl];
+ const { shiValue, siiValue, spiValue } = props;
- const apiResponses = await Promise.all(apiCalls.map(async (url) => {
- const response = await fetch(url);
- const data = await response.json();
- return data;
- }));
-
- const shiTrendData = apiResponses[0];
- const lastValues = shiTrendData[shiTrendData.length - 1];
-
- const spiTrendData = apiResponses[2];
- const spiTrendsValues = spiTrendData[0].values;
- const spiValues = spiTrendsValues.spi_values;
- const spi = spiValues[spiValues.length - 1][1];
- setSpiValue(spi);
-
- const shi = (lastValues.avg_area + lastValues.avg_conn) / 2;
- setShiValue(shi);
- setData(apiResponses);
-
- const siiTrendData = apiResponses[4];
- setSiiValue((siiTrendData[0].all_taxa_avg * 100).toFixed(2));
- }
-
- useEffect(() => {
- getData();
- }, [])
+ const [selectedIndex, setSelectedIndex] = useState(1);
return (
@@ -109,20 +60,11 @@ function DashboardTrendsSidebar(props) {
);
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/index.js b/src/containers/sidebars/dashboard-trends-sidebar/index.js
index b907870c7..b00142b16 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/index.js
+++ b/src/containers/sidebars/dashboard-trends-sidebar/index.js
@@ -1,11 +1,89 @@
-import React from 'react';
+import React, { useEffect, useState } from 'react';
import { connect } from 'react-redux';
import Component from './dashboard-trends-sidebar-component.jsx';
import mapStateToProps from './selectors';
-function DashboardTrendsSidebarContainer() {
- return
;
+function DashboardTrendsSidebarContainer(props) {
+ const { countryISO, countryData } = props;
+
+ const [shiValue, setShiValue] = useState(0);
+ const [spiValue, setSpiValue] = useState(0);
+ const [siiValue, setSiiValue] = useState(0);
+
+ const [shiTrendsData, setShiTrendsData] = useState();
+ const [shiScoresData, setShiScoresData] = useState();
+ const [spiTrendsData, setSpiTrendsData] = useState();
+ const [spiScoresData, setSpiScoresData] = useState();
+ const [siiTrendsData, setSiiTrendsData] = useState();
+ const [siiScoresData, setSiiScoresData] = useState();
+
+ const getData = async () => {
+ const year = '2021';
+ const regionId = '90b03e87-3880-4164-a310-339994e3f919';
+ const taxa = 'all_terr_verts';
+
+ // SHI calls
+ const shiTrendsUrl = `https://next-api-dot-api-2-x-dot-map-of-life.appspot.com/2.x/indicators/shs/trend?iso=${countryISO}`;
+ const shiScoresUrl = `https://next-api-dot-api-2-x-dot-map-of-life.appspot.com/2.x/indicators/shs/values?iso=${countryISO}&year=${year}`;
+
+ // SPI calls
+ const spiTrendsUrl = `https://next-api-dot-api-2-x-dot-map-of-life.appspot.com/2.x/indicators/nrc?region_id=${regionId}&taxa=${taxa}`;
+ const spiScoresUrl = `https://next-api-dot-api-2-x-dot-map-of-life.appspot.com/2.x/indicators/sps/values?iso=${countryISO}&year=${year}&taxa=${taxa}`;
+
+ // SII calls
+ const siiTrendsUrl = `https://next-api-dot-api-2-x-dot-map-of-life.appspot.com/2.x/indicators/completeness?region_id=${regionId}&indicator=richness&version=2020&weight=national`;
+ const siiScoresUrl = `https://next-api-dot-api-2-x-dot-map-of-life.appspot.com/2.x/indicators/sps/values?iso=${countryISO}&year=${year}&taxa=${taxa}`;
+
+ const apiCalls = [shiTrendsUrl, shiScoresUrl, spiTrendsUrl, spiScoresUrl, siiTrendsUrl, siiScoresUrl];
+
+ const apiResponses = await Promise.all(apiCalls.map(async (url) => {
+ const response = await fetch(url);
+ const data = await response.json();
+ return data;
+ }));
+
+ setShiTrendsData(apiResponses[0]);
+ const shiTD = apiResponses[0];
+ const lastValues = shiTD[shiTD.length - 1];
+ setShiScoresData(apiResponses[1]);
+ const shi = (lastValues.avg_area + lastValues.avg_conn) / 2;
+ setShiValue(shi);
+
+ setSpiTrendsData(apiResponses[2]);
+ const spiTD = apiResponses[2];
+ const spiTrendsValues = spiTD[0].values;
+ const spiValues = spiTrendsValues.spi_values;
+ const spi = spiValues[spiValues.length - 1][1];
+ setSpiValue(spi);
+ setSpiScoresData(apiResponses[3]);
+
+ const siiTD = apiResponses[4];
+ setSiiValue((siiTD[0].all_taxa_avg * 100).toFixed(2));
+ setSiiTrendsData(apiResponses[4]);
+ setSiiScoresData(apiResponses[5]);
+ }
+
+ useEffect(() => {
+ getData();
+ }, []);
+
+ return (
+
+ );
}
export default connect(mapStateToProps, null)(DashboardTrendsSidebarContainer);
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/selectors.js b/src/containers/sidebars/dashboard-trends-sidebar/selectors.js
index e69de29bb..ea1aec3d9 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/selectors.js
+++ b/src/containers/sidebars/dashboard-trends-sidebar/selectors.js
@@ -0,0 +1,4 @@
+/* eslint-disable max-len */
+import { createStructuredSelector } from 'reselect';
+
+export default createStructuredSelector({});
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/shi/national-chart/national-chart-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/shi/national-chart/national-chart-component.jsx
index ce416025f..054e2d088 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/shi/national-chart/national-chart-component.jsx
+++ b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/shi/national-chart/national-chart-component.jsx
@@ -19,7 +19,7 @@ import styles from './national-chart-styles.module.scss';
ChartJS.register(LinearScale, LineElement, PointElement, Tooltip, Legend);
function NationalChartComponent(props) {
- const { countryData, nationalChartData, chartData } = props;
+ const { countryData, chartData } = props;
const [data, setData] = useState();
const [shiValue, setShiValue] = useState(0);
const [nationalScores, setNationalScores] = useState({ areaScore: 0, connecivityScore: 0, year: 2001 })
@@ -89,35 +89,6 @@ function NationalChartComponent(props) {
},
};
-
- useEffect(() => {
- if (nationalChartData.area_values.length) {
- const shiVal = (nationalScores.areaScore + nationalScores.connecivityScore) / 2;
-
- const shi = {
- labels: ['Global SHI', 'Remaining'],
- datasets: [
- {
- label: '',
- data: [shiVal, 100 - shiVal],
- backgroundColor: [
- getCSSVariable('temporal-spi'),
- getCSSVariable('white-opacity-20'),
- ],
- borderColor: [
- getCSSVariable('temporal-spi'),
- getCSSVariable('white-opacity-20'),
- ],
- borderWidth: 1,
- },
- ],
- };
-
- setShiValue(shiVal);
- setShiData(shi);
- }
- }, [nationalChartData]);
-
useEffect(() => {
if (chartData) {
setData({
@@ -147,6 +118,30 @@ function NationalChartComponent(props) {
connecivityScore: lastValues.avg_conn,
year: lastValues.year
});
+
+ const shiVal = (lastValues.avg_area + lastValues.avg_conn) / 2;
+
+ const shi = {
+ labels: ['Global SHI', 'Remaining'],
+ datasets: [
+ {
+ label: '',
+ data: [shiVal, 100 - shiVal],
+ backgroundColor: [
+ getCSSVariable('temporal-spi'),
+ getCSSVariable('white-opacity-20'),
+ ],
+ borderColor: [
+ getCSSVariable('temporal-spi'),
+ getCSSVariable('white-opacity-20'),
+ ],
+ borderWidth: 1,
+ },
+ ],
+ };
+
+ setShiValue(shiVal);
+ setShiData(shi);
}
}, [chartData])
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/shi/temporal-trends-shi-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/shi/temporal-trends-shi-component.jsx
index 593e00f6f..c903d9fa2 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/shi/temporal-trends-shi-component.jsx
+++ b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/shi/temporal-trends-shi-component.jsx
@@ -13,7 +13,7 @@ import styles from '../../dashboard-trends-sidebar-styles.module.scss';
import NationalChartContainer from './national-chart';
function TemporalTrendsShiComponent(props) {
- const { updateActiveTrend, shiTrendData, shiNationalData } = props;
+ const { updateActiveTrend, shiTrendsData, shiNationalData } = props;
const [nationalChartData, setNationalChartData] = useState({
area_values: [],
@@ -78,7 +78,7 @@ function TemporalTrendsShiComponent(props) {
diff --git a/src/containers/views/dashboard-trends-view/dashboard-trends-view-component.jsx b/src/containers/views/dashboard-trends-view/dashboard-trends-view-component.jsx
index 719c362c5..8098131a3 100644
--- a/src/containers/views/dashboard-trends-view/dashboard-trends-view-component.jsx
+++ b/src/containers/views/dashboard-trends-view/dashboard-trends-view-component.jsx
@@ -12,7 +12,7 @@ import EsriFeatureService from 'services/esri-feature-service';
import { COUNTRIES_DATA_SERVICE_URL } from 'constants/layers-urls';
-import DashboardTrendsSidebar from '../../sidebars/dashboard-trends-sidebar/dashboard-trends-sidebar-component';
+import DashboardTrendsSidebarContainer from 'containers/sidebars/dashboard-trends-sidebar';
const { VITE_APP_ARGISJS_API_VERSION: API_VERSION } = import.meta.env;
@@ -83,7 +83,7 @@ function DashboardTrendsViewComponent(props) {
url: `https://js.arcgis.com/${API_VERSION}`,
}}
>
-
Date: Fri, 19 Jul 2024 14:47:42 -0400
Subject: [PATCH 037/350] more refactoring
---
.../dashboard-trends-sidebar/index.js | 38 ++++++++-----------
.../shi/score-distributions-shi-component.jsx | 8 ++--
.../sii/score-distributions-sii-component.jsx | 8 ++--
.../spi/score-distributions-spi-component.jsx | 8 ++--
.../national-chart-component.jsx | 2 +-
.../shi/temporal-trends-shi-component.jsx | 4 +-
.../sii/temporal-trends-sii-component.jsx | 9 ++---
.../spi/temporal-trends-spi-component.jsx | 12 +++---
8 files changed, 42 insertions(+), 47 deletions(-)
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/index.js b/src/containers/sidebars/dashboard-trends-sidebar/index.js
index b00142b16..4bcb6c6ef 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/index.js
+++ b/src/containers/sidebars/dashboard-trends-sidebar/index.js
@@ -11,12 +11,9 @@ function DashboardTrendsSidebarContainer(props) {
const [spiValue, setSpiValue] = useState(0);
const [siiValue, setSiiValue] = useState(0);
- const [shiTrendsData, setShiTrendsData] = useState();
- const [shiScoresData, setShiScoresData] = useState();
- const [spiTrendsData, setSpiTrendsData] = useState();
- const [spiScoresData, setSpiScoresData] = useState();
- const [siiTrendsData, setSiiTrendsData] = useState();
- const [siiScoresData, setSiiScoresData] = useState();
+ const [shiData, setShiData] = useState({trendData: [], scoresData: []});
+ const [spiData, setSpiData] = useState({trendData: [], scoresData: []});
+ const [siiData, setSiiData] = useState({trendData: [], scoresData: []});
const getData = async () => {
const year = '2021';
@@ -43,25 +40,25 @@ function DashboardTrendsSidebarContainer(props) {
return data;
}));
- setShiTrendsData(apiResponses[0]);
- const shiTD = apiResponses[0];
+ const [shiTrendData, shiScoresData, spiTrendData, spiScoresData, siiTrendData, siiScoresData] = apiResponses;
+
+ const shiTD = shiTrendData;
const lastValues = shiTD[shiTD.length - 1];
- setShiScoresData(apiResponses[1]);
- const shi = (lastValues.avg_area + lastValues.avg_conn) / 2;
+ const shi = ((lastValues.avg_area + lastValues.avg_conn) / 2).toFixed(2);
setShiValue(shi);
- setSpiTrendsData(apiResponses[2]);
- const spiTD = apiResponses[2];
+ const spiTD = spiTrendData;
const spiTrendsValues = spiTD[0].values;
const spiValues = spiTrendsValues.spi_values;
const spi = spiValues[spiValues.length - 1][1];
setSpiValue(spi);
- setSpiScoresData(apiResponses[3]);
- const siiTD = apiResponses[4];
+ const siiTD = siiTrendData;
setSiiValue((siiTD[0].all_taxa_avg * 100).toFixed(2));
- setSiiTrendsData(apiResponses[4]);
- setSiiScoresData(apiResponses[5]);
+
+ setShiData({trendData: shiTrendData, scoresData: shiScoresData});
+ setSpiData({trendData: spiTrendData, scoresData: spiScoresData});
+ setSiiData({trendData: siiTrendData, scoresData: siiScoresData});
}
useEffect(() => {
@@ -75,12 +72,9 @@ function DashboardTrendsSidebarContainer(props) {
shiValue={shiValue}
spiValue={spiValue}
siiValue={siiValue}
- shiTrendsData={shiTrendsData}
- shiScoresData={shiScoresData}
- spiTrendsData={spiTrendsData}
- spiScoresData={spiScoresData}
- siiTrendsData={siiTrendsData}
- siiScoresData={siiScoresData}
+ shiData={shiData}
+ spiData={spiData}
+ siiData={siiData}
{...props}
/>
);
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/shi/score-distributions-shi-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/shi/score-distributions-shi-component.jsx
index b5d0d6f2d..dd249c91b 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/shi/score-distributions-shi-component.jsx
+++ b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/shi/score-distributions-shi-component.jsx
@@ -12,7 +12,7 @@ import DistributionsTableContainer from './distributions-table';
import DistributionsChartComponent from 'components/charts/distribution-chart/distribution-chart-component';
function ScoreDistributionsShiComponent(props) {
- const { countryData, shiScoresData } = props;
+ const { countryData, shiData } = props;
const lowAvg = 'Amphibians';
const highAvg = 'birds';
@@ -41,8 +41,8 @@ function ScoreDistributionsShiComponent(props) {
const [activeScore, setActiveScore] = useState('area');
const getChartData = async () => {
- if (shiScoresData) {
- const data = shiScoresData;//await response.json();
+ if (shiData.scoresData.length) {
+ const data = shiData.scoresData;
setResponseData(data);
displayData(data, activeScore);
@@ -140,7 +140,7 @@ function ScoreDistributionsShiComponent(props) {
useEffect(() => {
getChartData();
- }, [shiScoresData]);
+ }, [shiData]);
const getHistogramData = (taxa) => {
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/sii/score-distributions-sii-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/sii/score-distributions-sii-component.jsx
index 8fa0702a4..b11147561 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/sii/score-distributions-sii-component.jsx
+++ b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/sii/score-distributions-sii-component.jsx
@@ -10,7 +10,7 @@ import SpeciesRichnessComponent from 'components/species-richness/species-richne
import DistributionsChartComponent from 'components/charts/distribution-chart/distribution-chart-component';
function ScoreDistributionsSiiComponent(props) {
- const { countryData, siiScoresData } = props;
+ const { countryData, siiData } = props;
const lowAvg = 'Amphibians';
const highAvg = 'birds';
@@ -38,8 +38,8 @@ function ScoreDistributionsSiiComponent(props) {
const [showTable, setShowTable] = useState(false);
const getChartData = async () => {
- if (siiScoresData) {
- const data = siiScoresData; //await response.json();
+ if (siiData.scoresData.length) {
+ const data = siiData.scoresData;
const taxaSet = {};
// Loop through each number and place it in the appropriate bucket
@@ -72,7 +72,7 @@ function ScoreDistributionsSiiComponent(props) {
useEffect(() => {
getChartData();
- }, [siiScoresData]);
+ }, [siiData]);
const options = {
plugins: {
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/spi/score-distributions-spi-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/spi/score-distributions-spi-component.jsx
index b1bad4101..933535f8a 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/spi/score-distributions-spi-component.jsx
+++ b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/spi/score-distributions-spi-component.jsx
@@ -11,7 +11,7 @@ import compStyles from './score-distributions-spi-styles.module.scss';
import DistributionsChartComponent from 'components/charts/distribution-chart/distribution-chart-component';
function ScoreDistributionsSpiComponent(props) {
- const { countryData, spiScoresData } = props;
+ const { countryData, spiData } = props;
const lowAvg = 'Amphibians';
const highAvg = 'birds';
@@ -41,8 +41,8 @@ function ScoreDistributionsSpiComponent(props) {
const [showTable, setShowTable] = useState(false);
const getChartData = async () => {
- if (spiScoresData) {
- const data = spiScoresData;//await response.json();
+ if (spiData.scoresData.length) {
+ const data = spiData.scoresData;
const taxaSet = {};
// Loop through each number and place it in the appropriate bucket
@@ -86,7 +86,7 @@ function ScoreDistributionsSpiComponent(props) {
useEffect(() => {
getTaxaData();
getChartData();
- }, [spiScoresData]);
+ }, [spiData]);
const options = {
plugins: {
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/shi/national-chart/national-chart-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/shi/national-chart/national-chart-component.jsx
index 054e2d088..b31fddbb6 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/shi/national-chart/national-chart-component.jsx
+++ b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/shi/national-chart/national-chart-component.jsx
@@ -90,7 +90,7 @@ function NationalChartComponent(props) {
};
useEffect(() => {
- if (chartData) {
+ if (chartData.length) {
setData({
labels: chartData.map((item) => item.year),
datasets: [
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/shi/temporal-trends-shi-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/shi/temporal-trends-shi-component.jsx
index c903d9fa2..dd169abf0 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/shi/temporal-trends-shi-component.jsx
+++ b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/shi/temporal-trends-shi-component.jsx
@@ -13,7 +13,7 @@ import styles from '../../dashboard-trends-sidebar-styles.module.scss';
import NationalChartContainer from './national-chart';
function TemporalTrendsShiComponent(props) {
- const { updateActiveTrend, shiTrendsData, shiNationalData } = props;
+ const { updateActiveTrend, shiData, shiNationalData } = props;
const [nationalChartData, setNationalChartData] = useState({
area_values: [],
@@ -78,7 +78,7 @@ function TemporalTrendsShiComponent(props) {
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/sii/temporal-trends-sii-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/sii/temporal-trends-sii-component.jsx
index 918197b04..91984eb32 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/sii/temporal-trends-sii-component.jsx
+++ b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/sii/temporal-trends-sii-component.jsx
@@ -10,18 +10,17 @@ import styles from '../../dashboard-trends-sidebar-styles.module.scss';
import NationalChartContainer from './national-chart';
function TemporalTrendsSiiComponent(props) {
- const { siiTrendsData } = props;
+ const { siiData } = props;
const [nationalChartData, setNationalChartData] = useState({
area_values: [],
spi_values: [],
});
-
const taxa = 'all_terr_verts';
const getNationalData = async () => {
- if (siiTrendsData) {
- const data = siiTrendsData;
+ if (siiData.trendData.length) {
+ const data = siiData.trendData;
const { groups } = data[0];
const allVertValues = groups.filter(group => group.taxa === taxa);
@@ -31,7 +30,7 @@ function TemporalTrendsSiiComponent(props) {
useEffect(() => {
getNationalData();
- }, [siiTrendsData]);
+ }, [siiData]);
return (
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/spi/temporal-trends-spi-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/spi/temporal-trends-spi-component.jsx
index b52055449..5622f7993 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/spi/temporal-trends-spi-component.jsx
+++ b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/spi/temporal-trends-spi-component.jsx
@@ -14,7 +14,7 @@ import NationalChartContainer from './national-chart';
import ProvinceChartContainer from './province-chart';
function TemporalTrendsSpiComponent(props) {
- const { countryData, spiTrendsData } = props;
+ const { countryData, spiData } = props;
const [activeTrend, setActiveTrend] = useState(NATIONAL_TREND);
const [nationalChartData, setNationalChartData] = useState({
@@ -23,14 +23,16 @@ function TemporalTrendsSpiComponent(props) {
});
const getNationalData = async () => {
- const data = spiTrendsData;
- const { area_values, spi_values } = data[0].values;
- setNationalChartData({ area_values, spi_values });
+ if (spiData.trendData.length) {
+ const data = spiData.trendData;
+ const { area_values, spi_values } = data[0].values;
+ setNationalChartData({ area_values, spi_values });
+ }
};
useEffect(() => {
getNationalData();
- }, [spiTrendsData]);
+ }, [spiData]);
const handleActionChange = (event) => {
setActiveTrend(event.currentTarget.innerText);
From 682091253136a312c10c537a1828a59a01e02992 Mon Sep 17 00:00:00 2001
From: Chris Manciero
Date: Mon, 22 Jul 2024 11:45:54 -0400
Subject: [PATCH 038/350] update text
---
.../shi/score-distributions-shi-component.jsx | 9 +++---
.../sii/score-distributions-sii-component.jsx | 7 ++---
.../shi/temporal-trends-shi-component.jsx | 30 +++++--------------
.../sii/temporal-trends-sii-component.jsx | 10 +++++--
.../spi/temporal-trends-spi-component.jsx | 16 +++++++---
5 files changed, 33 insertions(+), 39 deletions(-)
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/shi/score-distributions-shi-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/shi/score-distributions-shi-component.jsx
index dd249c91b..e2024eb22 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/shi/score-distributions-shi-component.jsx
+++ b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/shi/score-distributions-shi-component.jsx
@@ -223,13 +223,12 @@ function ScoreDistributionsShiComponent(props) {
Score Distributions
- View the distribution of the individual Species Protection Scores for
- all terrestrial vertebrates. {lowAvg} have the lowest average
- protection score while {highAvg} have the highest.
+ View the distribution of the individual Species Habitat Scores,
+ including the two components Area and Connectivity, for all terrestrial vertebrates. {lowAvg} have the lowest average habitat score while {highAvg} have the highest.
- Species with SPS between 0.5:
+ Species with SHS between 35-45:
@@ -246,7 +245,7 @@ function ScoreDistributionsShiComponent(props) {
Add to map
- SPS: 0.04
+ SHS: 0.04
);
})}
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/sii/score-distributions-sii-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/sii/score-distributions-sii-component.jsx
index b11147561..5adad380d 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/sii/score-distributions-sii-component.jsx
+++ b/src/containers/sidebars/dashboard-trends-sidebar/score-distributions/sii/score-distributions-sii-component.jsx
@@ -134,13 +134,12 @@ function ScoreDistributionsSiiComponent(props) {
Score Distributions
- View the distribution of the individual Species Protection Scores for
- all terrestrial vertebrates. {lowAvg} have the lowest average
- protection score while {highAvg} have the highest.
+ View the distribution of the individual Species Information Scores for all
+ terrestrial vertebrates. {lowAvg} have the lowest average information score while {highAvg} have the highest.
- Species with SPS between 0.5:
+ Species with SIS between 0-5:
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/shi/temporal-trends-shi-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/shi/temporal-trends-shi-component.jsx
index dd169abf0..65084432b 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/shi/temporal-trends-shi-component.jsx
+++ b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/shi/temporal-trends-shi-component.jsx
@@ -13,28 +13,15 @@ import styles from '../../dashboard-trends-sidebar-styles.module.scss';
import NationalChartContainer from './national-chart';
function TemporalTrendsShiComponent(props) {
- const { updateActiveTrend, shiData, shiNationalData } = props;
-
- const [nationalChartData, setNationalChartData] = useState({
- area_values: [],
- spi_values: [],
- });
+ const { updateActiveTrend, shiData, shiValue } = props;
// const [chartData, setChartData] = useState();
const [lostAvg, setLostAvg] = useState(0)
- const getNationalData = async () => {
- if (shiNationalData) {
- const { area_values, spi_values } = shiNationalData[0].values;
- setNationalChartData({ area_values, spi_values });
-
- setLostAvg(100 - spi_values[spi_values.length - 1][1]);
- }
- };
-
useEffect(() => {
- getNationalData();
- }, [shiNationalData]);
+ setLostAvg((100 - shiValue).toFixed(2));
+
+ }, []);
const handleActionChange = (event) => {
updateActiveTrend(event.currentTarget.innerText);
@@ -46,13 +33,11 @@ function TemporalTrendsShiComponent(props) {
Temporal Trends
Since 2001, the terrestrial vertebrate species of the Democratic
- Republic of the Congo have lost an average of {lostAvg} % of their suitable
- habitat, leading to the country having a Species Habitat Index of
- 98.63.
+ Republic of the Congo have lost an average of {lostAvg}% of their suitable
+ habitat, leading to the country having a Species Habitat Index of {shiValue}.
- The Area Score addresses changes in habitat extent while the
- Connectivity Score addresses changes in the fragmentation of habitat.
+ The Area Score addresses changes in habitat extent while the Connectivity Score addresses changes in the fragmentation of habitat.
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/sii/temporal-trends-sii-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/sii/temporal-trends-sii-component.jsx
index 91984eb32..ab6cc5d7b 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/sii/temporal-trends-sii-component.jsx
+++ b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/sii/temporal-trends-sii-component.jsx
@@ -1,4 +1,5 @@
import React, { useEffect, useState } from 'react';
+import last from 'lodash/last';
import cx from 'classnames';
@@ -10,11 +11,12 @@ import styles from '../../dashboard-trends-sidebar-styles.module.scss';
import NationalChartContainer from './national-chart';
function TemporalTrendsSiiComponent(props) {
- const { siiData } = props;
+ const { countryData, siiData } = props;
const [nationalChartData, setNationalChartData] = useState({
area_values: [],
spi_values: [],
});
+ const [latestValues, setLatestValues] = useState({ year: 0, spi: 0 })
const taxa = 'all_terr_verts';
@@ -25,6 +27,9 @@ function TemporalTrendsSiiComponent(props) {
const allVertValues = groups.filter(group => group.taxa === taxa);
setNationalChartData(allVertValues[0]);
+
+ const { values } = allVertValues[0];
+ setLatestValues({ year: last(values)[0], spi: (last(values)[1] * 100).toFixed(2) })
}
};
@@ -37,8 +42,7 @@ function TemporalTrendsSiiComponent(props) {
Temporal Trends
- Species data coverage remains low in Democratic Republic of Congo. In
- 2023, 0.44% of the expected ranges of terrestrial vertebrate species
+ Species data coverage remains low in {countryData?.NAME_0} . In {latestValues.year}, {latestValues.spi}% of the expected ranges of terrestrial vertebrate species
here had a recorded observation of that species. Since 1950, the
annual SII has fluctuated between 1.6 and 0.0.
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/spi/temporal-trends-spi-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/spi/temporal-trends-spi-component.jsx
index 5622f7993..ece7b8b81 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/spi/temporal-trends-spi-component.jsx
+++ b/src/containers/sidebars/dashboard-trends-sidebar/temporal-trends/spi/temporal-trends-spi-component.jsx
@@ -12,26 +12,35 @@ import styles from '../../dashboard-trends-sidebar-styles.module.scss';
import NationalChartContainer from './national-chart';
import ProvinceChartContainer from './province-chart';
+import last from 'lodash/last';
function TemporalTrendsSpiComponent(props) {
const { countryData, spiData } = props;
+ const areaProtected = (328357).toLocaleString();
+
const [activeTrend, setActiveTrend] = useState(NATIONAL_TREND);
+ const [spiInfo, setSpiInfo] = useState();
const [nationalChartData, setNationalChartData] = useState({
area_values: [],
spi_values: [],
});
+ const [areaProtectedPercent, setAreaProtectedPercent] = useState(0);
const getNationalData = async () => {
if (spiData.trendData.length) {
const data = spiData.trendData;
const { area_values, spi_values } = data[0].values;
setNationalChartData({ area_values, spi_values });
+
+ setSpiInfo(`${spi_values?.[0][1]} in ${spi_values?.[0][0]} to ${last(spi_values)[1]} in ${last(spi_values)[0]}`);
+ setAreaProtectedPercent(area_values[area_values.length - 1][1]);
}
};
useEffect(() => {
getNationalData();
+
}, [spiData]);
const handleActionChange = (event) => {
@@ -43,10 +52,9 @@ function TemporalTrendsSpiComponent(props) {
Temporal Trends
- Since 1980, the {countryData?.NAME_0} has added 328357 km2 of
- land into its protected area network, representing 14% of the total
- land in the country, increasing its Species Protection Index from
- 27.21 in 1980 to 63 in 2023.
+ Since 1980, the {countryData?.NAME_0} has added {areaProtected} km2 of
+ land into its protected area network, representing {areaProtectedPercent}% of the total
+ land in the country, increasing its Species Protection Index from {spiInfo} .
From de9770f1771c711dcaaebab0c64ca4ca77a0ee04 Mon Sep 17 00:00:00 2001
From: Chris Manciero
Date: Wed, 31 Jul 2024 13:33:49 -0400
Subject: [PATCH 039/350] light mode enable for trends
---
.../spi-arc-chart/spi-arc-chart-component.jsx | 9 +--
.../spi-arc-chart-styles.module.scss | 12 +++-
.../species-info-styles.module.scss | 4 +-
.../dashboard-trends-sidebar-component.jsx | 7 +-
...ashboard-trends-sidebar-styles.module.scss | 65 +++++++++++++------
.../national-chart-component.jsx | 12 ++--
.../national-chart-styles.module.scss | 20 ++++--
.../shi/temporal-trends-shi-component.jsx | 10 +--
.../national-chart-component.jsx | 12 ++--
.../national-chart-styles.module.scss | 20 ++++--
.../sii/temporal-trends-sii-component.jsx | 8 +--
.../national-chart-component.jsx | 12 ++--
.../national-chart-styles.module.scss | 20 ++++--
.../spi/temporal-trends-spi-component.jsx | 6 +-
.../dashboard-trends-view-component.jsx | 19 ++++--
.../dashboard-trends-view.js | 10 +--
src/context/light-mode/index.js | 20 ++++++
src/styles/settings.scss | 8 +++
src/styles/ui.module.scss | 12 +++-
19 files changed, 200 insertions(+), 86 deletions(-)
create mode 100644 src/context/light-mode/index.js
diff --git a/src/components/charts/spi-arc-chart/spi-arc-chart-component.jsx b/src/components/charts/spi-arc-chart/spi-arc-chart-component.jsx
index 64f9447f1..62464d94c 100644
--- a/src/components/charts/spi-arc-chart/spi-arc-chart-component.jsx
+++ b/src/components/charts/spi-arc-chart/spi-arc-chart-component.jsx
@@ -1,6 +1,6 @@
-import React, { useEffect, useState } from 'react';
+import React, { useContext, useEffect, useState } from 'react';
import { Doughnut } from 'react-chartjs-2';
-
+import cx from 'classnames';
import {
Chart as ChartJS,
CategoryScale,
@@ -12,6 +12,7 @@ import {
} from 'chart.js';
import styles from './spi-arc-chart-styles.module.scss';
+import { LightModeContext } from '../../../context/light-mode';
ChartJS.register(
CategoryScale,
@@ -24,7 +25,7 @@ ChartJS.register(
function SpiArcChartComponent(props) {
const { scores, width, height, data, img, species, value } = props;
-
+ const { lightMode } = useContext(LightModeContext);
const [score, setScore] = useState(0);
const doughnutOptions = {
@@ -69,7 +70,7 @@ function SpiArcChartComponent(props) {
}, [value]);
return (
-
+
{scores && (
{getPercentage()[0].toFixed(2)}
)}
diff --git a/src/components/charts/spi-arc-chart/spi-arc-chart-styles.module.scss b/src/components/charts/spi-arc-chart/spi-arc-chart-styles.module.scss
index dd4a45594..f1aaddf5f 100644
--- a/src/components/charts/spi-arc-chart/spi-arc-chart-styles.module.scss
+++ b/src/components/charts/spi-arc-chart/spi-arc-chart-styles.module.scss
@@ -9,8 +9,14 @@
justify-content: center;
align-items: center;
+ --font-color: #{$white};
+
+ &.light{
+ --font-color: #{$black};
+ }
+
.score{
- color: $white;
+ color: var(--font-color);
text-align: center;
font-family: "Open Sans";
font-size: 20px;
@@ -21,7 +27,7 @@
}
.globalScore{
- color: #FFF;
+ color: var(--font-color);
text-align: center;
font-family: "Open Sans";
font-size: 20px;
@@ -38,7 +44,7 @@
align-items: center;
.richness{
- color: $white;
+ color: var(--font-color);
text-align: center;
font-family: "Open Sans";
font-size: 11px;
diff --git a/src/containers/sidebars/dashboard-sidebar/species-info/species-info-styles.module.scss b/src/containers/sidebars/dashboard-sidebar/species-info/species-info-styles.module.scss
index 00810a4d2..1bd97e956 100644
--- a/src/containers/sidebars/dashboard-sidebar/species-info/species-info-styles.module.scss
+++ b/src/containers/sidebars/dashboard-sidebar/species-info/species-info-styles.module.scss
@@ -23,7 +23,7 @@
flex-direction: column;
gap: 3px;
color: $white;
- margin: 0 0 $site-gutter / 2 0;
+ margin: 0 0 calc($site-gutter / 2) 0;
.commonName{
@extend %display1;
@@ -47,7 +47,7 @@
.description {
@extend %bodyText;
color: $white;
- margin: 0 0 $site-gutter / 2 0;
+ margin: 0 0 calc($site-gutter / 2) 0;
font-size: 14px;
}
}
diff --git a/src/containers/sidebars/dashboard-trends-sidebar/dashboard-trends-sidebar-component.jsx b/src/containers/sidebars/dashboard-trends-sidebar/dashboard-trends-sidebar-component.jsx
index 9c0e49c7f..b817e4829 100644
--- a/src/containers/sidebars/dashboard-trends-sidebar/dashboard-trends-sidebar-component.jsx
+++ b/src/containers/sidebars/dashboard-trends-sidebar/dashboard-trends-sidebar-component.jsx
@@ -1,10 +1,11 @@
-import React, { useEffect, useState } from 'react';
+import React, { useContext, useEffect, useState } from 'react';
import cx from 'classnames';
import styles from './dashboard-trends-sidebar-styles.module.scss';
import ScoreDistributionsContainer from './score-distributions';
import TemporalTrendsContainer from './temporal-trends';
+import { LightModeContext } from '../../../context/light-mode';
export const NATIONAL_TREND = 'NATIONAL';
export const PROVINCE_TREND = 'PROVINCE';
@@ -14,14 +15,16 @@ function DashboardTrendsSidebar(props) {
const [selectedIndex, setSelectedIndex] = useState(1);
+ const { lightMode, toggleLightMode } = useContext(LightModeContext);
return (
-