useLastReading

Returns the last non-null value and its matching category. Returns null when the series has no value.

tsx
import { useLastReading } from '@hzblj/zyplot'

export function LatestPrice({ categories, values }) {
  const reading = useLastReading(categories, values)

  if (!reading) return null
  return <span>{reading.category}: {reading.value}</span>
}