Skip to content

Commit

Permalink
feat(website): add more chart types to the homepage
Browse files Browse the repository at this point in the history
  • Loading branch information
plouc committed Jan 12, 2022
1 parent 01e6c34 commit bd2c8ad
Show file tree
Hide file tree
Showing 34 changed files with 303 additions and 26 deletions.
5 changes: 5 additions & 0 deletions conf/base.yaml
@@ -1,14 +1,19 @@
baseUrl: http://localhost:8000
capture:
home:
- id: area-bump
- id: bar-horizontal
- id: bar-vertical
- id: bump
- id: calendar
- id: chord
- id: choropleth
- id: circle-packing
- id: line
- id: marimekko
- id: pie
- id: radar
- id: radial-bar
- id: sankey
- id: stream
- id: sunburst
Expand Down
Binary file added website/src/assets/captures/home/area-bump.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified website/src/assets/captures/home/bar-horizontal.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified website/src/assets/captures/home/bar-vertical.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added website/src/assets/captures/home/bump.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified website/src/assets/captures/home/calendar.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified website/src/assets/captures/home/chord.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added website/src/assets/captures/home/choropleth.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified website/src/assets/captures/home/circle-packing.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified website/src/assets/captures/home/line.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added website/src/assets/captures/home/marimekko.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified website/src/assets/captures/home/pie.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified website/src/assets/captures/home/radar.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added website/src/assets/captures/home/radial-bar.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified website/src/assets/captures/home/sankey.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified website/src/assets/captures/home/stream.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified website/src/assets/captures/home/sunburst.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified website/src/assets/captures/home/swarmplot.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified website/src/assets/captures/home/treemap.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified website/src/assets/captures/home/voronoi.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 12 additions & 7 deletions website/src/components/home/Home.tsx
Expand Up @@ -3,20 +3,25 @@ import { Link } from 'gatsby'
import styled from 'styled-components'
import { FiArrowRight } from 'react-icons/fi'
import media from '../../theming/mediaQueries'
import areaBump from '../../assets/captures/home/area-bump.png'
import barHorizontal from '../../assets/captures/home/bar-horizontal.png'
import barVertical from '../../assets/captures/home/bar-vertical.png'
import bump from '../../assets/captures/home/bump.png'
import chord from '../../assets/captures/home/chord.png'
import choropleth from '../../assets/captures/home/choropleth.png'
import line from '../../assets/captures/home/line.png'
import circlePacking from '../../assets/captures/home/circle-packing.png'
import stream from '../../assets/captures/home/stream.png'
import pie from '../../assets/captures/home/pie.png'
import calendar from '../../assets/captures/home/calendar.png'
import radar from '../../assets/captures/home/radar.png'
import radialBar from '../../assets/captures/home/radial-bar.png'
import voronoi from '../../assets/captures/home/voronoi.png'
import treemap from '../../assets/captures/home/treemap.png'
import sunburst from '../../assets/captures/home/sunburst.png'
import sankey from '../../assets/captures/home/sankey.png'
import swarmplot from '../../assets/captures/home/swarmplot.png'
import marimekko from '../../assets/captures/home/marimekko.png'
import logoImg from '../../assets/nivo-logo.png'

const Home = () => {
Expand All @@ -25,7 +30,7 @@ const Home = () => {
<Item name="Chord Diagram" to="/chord/" image={chord} />
<Item name="Line Chart" to="/line/" image={line} />
<Item name="Circle Packing Layout" to="/circle-packing/" image={circlePacking} />
<Item name="Bar Chart" to="/bar/" image={barVertical} />
<Item name="Area Bump Chart" to="/area-bump/" image={areaBump} />
<Item name="Bar Chart" to="/bar/" image={barHorizontal} />
<Item name="Stream Chart" to="/stream/" image={stream} />
<Item name="Pie Chart" to="/pie/" image={pie} />
Expand All @@ -45,13 +50,13 @@ const Home = () => {
<Item name="Sunburst Chart" to="/sunburst/" image={sunburst} />
<Item name="Sankey" to="/sankey/" image={sankey} />
<Item name="Swarm Plot" to="/swarmplot/" image={swarmplot} />
<Item name="Chord Diagram" to="/chord/" image={chord} />
<Item name="Line Chart" to="/line/" image={line} />
<Item name="Circle Packing Layout" to="/circle-packing/" image={circlePacking} />
<Item name="Marimekko Chart" to="/marimekko/" image={marimekko} />
<Item name="Bump Chart" to="/bump/" image={bump} />
<Item name="Radial Bar Chart" to="/radial-bar/" image={radialBar} />
<Item name="Choropleth Map" to="/choropleth/" image={choropleth} />
<Item name="Bar Chart" to="/bar/" image={barVertical} />
<Item name="Bar Chart" to="/bar/" image={barHorizontal} />
<Item name="Stream Chart" to="/stream/" image={stream} />
<Item name="Pie Chart" to="/pie/" image={pie} />
<Item name="Tree Map" to="/treemap/" image={treemap} />
<Item name="Chord Diagram" to="/chord/" image={chord} />
</Container>
)
}
Expand Down
48 changes: 48 additions & 0 deletions website/src/components/home/HomeAreaBumpDemo.tsx
@@ -0,0 +1,48 @@
import React, { useMemo } from 'react'
import random from 'lodash/random'
import { AreaBump } from '@nivo/bump'
import { useHomeTheme } from './theme'
import { dimensions } from './dimensions'
import range from 'lodash/range'

const serieIds = ['JavaScript', 'ReasonML', 'TypeScript', 'Elm']
const generateData = () => {
const years = range(2000, 2005)

return serieIds.map(id => ({
id,
data: years.map(year => ({
x: year,
y: random(5, 40),
})),
}))
}

export const HomeAreaBumpDemo = () => {
const data = useMemo(() => generateData(), [])
const { colors, nivoTheme } = useHomeTheme()

return (
<div id="area-bump">
<AreaBump
width={dimensions.width}
height={dimensions.height}
margin={dimensions.margin}
data={data}
colors={colors}
borderWidth={1}
spacing={12}
borderColor={colors[3]}
blendMode="normal"
enableGridX={true}
axisTop={null}
axisBottom={null}
startLabel={false}
endLabel={false}
isInteractive={false}
animate={false}
theme={nivoTheme}
/>
</div>
)
}
66 changes: 66 additions & 0 deletions website/src/components/home/HomeBumpDemo.tsx
@@ -0,0 +1,66 @@
import React, { useMemo } from 'react'
import { Bump } from '@nivo/bump'
import { useHomeTheme } from './theme'
import { dimensions } from './dimensions'
import range from 'lodash/range'
import shuffle from 'lodash/shuffle'

interface Datum {
x: number
y: number
}

const generateData = () => {
const years = range(2000, 2005)
const ranks = range(1, 6)

const series: {
id: string
data: Datum[]
}[] = ranks.map(rank => {
return {
id: `Serie ${rank}`,
data: [],
}
})

years.forEach(year => {
shuffle(ranks).forEach((rank, i) => {
series[i].data.push({
x: year,
y: rank,
})
})
})

return series
}

export const HomeBumpDemo = () => {
const data = useMemo(() => generateData(), [])
const { colors, nivoTheme } = useHomeTheme()

return (
<div id="bump">
<Bump
width={dimensions.width}
height={dimensions.height}
margin={dimensions.margin}
data={data}
colors={colors}
lineWidth={dimensions.lineWidth}
pointSize={dimensions.pointSize}
endLabel={false}
startLabel={false}
enableGridX={true}
axisTop={null}
axisRight={null}
axisBottom={null}
axisLeft={null}
isInteractive={false}
animate={false}
theme={nivoTheme}
/>
</div>
)
}
35 changes: 35 additions & 0 deletions website/src/components/home/HomeChoroplethDemo.tsx
@@ -0,0 +1,35 @@
import React, { useMemo } from 'react'
import { Choropleth } from '@nivo/geo'
import { useHomeTheme } from './theme'
import { dimensions } from './dimensions'
import { generateChoroplethData } from '../../data/components/geo/generator'
import countries from '../../data/components/geo/world_countries'

export const HomeChoroplethDemo = () => {
const data = useMemo(() => generateChoroplethData(), [])
const { colors, nivoTheme } = useHomeTheme()

return (
<div id="choropleth">
<Choropleth
width={dimensions.width}
height={dimensions.height}
margin={dimensions.margin}
data={data}
features={countries.features}
colors={colors}
domain={[0, 1000000]}
unknownColor={`${colors[0]}44`}
borderWidth={1}
borderColor={colors[3]}
isInteractive={false}
animate={false}
theme={nivoTheme}
projectionType="mercator"
projectionScale={100}
projectionTranslation={[0.5, 0.6]}
projectionRotation={[0, 0, 0]}
/>
</div>
)
}
4 changes: 2 additions & 2 deletions website/src/components/home/HomeLineDemo.tsx
Expand Up @@ -15,13 +15,13 @@ export const HomeLineDemo = () => {
margin={dimensions.margin}
data={generateDrinkStats(12)}
yScale={{ type: 'linear', stacked: true }}
lineWidth={4}
lineWidth={dimensions.lineWidth}
curve="monotoneX"
theme={nivoTheme}
colors={colors}
animate={false}
isInteractive={false}
pointSize={16}
pointSize={dimensions.pointSize}
axisLeft={null}
axisBottom={null}
/>
Expand Down
83 changes: 69 additions & 14 deletions website/src/components/home/HomeMarimekkoDemo.tsx
@@ -1,31 +1,86 @@
import React, { useMemo } from 'react'
import { generateChordData } from '@nivo/generators'
import { ChordCanvas } from '@nivo/chord'
import random from 'lodash/random'
import { Marimekko } from '@nivo/marimekko'
import { useHomeTheme } from './theme'
import { dimensions } from './dimensions'

const getRandomValue = () => random(0, 32)

const generateData = () =>
[`it's good`, `it's sweet`, `it's spicy`, 'worth eating', 'worth buying'].map(statement => ({
statement,
participation: getRandomValue(),
stronglyAgree: getRandomValue(),
agree: getRandomValue(),
disagree: getRandomValue(),
stronglyDisagree: getRandomValue(),
}))

export const HomeMarimekkoDemo = () => {
const data = useMemo(() => generateData(), [])
const { colors, nivoTheme } = useHomeTheme()
const { matrix, keys } = useMemo(() => generateChordData({ size: 7 }), [])

return (
<div id="chord">
<ChordCanvas
<div id="marimekko">
<Marimekko
width={dimensions.width}
height={dimensions.height}
margin={dimensions.margin}
data={matrix}
keys={keys}
data={data}
id="statement"
value="participation"
dimensions={[
{
id: 'disagree strongly',
value: 'stronglyDisagree',
},
{
id: 'disagree',
value: 'disagree',
},
{
id: 'agree',
value: 'agree',
},
{
id: 'agree strongly',
value: 'stronglyAgree',
},
]}
colors={colors}
padAngle={0.04}
innerRadiusRatio={0.9}
enableLabel={false}
defs={[
{
id: 'lines',
type: 'patternLines',
background: 'rgba(0, 0, 0, 0)',
color: 'inherit',
rotation: -45,
lineWidth: 6,
spacing: 10,
},
]}
fill={[
{
match: {
id: 'agree strongly',
},
id: 'lines',
},
{
match: {
id: 'disagree strongly',
},
id: 'lines',
},
]}
borderWidth={1}
borderColor={colors[3]}
innerPadding={6}
offset="expand"
enableGridX={false}
enableGridY={false}
isInteractive={false}
animate={false}
arcBorderWidth={1}
arcBorderColor={colors[3]}
ribbonBorderWidth={1}
ribbonBorderColor={colors[3]}
theme={nivoTheme}
/>
</div>
Expand Down
3 changes: 2 additions & 1 deletion website/src/components/home/HomeRadarDemo.tsx
Expand Up @@ -20,7 +20,8 @@ export const HomeRadarDemo = () => {
theme={nivoTheme}
colors={colors}
curve="linearClosed"
dotSize={7}
dotSize={dimensions.pointSize}
borderWidth={dimensions.lineWidth}
dotBorderWidth={1}
dotBorderColor={colors[1]}
enableDotLabel={false}
Expand Down
45 changes: 45 additions & 0 deletions website/src/components/home/HomeRadialBarDemo.tsx
@@ -0,0 +1,45 @@
import React, { useMemo } from 'react'
import { RadialBar } from '@nivo/radial-bar'
import { useHomeTheme } from './theme'
import { dimensions } from './dimensions'

const generateData = () => {
const ids = ['Supermarket', 'Combini', 'Online', 'Marché']
const categories = ['Vegetables', 'Fruits', 'Meat']

return ids.map(id => ({
id,
data: categories.map(category => ({
x: category,
y: Math.round(Math.random() * 300),
})),
}))
}

export const HomeRadialBarDemo = () => {
const data = useMemo(() => generateData(), [])
const { colors, nivoTheme } = useHomeTheme()

return (
<div id="radial-bar">
<RadialBar
width={dimensions.width}
height={dimensions.height}
margin={dimensions.margin}
data={data}
tracksColor={`${colors[0]}44`}
colors={colors.slice(1)}
endAngle={315}
borderWidth={1}
borderColor={colors[3]}
padding={0.3}
isInteractive={false}
animate={false}
theme={nivoTheme}
enableLabels={false}
radialAxisStart={null}
circularAxisOuter={null}
/>
</div>
)
}

0 comments on commit bd2c8ad

Please sign in to comment.