Skip to content

Commit

Permalink
feat(heatmap): update codesandbox example to reflect API changes
Browse files Browse the repository at this point in the history
  • Loading branch information
plouc committed Jan 12, 2022
1 parent be1a8af commit da44298
Showing 1 changed file with 19 additions and 24 deletions.
43 changes: 19 additions & 24 deletions examples/codesandbox/src/charts/HeatMap.tsx
@@ -1,26 +1,10 @@
import {
HeatMapDatum,
ResponsiveHeatMap,
ResponsiveHeatMapCanvas,
} from '@nivo/heatmap'
import { generateCountriesData } from '@nivo/generators'
import { generateXYSeries } from '@nivo/generators'
import { useChart } from '../hooks'

const keys = [
'hot dogs',
'burgers',
'sandwich',
'kebab',
'fries',
'donut',
'junk',
'sushi',
'ramen',
'curry',
'udon',
'bagel',
]

const props = {
axisTop: {
orient: 'top',
Expand All @@ -31,18 +15,29 @@ const props = {
legendOffset: 36,
},
margin: { top: 60, right: 80, bottom: 60, left: 80 },
indexBy: 'country',
keys,
}

export function HeatMap() {
const [data, flavor] = useChart(
() =>
generateCountriesData(keys, {
size: 9,
min: 0,
max: 100,
}) as HeatMapDatum[]
generateXYSeries({
serieIds: ['Japan', 'France', 'US', 'Germany', 'Norway', 'Iceland', 'UK', 'Vietnam'],
x: {
values: ['Train', 'Subway', 'Bus', 'Car', 'Boat', 'Moto', 'Moped', 'Bicycle', 'Others'],
},
y: {
length: NaN,
min: -100_000,
max: 100_000,
round: true,
},
}) as {
id: string
data: {
x: string
y: number
}[]
}[]
)

if (flavor === 'canvas') {
Expand Down

0 comments on commit da44298

Please sign in to comment.