Interactive interface for browsing global, full-resolution satellite imagery
WV-3718: Charting Mode On-Hover Imagery (#6364)
christof-wittreichd1d214b93de7
diff --git a/web/js/components/charting/chart-component.js b/web/js/components/charting/chart-component.jsindex f0ab4384b..f9c3b0df7 100644--- a/web/js/components/charting/chart-component.js+++ b/web/js/components/charting/chart-component.js@@ -21,7 +21,6 @@ import { Vector as OlVectorSource } from 'ol/source';import { getCenter } from 'ol/extent';import { inAndOut } from 'ol/easing';import {- Fill as OlStyleFill,Stroke as OlStyleStroke,Style as OlStyle,} from 'ol/style';@@ -100,8 +99,9 @@ function formatToThreeDigits(str) {}function CustomTooltip({- active, payload, label, unit,+ active, payload, label, unit, setHoveredDate,}) {+ setHoveredDate(label);const formattedUnit = unit ? ` (${unit})` : '';if (active && payload && payload.length) {if (!Number.isNaN(payload[0].value)) {@@ -135,16 +135,19 @@ function CustomTooltip({return null;}-function ChartComponent (props) {+function ChartComponent(props) {const {liveData,mapView,createLayer,overviewMapLayerDef,+ layers,} = props;const [errorCollapsed, setErrorCollapsed] = useState(true);+ const [hoveredDate, setHoveredDate] = useState(null);const mapInstanceRef = useRef(null);+ const layerListRef = useRef([]);const {data,@@ -157,6 +160,7 @@ function ChartComponent (props) {numPoints,coordinates,errors,+ layerId,} = liveData;// Normalize error days input robustly (supports array, CSV, and "['...','...']" forms)@@ -236,11 +240,6 @@ function ChartComponent (props) {return bufferYAxisMinAndMax(lowestMin, highestMax);}-----const yAxisValuesArr = getYAxisValues(data);/**@@ -342,6 +341,8 @@ function ChartComponent (props) {}useEffect(() => {+ if (hoveredDate === null) return;+const boxFeature = new OlFeature({geometry: fromExtent(coordinates),});@@ -350,9 +351,6 @@ function ChartComponent (props) {color: 'rgba(255, 255, 255, .6)',width: 1,}),- fill: new OlStyleFill({- color: 'rgba(255, 255, 255, .3)',- }),}));const boxLayer = new OlVectorLayer({source: new OlVectorSource({@@ -368,6 +366,7 @@ function ChartComponent (props) {backgroundLayerGroup.getLayers().getArray().forEach((layer) => {layersList.push(new OlLayerTile({source: layer.getSource(),+ zIndex: 99,}));});const copiedLayerGroup = new OlLayerGroup({@@ -402,13 +401,53 @@ function ChartComponent (props) {});};- createLayerWrapper();-- return () => {- mapInstanceRef.current.setTarget(null);- mapInstanceRef.current = null;+ const createHoveredLayerWrapper = async () => {+ const selectedLayerDef = layers.layerConfig[layerId];+ const layerOptions = {+ date: new Date(hoveredDate),+ };+ const foregroundLayer = await createLayer(selectedLayerDef, layerOptions);+ foregroundLayer.setVisible(true);++ if (foregroundLayer instanceof OlLayerGroup) {+ foregroundLayer.getLayers().getArray().forEach((layer) => {+ layerListRef.current.push(new OlLayerTile({+ source: layer.getSource(),+ opacity: 0.15,+ }));+ layerListRef.current.push(new OlLayerTile({+ source: layer.getSource(),+ extent: coordinates,+ }));+ });+ } else {+ layerListRef.current.push(new OlLayerTile({+ source: foregroundLayer.getSource(),+ opacity: 0.15,+ }));+ layerListRef.current.push(new OlLayerTile({+ source: foregroundLayer.getSource(),+ extent: coordinates,+ }));+ }+ layerListRef.current.forEach((layer) => {+ mapInstanceRef.current.addLayer(layer);+ });};- }, [overviewMapLayerDef]);++ if (!mapInstanceRef.current) {+ createLayerWrapper();+ }++ layerListRef.current.forEach((layer, i) => {+ mapInstanceRef.current.removeLayer(layer);+ });+ layerListRef.current = [];++ if (hoveredDate) {+ createHoveredLayerWrapper();+ }+ }, [overviewMapLayerDef, layerId, hoveredDate]);return (<div className="charting-chart-container">@@ -425,7 +464,7 @@ function ChartComponent (props) {bottom: 10,}}>- <Tooltip content={<CustomTooltip unit={unit} />} />+ <Tooltip content={<CustomTooltip unit={unit} setHoveredDate={setHoveredDate} />} />{' '}{getLineChart(data)}<XAxis dataKey="name" stroke="#a6a5a6" interval={0} tick={<CustomXAxisTick data={data} />} tickLine={false} />@@ -574,6 +613,7 @@ const mapStateToProps = (state) => {mapView: ui.selected.getView(),createLayer: ui.createLayer,overviewMapLayerDef: layers.layerConfig[layerId],+ layers,};};@@ -582,6 +622,7 @@ ChartComponent.propTypes = {mapView: PropTypes.oneOfType([PropTypes.object, PropTypes.oneOf(['null'])]),createLayer: PropTypes.func,overviewMapLayerDef: PropTypes.oneOfType([PropTypes.object, PropTypes.oneOf(['null'])]),+ layers: PropTypes.shape,};CustomXAxisTick.propTypes = {@@ -600,6 +641,7 @@ CustomTooltip.propTypes = {payload: PropTypes.oneOfType([PropTypes.array, PropTypes.oneOf(['null'])]),label: PropTypes.string,unit: PropTypes.string,+ setHoveredDate: PropTypes.func,};export default connect(diff --git a/web/js/components/sidebar/charting-mode-options.js b/web/js/components/sidebar/charting-mode-options.jsindex b285e7dee..a479eb643 100644--- a/web/js/components/sidebar/charting-mode-options.js+++ b/web/js/components/sidebar/charting-mode-options.js@@ -299,14 +299,15 @@ function ChartingModeOptions(props) {* @param {String} simpleStatsURI*/async function getImageStatData(simpleStatsURI) {- const requestOptions = {+ /* const requestOptions = {method: 'GET',redirect: 'follow',- };+ }; */try {- const response = await fetch(simpleStatsURI, requestOptions);- const data = await response.text();+ // const response = await fetch(simpleStatsURI, requestOptions);+ // const data = await response.text();+ const data = '{"mean": {"2026-01-09T00:00:00Z": 0.36017192908918777, "2026-01-10T00:00:00Z": 0.3885369696796461, "2026-01-11T00:00:00Z": 0.30759154163103475, "2026-01-12T00:00:00Z": 0.4103048251029627, "2026-01-13T00:00:00Z": 0.38004374327451756, "2026-01-14T00:00:00Z": 0.29884240160553016, "2026-01-15T00:00:00Z": 0.32887203830425576, "2026-01-16T00:00:00Z": 0.27330539783775376, "2026-01-17T00:00:00Z": 0.2832226909413854, "2026-01-18T00:00:00Z": 0.33304133257060864, "2026-01-19T00:00:00Z": 0.2828463203463203}, "median": {"2026-01-09T00:00:00Z": "0.3", "2026-01-10T00:00:00Z": "0.3", "2026-01-11T00:00:00Z": "0.25", "2026-01-12T00:00:00Z": "0.325", "2026-01-13T00:00:00Z": "0.3", "2026-01-14T00:00:00Z": "0.2", "2026-01-15T00:00:00Z": "0.25", "2026-01-16T00:00:00Z": "0.2", "2026-01-17T00:00:00Z": "0.175", "2026-01-18T00:00:00Z": "0.225", "2026-01-19T00:00:00Z": "0.125"}, "max": {"2026-01-09T00:00:00Z": 1.8, "2026-01-10T00:00:00Z": 2.025, "2026-01-11T00:00:00Z": 1.375, "2026-01-12T00:00:00Z": 2.15, "2026-01-13T00:00:00Z": 1.75, "2026-01-14T00:00:00Z": 1.425, "2026-01-15T00:00:00Z": 1.95, "2026-01-16T00:00:00Z": 1.325, "2026-01-17T00:00:00Z": 1.7, "2026-01-18T00:00:00Z": 1.95, "2026-01-19T00:00:00Z": 0.95}, "min": {"2026-01-09T00:00:00Z": 0.0, "2026-01-10T00:00:00Z": 0.0, "2026-01-11T00:00:00Z": 0.0, "2026-01-12T00:00:00Z": 0.0, "2026-01-13T00:00:00Z": 0.0, "2026-01-14T00:00:00Z": 0.0, "2026-01-15T00:00:00Z": 0.0, "2026-01-16T00:00:00Z": 0.0, "2026-01-17T00:00:00Z": 0.0, "2026-01-18T00:00:00Z": 0.0, "2026-01-19T00:00:00Z": 0.0}, "stdev": {"2026-01-09T00:00:00Z": 0.28477086162742365, "2026-01-10T00:00:00Z": 0.3366963736367211, "2026-01-11T00:00:00Z": 0.27500984108245463, "2026-01-12T00:00:00Z": 0.3469926924277428, "2026-01-13T00:00:00Z": 0.33114352682575054, "2026-01-14T00:00:00Z": 0.3009251064532651, "2026-01-15T00:00:00Z": 0.30514923656549786, "2026-01-16T00:00:00Z": 0.2480364241819868, "2026-01-17T00:00:00Z": 0.26816022698364583, "2026-01-18T00:00:00Z": 0.3366854026007206, "2026-01-19T00:00:00Z": 0.3184876399728323}, "stderr": "0.0002972413888497856", "hist": [["0.0", "477918"], ["0.215", "292653"], ["0.43", "152308"], ["0.645", "98977"], ["0.86", "41353"], ["1.075", "23861"], ["1.29", "9779"], ["1.505", "3220"], ["1.72", "1193"], ["1.935", "848"]]}';// This is the response when the imageStat server failsif (!data || data === 'null') {return {@@ -509,6 +510,7 @@ function ChartingModeOptions(props) {isTruncated: false,numPoints,coordinates: [...bottomLeftLatLong, ...topRightLatLong],+ layerId: layerInfo.id,});updateChartRequestStatus(false);} else {