1
- import React from 'react'
1
+ import React , { useMemo } from 'react'
2
+ import { graphql , useStaticQuery } from 'gatsby'
3
+ import { svgDefaultProps as defaults } from '@nivo/heatmap'
2
4
import { Seo } from '../../components/Seo'
3
5
import { ApiClient } from '../../components/components/api-client/ApiClient'
4
6
import { groups } from '../../data/components/heatmap/props'
5
7
import mapper from '../../data/components/heatmap/mapper'
6
8
import { getLightData } from '../../data/components/heatmap/generator'
7
9
import meta from '../../data/components/heatmap/meta.yml'
8
- import { graphql , useStaticQuery } from 'gatsby'
9
-
10
- const data = getLightData ( )
11
10
12
11
const HeatMapApi = ( ) => {
13
12
const {
@@ -24,6 +23,8 @@ const HeatMapApi = () => {
24
23
}
25
24
` )
26
25
26
+ const data = useMemo ( ( ) => getLightData ( ) , [ ] )
27
+
27
28
return (
28
29
< >
29
30
< Seo
@@ -42,27 +43,32 @@ const HeatMapApi = () => {
42
43
defaultProps = { {
43
44
width : 800 ,
44
45
height : 600 ,
45
- data : JSON . stringify ( data . data , null , ' ' ) ,
46
- keys : data . keys ,
47
- indexBy : 'country' ,
48
-
46
+ data : JSON . stringify ( data , null , ' ' ) ,
49
47
margin : {
50
48
top : 100 ,
51
49
right : 60 ,
52
50
bottom : 30 ,
53
51
left : 60 ,
54
52
} ,
55
-
56
- minValue : 'auto' ,
57
- maxValue : 'auto' ,
58
- forceSquare : true ,
59
- sizeVariation : 0.4 ,
60
- padding : 2 ,
61
- colors : 'nivo' ,
62
-
53
+ valueFormat : { format : '>-.2s' , enabled : true } ,
54
+ forceSquare : defaults . forceSquare ,
55
+ sizeVariation : defaults . sizeVariation ,
56
+ xOuterPadding : defaults . xOuterPadding ,
57
+ xInnerPadding : defaults . xInnerPadding ,
58
+ yOuterPadding : defaults . yOuterPadding ,
59
+ yInnerPadding : defaults . yInnerPadding ,
60
+ colors : {
61
+ type : 'diverging' ,
62
+ scheme : 'red_yellow_blue' ,
63
+ divergeAt : 0.5 ,
64
+ minValue : - 100_000 ,
65
+ maxValue : 100_000 ,
66
+ } ,
67
+ emptyColor : '#555555' ,
68
+ enableGridX : false ,
69
+ enableGridY : true ,
63
70
axisTop : {
64
71
enable : true ,
65
- orient : 'top' ,
66
72
tickSize : 5 ,
67
73
tickPadding : 5 ,
68
74
tickRotation : - 55 ,
@@ -71,7 +77,6 @@ const HeatMapApi = () => {
71
77
} ,
72
78
axisRight : {
73
79
enable : false ,
74
- orient : 'right' ,
75
80
tickSize : 5 ,
76
81
tickPadding : 5 ,
77
82
tickRotation : 0 ,
@@ -81,7 +86,6 @@ const HeatMapApi = () => {
81
86
} ,
82
87
axisBottom : {
83
88
enable : false ,
84
- orient : 'bottom' ,
85
89
tickSize : 5 ,
86
90
tickPadding : 5 ,
87
91
tickRotation : 0 ,
@@ -91,31 +95,28 @@ const HeatMapApi = () => {
91
95
} ,
92
96
axisLeft : {
93
97
enable : true ,
94
- orient : 'left' ,
95
98
tickSize : 5 ,
96
99
tickPadding : 5 ,
97
100
tickRotation : 0 ,
98
101
legend : 'country' ,
99
102
legendPosition : 'middle' ,
100
103
legendOffset : - 40 ,
101
104
} ,
102
-
103
- enableGridX : false ,
104
- enableGridY : true ,
105
-
106
- cellShape : 'circle' ,
107
- cellOpacity : 1 ,
108
- cellBorderWidth : 0 ,
109
- cellBorderColor : {
105
+ cellComponent : defaults . cellComponent ,
106
+ borderRadius : defaults . borderRadius ,
107
+ opacity : defaults . opacity ,
108
+ borderWidth : defaults . borderWidth ,
109
+ borderColor : {
110
110
from : 'color' ,
111
111
modifiers : [ [ 'darker' , 0.4 ] ] ,
112
112
} ,
113
-
114
113
enableLabels : true ,
115
114
labelTextColor : {
116
115
from : 'color' ,
117
116
modifiers : [ [ 'darker' , 1.4 ] ] ,
118
117
} ,
118
+ legends : [ ] ,
119
+ annotations : [ ] ,
119
120
} }
120
121
/>
121
122
</ >
0 commit comments