Skip to content

Commit

Permalink
chore: merge in main
Browse files Browse the repository at this point in the history
  • Loading branch information
turban committed Mar 10, 2025
1 parent fd5e6b9 commit 8be37cb
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 104 deletions.
3 changes: 1 addition & 2 deletions src/components/explore/elevation/Elevation.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { demResolution } from '../../../data/datasets.js'
import useEarthEngineTimeSeries from '../../../hooks/useEarthEngineTimeSeries.js'
import exploreStore from '../../../store/exploreStore.js'
import DataLoader from '../../shared/DataLoader.jsx'
import Resolution from '../../shared/Resolution.jsx'
import Chart from '../Chart.jsx'
import getChartConfig from './charts/elevation.js'
import { demResolution } from '../../../data/datasets.js'
// import styles from './styles/VegetationIndexSelect.module.css'

const dataset = {
datasetId: 'USGS/SRTMGL1_003',
Expand Down
102 changes: 0 additions & 102 deletions src/components/explore/elevation/charts/elevation.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,3 @@
import i18n from '@dhis2/d2-i18n'
import { colors } from '@dhis2/ui'
import { interpolate, roundTwoDecimals } from '../../../../utils/calc.js'
import {
animation,
vegetationCredits,
getDailyPeriod,
} from '../../../../utils/chart.js'
import {
addPeriodTimestamp,
getMiddleTime,
getPeriods,
} from '../../../../utils/time.js'

const getInterpolatedSeries = ({ periodType, period, data, band }) =>
getPeriods({ ...period, periodType })
.map(addPeriodTimestamp)
.map((p) => {
const value = interpolate(data, p.middleTime, band)
return {
x: p.middleTime,
y: value !== null ? value * 0.0001 : null,
}
})

const getChartConfig = (name, data) => {
console.log('config', name, data)

Expand Down Expand Up @@ -104,83 +79,6 @@ const getChartConfig = (name, data) => {
},
],
}

/*
const series = [
{
type: 'line',
data: data.map((d) => ({
x: getMiddleTime(d),
y: roundTwoDecimals(d[band] * 0.0001),
})),
name: '16-days',
color: colors.green600,
lineWidth: 3,
zIndex: 2,
},
]
*/

// Used to debug WEEKLY and MONTHLY interpolation
if (periodType) {
series.push({
type: 'line',
data: getInterpolatedSeries({
periodType,
period,
data,
band,
}),
name: periodType,
color: '#555',
lineWidth: 1,
zIndex: 3,
})
}

return {
title: {
text: i18n.t('{{name}}: {{band}} vegetation index 2024', {
name,
band,
period: getDailyPeriod(data),
nsSeparator: ';',
}),
},
credits: vegetationCredits,
tooltip: {
crosshairs: true,
shared: true,
valueSuffix: '°C',
},
xAxis: {
type: 'datetime',
tickInterval: 2592000000,
labels: {
format: '{value: %b}',
},
},
yAxis: {
title: false,
min: 0,
max: 1,
},
chart: {
height: 480,
marginBottom: 75,
},
plotOptions: {
series: {
animation,
},
column: {
borderColor: null,
pointPadding: 0,
groupPadding: 0,
},
},
series,
}
}

export default getChartConfig

0 comments on commit 8be37cb

Please sign in to comment.