Skip to content

Commit

Permalink
npx cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
eriwarr committed Feb 6, 2025
1 parent f9a44cf commit 5def2f4
Showing 1 changed file with 62 additions and 62 deletions.
124 changes: 62 additions & 62 deletions frontend/src/charts/choroplethMap/TooltipContent.tsx
Original file line number Diff line number Diff line change
@@ -1,62 +1,62 @@
import type React from 'react'
import type { MetricConfig } from '../../data/config/MetricConfigTypes'
import { het } from '../../styles/DesignTokens'

import { formatMetricValue } from './mapHelpers'
import type { TooltipFeature } from './types'

const { borderColor } = het

interface TooltipContentProps {
feature: TooltipFeature
dataMap: Map<string, any>
metricConfig: MetricConfig
geographyType?: string
}

const TooltipContent: React.FC<TooltipContentProps> = ({
feature,
dataMap,
metricConfig,
geographyType = '',
}) => {
const name = feature.properties?.name || String(feature.id)
const data = dataMap.get(feature.id as string)

if (!data) {
return (
<div>
<strong>
{name} {geographyType}
</strong>
<br />
No data available
</div>
)
}

const entries = Object.entries(data).filter(([key]) => key !== 'value')
const [firstLabel, firstValue] = entries[0] ?? ['', 0]
const remainingEntries = entries.slice(1)

return (
<div>
<strong>
{name} {geographyType}
</strong>
<div style={{ textAlign: 'center' }}>
<div style={{ marginBottom: 4 }}>
<span style={{ color: borderColor }}>{firstLabel}:</span>{' '}
{formatMetricValue(firstValue as number, metricConfig)}
</div>
{remainingEntries.map(([label, value]) => (
<div key={label} style={{ marginBottom: 4 }}>
<span style={{ color: borderColor }}>{label}:</span> {String(value)}
</div>
))}
</div>
</div>
)
}

export default TooltipContent
import type React from 'react'
import type { MetricConfig } from '../../data/config/MetricConfigTypes'
import { het } from '../../styles/DesignTokens'

import { formatMetricValue } from './mapHelpers'
import type { TooltipFeature } from './types'

const { borderColor } = het

interface TooltipContentProps {
feature: TooltipFeature
dataMap: Map<string, any>
metricConfig: MetricConfig
geographyType?: string
}

const TooltipContent: React.FC<TooltipContentProps> = ({
feature,
dataMap,
metricConfig,
geographyType = '',
}) => {
const name = feature.properties?.name || String(feature.id)
const data = dataMap.get(feature.id as string)

if (!data) {
return (
<div>
<strong>
{name} {geographyType}
</strong>
<br />
No data available
</div>
)
}

const entries = Object.entries(data).filter(([key]) => key !== 'value')
const [firstLabel, firstValue] = entries[0] ?? ['', 0]
const remainingEntries = entries.slice(1)

return (
<div>
<strong>
{name} {geographyType}
</strong>
<div style={{ textAlign: 'center' }}>
<div style={{ marginBottom: 4 }}>
<span style={{ color: borderColor }}>{firstLabel}:</span>{' '}
{formatMetricValue(firstValue as number, metricConfig)}
</div>
{remainingEntries.map(([label, value]) => (
<div key={label} style={{ marginBottom: 4 }}>
<span style={{ color: borderColor }}>{label}:</span> {String(value)}
</div>
))}
</div>
</div>
)
}

export default TooltipContent

0 comments on commit 5def2f4

Please sign in to comment.