Skip to content

Commit bd2c8ad

Browse files
committedJan 12, 2022
feat(website): add more chart types to the homepage
1 parent 01e6c34 commit bd2c8ad

34 files changed

+303
-26
lines changed
 

‎conf/base.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
baseUrl: http://localhost:8000
22
capture:
33
home:
4+
- id: area-bump
45
- id: bar-horizontal
56
- id: bar-vertical
7+
- id: bump
68
- id: calendar
79
- id: chord
10+
- id: choropleth
811
- id: circle-packing
912
- id: line
13+
- id: marimekko
1014
- id: pie
1115
- id: radar
16+
- id: radial-bar
1217
- id: sankey
1318
- id: stream
1419
- id: sunburst
55.3 KB

Error rendering embedded code

Invalid image source.

197 Bytes

Error rendering embedded code

Invalid image source.

136 Bytes

Error rendering embedded code

Invalid image source.

36.2 KB

Error rendering embedded code

Invalid image source.

-1.09 KB

Error rendering embedded code

Invalid image source.

411 Bytes

Error rendering embedded code

Invalid image source.

94.8 KB

Error rendering embedded code

Invalid image source.

489 Bytes

Error rendering embedded code

Invalid image source.

-5.96 KB

Error rendering embedded code

Invalid image source.

85.3 KB

Error rendering embedded code

Invalid image source.

-186 Bytes

Error rendering embedded code

Invalid image source.

2.99 KB

Error rendering embedded code

Invalid image source.

49.2 KB

Error rendering embedded code

Invalid image source.

3.73 KB

Error rendering embedded code

Invalid image source.

-4.32 KB

Error rendering embedded code

Invalid image source.

-453 Bytes

Error rendering embedded code

Invalid image source.

1.06 KB

Error rendering embedded code

Invalid image source.

63 Bytes

Error rendering embedded code

Invalid image source.

-9.93 KB

Error rendering embedded code

Invalid image source.

‎website/src/components/home/Home.tsx

+12-7
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,25 @@ import { Link } from 'gatsby'
33
import styled from 'styled-components'
44
import { FiArrowRight } from 'react-icons/fi'
55
import media from '../../theming/mediaQueries'
6+
import areaBump from '../../assets/captures/home/area-bump.png'
67
import barHorizontal from '../../assets/captures/home/bar-horizontal.png'
78
import barVertical from '../../assets/captures/home/bar-vertical.png'
9+
import bump from '../../assets/captures/home/bump.png'
810
import chord from '../../assets/captures/home/chord.png'
11+
import choropleth from '../../assets/captures/home/choropleth.png'
912
import line from '../../assets/captures/home/line.png'
1013
import circlePacking from '../../assets/captures/home/circle-packing.png'
1114
import stream from '../../assets/captures/home/stream.png'
1215
import pie from '../../assets/captures/home/pie.png'
1316
import calendar from '../../assets/captures/home/calendar.png'
1417
import radar from '../../assets/captures/home/radar.png'
18+
import radialBar from '../../assets/captures/home/radial-bar.png'
1519
import voronoi from '../../assets/captures/home/voronoi.png'
1620
import treemap from '../../assets/captures/home/treemap.png'
1721
import sunburst from '../../assets/captures/home/sunburst.png'
1822
import sankey from '../../assets/captures/home/sankey.png'
1923
import swarmplot from '../../assets/captures/home/swarmplot.png'
24+
import marimekko from '../../assets/captures/home/marimekko.png'
2025
import logoImg from '../../assets/nivo-logo.png'
2126

2227
const Home = () => {
@@ -25,7 +30,7 @@ const Home = () => {
2530
<Item name="Chord Diagram" to="/chord/" image={chord} />
2631
<Item name="Line Chart" to="/line/" image={line} />
2732
<Item name="Circle Packing Layout" to="/circle-packing/" image={circlePacking} />
28-
<Item name="Bar Chart" to="/bar/" image={barVertical} />
33+
<Item name="Area Bump Chart" to="/area-bump/" image={areaBump} />
2934
<Item name="Bar Chart" to="/bar/" image={barHorizontal} />
3035
<Item name="Stream Chart" to="/stream/" image={stream} />
3136
<Item name="Pie Chart" to="/pie/" image={pie} />
@@ -45,13 +50,13 @@ const Home = () => {
4550
<Item name="Sunburst Chart" to="/sunburst/" image={sunburst} />
4651
<Item name="Sankey" to="/sankey/" image={sankey} />
4752
<Item name="Swarm Plot" to="/swarmplot/" image={swarmplot} />
48-
<Item name="Chord Diagram" to="/chord/" image={chord} />
49-
<Item name="Line Chart" to="/line/" image={line} />
50-
<Item name="Circle Packing Layout" to="/circle-packing/" image={circlePacking} />
53+
<Item name="Marimekko Chart" to="/marimekko/" image={marimekko} />
54+
<Item name="Bump Chart" to="/bump/" image={bump} />
55+
<Item name="Radial Bar Chart" to="/radial-bar/" image={radialBar} />
56+
<Item name="Choropleth Map" to="/choropleth/" image={choropleth} />
5157
<Item name="Bar Chart" to="/bar/" image={barVertical} />
52-
<Item name="Bar Chart" to="/bar/" image={barHorizontal} />
53-
<Item name="Stream Chart" to="/stream/" image={stream} />
54-
<Item name="Pie Chart" to="/pie/" image={pie} />
58+
<Item name="Tree Map" to="/treemap/" image={treemap} />
59+
<Item name="Chord Diagram" to="/chord/" image={chord} />
5560
</Container>
5661
)
5762
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import React, { useMemo } from 'react'
2+
import random from 'lodash/random'
3+
import { AreaBump } from '@nivo/bump'
4+
import { useHomeTheme } from './theme'
5+
import { dimensions } from './dimensions'
6+
import range from 'lodash/range'
7+
8+
const serieIds = ['JavaScript', 'ReasonML', 'TypeScript', 'Elm']
9+
const generateData = () => {
10+
const years = range(2000, 2005)
11+
12+
return serieIds.map(id => ({
13+
id,
14+
data: years.map(year => ({
15+
x: year,
16+
y: random(5, 40),
17+
})),
18+
}))
19+
}
20+
21+
export const HomeAreaBumpDemo = () => {
22+
const data = useMemo(() => generateData(), [])
23+
const { colors, nivoTheme } = useHomeTheme()
24+
25+
return (
26+
<div id="area-bump">
27+
<AreaBump
28+
width={dimensions.width}
29+
height={dimensions.height}
30+
margin={dimensions.margin}
31+
data={data}
32+
colors={colors}
33+
borderWidth={1}
34+
spacing={12}
35+
borderColor={colors[3]}
36+
blendMode="normal"
37+
enableGridX={true}
38+
axisTop={null}
39+
axisBottom={null}
40+
startLabel={false}
41+
endLabel={false}
42+
isInteractive={false}
43+
animate={false}
44+
theme={nivoTheme}
45+
/>
46+
</div>
47+
)
48+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import React, { useMemo } from 'react'
2+
import { Bump } from '@nivo/bump'
3+
import { useHomeTheme } from './theme'
4+
import { dimensions } from './dimensions'
5+
import range from 'lodash/range'
6+
import shuffle from 'lodash/shuffle'
7+
8+
interface Datum {
9+
x: number
10+
y: number
11+
}
12+
13+
const generateData = () => {
14+
const years = range(2000, 2005)
15+
const ranks = range(1, 6)
16+
17+
const series: {
18+
id: string
19+
data: Datum[]
20+
}[] = ranks.map(rank => {
21+
return {
22+
id: `Serie ${rank}`,
23+
data: [],
24+
}
25+
})
26+
27+
years.forEach(year => {
28+
shuffle(ranks).forEach((rank, i) => {
29+
series[i].data.push({
30+
x: year,
31+
y: rank,
32+
})
33+
})
34+
})
35+
36+
return series
37+
}
38+
39+
export const HomeBumpDemo = () => {
40+
const data = useMemo(() => generateData(), [])
41+
const { colors, nivoTheme } = useHomeTheme()
42+
43+
return (
44+
<div id="bump">
45+
<Bump
46+
width={dimensions.width}
47+
height={dimensions.height}
48+
margin={dimensions.margin}
49+
data={data}
50+
colors={colors}
51+
lineWidth={dimensions.lineWidth}
52+
pointSize={dimensions.pointSize}
53+
endLabel={false}
54+
startLabel={false}
55+
enableGridX={true}
56+
axisTop={null}
57+
axisRight={null}
58+
axisBottom={null}
59+
axisLeft={null}
60+
isInteractive={false}
61+
animate={false}
62+
theme={nivoTheme}
63+
/>
64+
</div>
65+
)
66+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import React, { useMemo } from 'react'
2+
import { Choropleth } from '@nivo/geo'
3+
import { useHomeTheme } from './theme'
4+
import { dimensions } from './dimensions'
5+
import { generateChoroplethData } from '../../data/components/geo/generator'
6+
import countries from '../../data/components/geo/world_countries'
7+
8+
export const HomeChoroplethDemo = () => {
9+
const data = useMemo(() => generateChoroplethData(), [])
10+
const { colors, nivoTheme } = useHomeTheme()
11+
12+
return (
13+
<div id="choropleth">
14+
<Choropleth
15+
width={dimensions.width}
16+
height={dimensions.height}
17+
margin={dimensions.margin}
18+
data={data}
19+
features={countries.features}
20+
colors={colors}
21+
domain={[0, 1000000]}
22+
unknownColor={`${colors[0]}44`}
23+
borderWidth={1}
24+
borderColor={colors[3]}
25+
isInteractive={false}
26+
animate={false}
27+
theme={nivoTheme}
28+
projectionType="mercator"
29+
projectionScale={100}
30+
projectionTranslation={[0.5, 0.6]}
31+
projectionRotation={[0, 0, 0]}
32+
/>
33+
</div>
34+
)
35+
}

‎website/src/components/home/HomeLineDemo.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ export const HomeLineDemo = () => {
1515
margin={dimensions.margin}
1616
data={generateDrinkStats(12)}
1717
yScale={{ type: 'linear', stacked: true }}
18-
lineWidth={4}
18+
lineWidth={dimensions.lineWidth}
1919
curve="monotoneX"
2020
theme={nivoTheme}
2121
colors={colors}
2222
animate={false}
2323
isInteractive={false}
24-
pointSize={16}
24+
pointSize={dimensions.pointSize}
2525
axisLeft={null}
2626
axisBottom={null}
2727
/>

‎website/src/components/home/HomeMarimekkoDemo.tsx

+69-14
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,86 @@
11
import React, { useMemo } from 'react'
2-
import { generateChordData } from '@nivo/generators'
3-
import { ChordCanvas } from '@nivo/chord'
2+
import random from 'lodash/random'
3+
import { Marimekko } from '@nivo/marimekko'
44
import { useHomeTheme } from './theme'
55
import { dimensions } from './dimensions'
66

7+
const getRandomValue = () => random(0, 32)
8+
9+
const generateData = () =>
10+
[`it's good`, `it's sweet`, `it's spicy`, 'worth eating', 'worth buying'].map(statement => ({
11+
statement,
12+
participation: getRandomValue(),
13+
stronglyAgree: getRandomValue(),
14+
agree: getRandomValue(),
15+
disagree: getRandomValue(),
16+
stronglyDisagree: getRandomValue(),
17+
}))
18+
719
export const HomeMarimekkoDemo = () => {
20+
const data = useMemo(() => generateData(), [])
821
const { colors, nivoTheme } = useHomeTheme()
9-
const { matrix, keys } = useMemo(() => generateChordData({ size: 7 }), [])
1022

1123
return (
12-
<div id="chord">
13-
<ChordCanvas
24+
<div id="marimekko">
25+
<Marimekko
1426
width={dimensions.width}
1527
height={dimensions.height}
1628
margin={dimensions.margin}
17-
data={matrix}
18-
keys={keys}
29+
data={data}
30+
id="statement"
31+
value="participation"
32+
dimensions={[
33+
{
34+
id: 'disagree strongly',
35+
value: 'stronglyDisagree',
36+
},
37+
{
38+
id: 'disagree',
39+
value: 'disagree',
40+
},
41+
{
42+
id: 'agree',
43+
value: 'agree',
44+
},
45+
{
46+
id: 'agree strongly',
47+
value: 'stronglyAgree',
48+
},
49+
]}
1950
colors={colors}
20-
padAngle={0.04}
21-
innerRadiusRatio={0.9}
22-
enableLabel={false}
51+
defs={[
52+
{
53+
id: 'lines',
54+
type: 'patternLines',
55+
background: 'rgba(0, 0, 0, 0)',
56+
color: 'inherit',
57+
rotation: -45,
58+
lineWidth: 6,
59+
spacing: 10,
60+
},
61+
]}
62+
fill={[
63+
{
64+
match: {
65+
id: 'agree strongly',
66+
},
67+
id: 'lines',
68+
},
69+
{
70+
match: {
71+
id: 'disagree strongly',
72+
},
73+
id: 'lines',
74+
},
75+
]}
76+
borderWidth={1}
77+
borderColor={colors[3]}
78+
innerPadding={6}
79+
offset="expand"
80+
enableGridX={false}
81+
enableGridY={false}
2382
isInteractive={false}
2483
animate={false}
25-
arcBorderWidth={1}
26-
arcBorderColor={colors[3]}
27-
ribbonBorderWidth={1}
28-
ribbonBorderColor={colors[3]}
2984
theme={nivoTheme}
3085
/>
3186
</div>

‎website/src/components/home/HomeRadarDemo.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ export const HomeRadarDemo = () => {
2020
theme={nivoTheme}
2121
colors={colors}
2222
curve="linearClosed"
23-
dotSize={7}
23+
dotSize={dimensions.pointSize}
24+
borderWidth={dimensions.lineWidth}
2425
dotBorderWidth={1}
2526
dotBorderColor={colors[1]}
2627
enableDotLabel={false}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import React, { useMemo } from 'react'
2+
import { RadialBar } from '@nivo/radial-bar'
3+
import { useHomeTheme } from './theme'
4+
import { dimensions } from './dimensions'
5+
6+
const generateData = () => {
7+
const ids = ['Supermarket', 'Combini', 'Online', 'Marché']
8+
const categories = ['Vegetables', 'Fruits', 'Meat']
9+
10+
return ids.map(id => ({
11+
id,
12+
data: categories.map(category => ({
13+
x: category,
14+
y: Math.round(Math.random() * 300),
15+
})),
16+
}))
17+
}
18+
19+
export const HomeRadialBarDemo = () => {
20+
const data = useMemo(() => generateData(), [])
21+
const { colors, nivoTheme } = useHomeTheme()
22+
23+
return (
24+
<div id="radial-bar">
25+
<RadialBar
26+
width={dimensions.width}
27+
height={dimensions.height}
28+
margin={dimensions.margin}
29+
data={data}
30+
tracksColor={`${colors[0]}44`}
31+
colors={colors.slice(1)}
32+
endAngle={315}
33+
borderWidth={1}
34+
borderColor={colors[3]}
35+
padding={0.3}
36+
isInteractive={false}
37+
animate={false}
38+
theme={nivoTheme}
39+
enableLabels={false}
40+
radialAxisStart={null}
41+
circularAxisOuter={null}
42+
/>
43+
</div>
44+
)
45+
}

‎website/src/components/home/dimensions.ts

+2
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,6 @@ export const dimensions = {
77
bottom: 20,
88
left: 20,
99
},
10+
lineWidth: 6,
11+
pointSize: 18,
1012
}

‎website/src/components/home/index.ts

+5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
1+
export * from './HomeAreaBumpDemo'
12
export * from './HomeBarDemo'
3+
export * from './HomeBumpDemo'
24
export * from './HomeCalendarDemo'
35
export * from './HomeChordDemo'
6+
export * from './HomeChoroplethDemo'
47
export * from './HomeCirclePackingDemo'
58
export * from './HomeLineDemo'
69
export * from './HomePieDemo'
710
export * from './HomeRadarDemo'
11+
export * from './HomeRadialBarDemo'
812
export * from './HomeSankeyDemo'
913
export * from './HomeStreamDemo'
1014
export * from './HomeSunburstDemo'
1115
export * from './HomeSwarmPlotDemo'
1216
export * from './HomeTreeMapDemo'
1317
export * from './HomeVoronoiDemo'
18+
export * from './HomeMarimekkoDemo'
File renamed without changes.
File renamed without changes.

‎website/src/pages/internal/home-demos.tsx

+12-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
import React from 'react'
22
import styled from 'styled-components'
33
import {
4+
HomeAreaBumpDemo,
45
HomeBarDemo,
6+
HomeBumpDemo,
57
HomeCalendarDemo,
68
HomeChordDemo,
9+
HomeChoroplethDemo,
710
HomeCirclePackingDemo,
811
HomeLineDemo,
12+
HomeMarimekkoDemo,
913
HomePieDemo,
1014
HomeRadarDemo,
15+
HomeRadialBarDemo,
1116
HomeSankeyDemo,
1217
HomeStreamDemo,
1318
HomeSunburstDemo,
@@ -18,8 +23,13 @@ import {
1823

1924
const HomeDemosPage = () => (
2025
<Container>
26+
<HomeChoroplethDemo />
27+
<HomeRadialBarDemo />
28+
<HomeAreaBumpDemo />
2129
<HomeBarDemo isHorizontal={false} />
2230
<HomeBarDemo isHorizontal={true} />
31+
<HomeBumpDemo />
32+
<HomeMarimekkoDemo />
2333
<HomeCalendarDemo />
2434
<HomeChordDemo />
2535
<HomeCirclePackingDemo />
@@ -37,11 +47,11 @@ const HomeDemosPage = () => (
3747

3848
const Container = styled.div`
3949
background: ${({ theme }) => theme.colors.coloredRange[2]};
40-
// background: transparent;
50+
background: transparent;
4151
display: flex;
4252
flex-wrap: wrap;
4353
transform-origin: top left;
44-
transform: scale3d(0.5, 0.5, 1);
54+
// transform: scale3d(0.5, 0.5, 1);
4555
width: 1800px;
4656
4757
& > * {
File renamed without changes.

0 commit comments

Comments
 (0)
Please sign in to comment.