Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Dec 6, 2021
1 parent f5b404e commit d50c685
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 30 deletions.
6 changes: 5 additions & 1 deletion demo/components/sidenav.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,11 @@ const Sidenav = ({ active, expanded }) => {
</Box>
<Box sx={{ my: [2] }}>
{contents[d].map((e) => {
const normalizedName = e.replace(/[A-Z]/g, (match, offset) => (offset > 0 ? '-' : '') + match.toLowerCase())
const normalizedName = e.replace(
/[A-Z]/g,
(match, offset) =>
(offset > 0 ? '-' : '') + match.toLowerCase()
)
return (
<Link
key={e}
Expand Down
30 changes: 19 additions & 11 deletions demo/pages/bar.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,16 @@ import {
Bar,
} from '@carbonplan/charts'

export const data = Array(11).fill(null).map((_, i) => [i, (i + 1) * 9])
export const data = Array(11)
.fill(null)
.map((_, i) => [i, (i + 1) * 9])

# Bar

This is a simple bar chart.

<Box sx={{ width: '100%', height: '400px' }}>
<Chart x={[-1, 11]} y={[0, 100]} padding={{ left: 60, top: 50 }}>
<Chart x={[-1, 11]} y={[0, 100]} padding={{ left: 60, top: 50 }}>
<Ticks left bottom />
<TickLabels left bottom />
<Axis left bottom />
Expand All @@ -31,7 +33,7 @@ This is a simple bar chart.

```jsx
<Box sx={{ width: '100%', height: '400px' }}>
<Chart x={[-1, 11]} y={[0, 100]} padding={{ left: 60, top: 50 }}>
<Chart x={[-1, 11]} y={[0, 100]} padding={{ left: 60, top: 50 }}>
<Ticks left bottom />
<TickLabels left bottom />
<Axis left bottom />
Expand All @@ -47,7 +49,7 @@ This is a simple bar chart.
### Horizontal bar

<Box sx={{ width: '100%', height: '400px' }}>
<Chart x={[0, 100]} y={[-1, 11]} padding={{ left: 60, top: 50 }}>
<Chart x={[0, 100]} y={[-1, 11]} padding={{ left: 60, top: 50 }}>
<Ticks left bottom />
<TickLabels left bottom />
<Axis left bottom />
Expand All @@ -59,7 +61,7 @@ This is a simple bar chart.

```jsx
<Box sx={{ width: '100%', height: '400px' }}>
<Chart x={[0, 100]} y={[-1, 11]} padding={{ left: 60, top: 50 }}>
<Chart x={[0, 100]} y={[-1, 11]} padding={{ left: 60, top: 50 }}>
<Ticks left bottom />
<TickLabels left bottom />
<Axis left bottom />
Expand All @@ -73,7 +75,7 @@ This is a simple bar chart.
### Floating bar

<Box sx={{ width: '100%', height: '400px' }}>
<Chart x={[-1, 11]} y={[0, 100]} padding={{ left: 60, top: 50 }}>
<Chart x={[-1, 11]} y={[0, 100]} padding={{ left: 60, top: 50 }}>
<Ticks left bottom />
<TickLabels left bottom />
<Axis left bottom />
Expand All @@ -85,7 +87,7 @@ This is a simple bar chart.

```jsx
<Box sx={{ width: '100%', height: '400px' }}>
<Chart x={[-1, 11]} y={[0, 100]} padding={{ left: 60, top: 50 }}>
<Chart x={[-1, 11]} y={[0, 100]} padding={{ left: 60, top: 50 }}>
<Ticks left bottom />
<TickLabels left bottom />
<Axis left bottom />
Expand All @@ -99,24 +101,30 @@ This is a simple bar chart.
### Multiple colors

<Box sx={{ width: '100%', height: '400px' }}>
<Chart x={[-1, 11]} y={[0, 100]} padding={{ left: 60, top: 50 }}>
<Chart x={[-1, 11]} y={[0, 100]} padding={{ left: 60, top: 50 }}>
<Ticks left bottom />
<TickLabels left bottom />
<Axis left bottom />
<Plot>
<Bar data={data} color={data.map((_, i) => ['pink', 'red', 'orange', 'yellow'][i % 4])} />
<Bar
data={data}
color={data.map((_, i) => ['pink', 'red', 'orange', 'yellow'][i % 4])}
/>
</Plot>
</Chart>
</Box>

```jsx
<Box sx={{ width: '100%', height: '400px' }}>
<Chart x={[-1, 11]} y={[0, 100]} padding={{ left: 60, top: 50 }}>
<Chart x={[-1, 11]} y={[0, 100]} padding={{ left: 60, top: 50 }}>
<Ticks left bottom />
<TickLabels left bottom />
<Axis left bottom />
<Plot>
<Bar data={data} color={data.map((_, i) => ['pink', 'red', 'orange', 'yellow'][i % 4])} />
<Bar
data={data}
color={data.map((_, i) => ['pink', 'red', 'orange', 'yellow'][i % 4])}
/>
</Plot>
</Chart>
</Box>
Expand Down
53 changes: 35 additions & 18 deletions demo/pages/stacked-bar.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,18 @@ import {
StackedBar,
} from '@carbonplan/charts'

export const data = Array(11).fill(null).map((_, i) => [i, 0, (i + 1) * 2, (i + 1) * 5, (i + 1) * 9])
export const getRandomColor = () => ['pink', 'red', 'orange', 'yellow', 'green'][Math.floor(Math.random() * 5)]
export const data = Array(11)
.fill(null)
.map((_, i) => [i, 0, (i + 1) * 2, (i + 1) * 5, (i + 1) * 9])
export const getRandomColor = () =>
['pink', 'red', 'orange', 'yellow', 'green'][Math.floor(Math.random() * 5)]

# StackedBar

This is a simple bar chart.

<Box sx={{ width: '100%', height: '400px' }}>
<Chart x={[-1, 11]} y={[0, 100]} padding={{ left: 60, top: 50 }}>
<Chart x={[-1, 11]} y={[0, 100]} padding={{ left: 60, top: 50 }}>
<Ticks left bottom />
<TickLabels left bottom />
<Axis left bottom />
Expand All @@ -32,7 +35,7 @@ This is a simple bar chart.

```jsx
<Box sx={{ width: '100%', height: '400px' }}>
<Chart x={[-1, 11]} y={[0, 100]} padding={{ left: 60, top: 50 }}>
<Chart x={[-1, 11]} y={[0, 100]} padding={{ left: 60, top: 50 }}>
<Ticks left bottom />
<TickLabels left bottom />
<Axis left bottom />
Expand All @@ -48,7 +51,7 @@ This is a simple bar chart.
### Horizontal bar

<Box sx={{ width: '100%', height: '400px' }}>
<Chart x={[0, 100]} y={[-1, 11]} padding={{ left: 60, top: 50 }}>
<Chart x={[0, 100]} y={[-1, 11]} padding={{ left: 60, top: 50 }}>
<Ticks left bottom />
<TickLabels left bottom />
<Axis left bottom />
Expand All @@ -60,7 +63,7 @@ This is a simple bar chart.

```jsx
<Box sx={{ width: '100%', height: '400px' }}>
<Chart x={[0, 100]} y={[-1, 11]} padding={{ left: 60, top: 50 }}>
<Chart x={[0, 100]} y={[-1, 11]} padding={{ left: 60, top: 50 }}>
<Ticks left bottom />
<TickLabels left bottom />
<Axis left bottom />
Expand All @@ -74,24 +77,30 @@ This is a simple bar chart.
### Floating bar

<Box sx={{ width: '100%', height: '400px' }}>
<Chart x={[-1, 11]} y={[0, 100]} padding={{ left: 60, top: 50 }}>
<Chart x={[-1, 11]} y={[0, 100]} padding={{ left: 60, top: 50 }}>
<Ticks left bottom />
<TickLabels left bottom />
<Axis left bottom />
<Plot>
<StackedBar data={data.map(([x, zero, ...yValues]) => [x, ...yValues])} color={'purple'} />
<StackedBar
data={data.map(([x, zero, ...yValues]) => [x, ...yValues])}
color={'purple'}
/>
</Plot>
</Chart>
</Box>

```jsx
<Box sx={{ width: '100%', height: '400px' }}>
<Chart x={[-1, 11]} y={[0, 100]} padding={{ left: 60, top: 50 }}>
<Chart x={[-1, 11]} y={[0, 100]} padding={{ left: 60, top: 50 }}>
<Ticks left bottom />
<TickLabels left bottom />
<Axis left bottom />
<Plot>
<StackedBar data={data.map(([x, zero, ...yValues]) => [x, ...yValues])} color={'purple'} />
<StackedBar
data={data.map(([x, zero, ...yValues]) => [x, ...yValues])}
color={'purple'}
/>
</Plot>
</Chart>
</Box>
Expand All @@ -102,7 +111,7 @@ This is a simple bar chart.
#### Custom stack colors

<Box sx={{ width: '100%', height: '400px' }}>
<Chart x={[-1, 11]} y={[0, 100]} padding={{ left: 60, top: 50 }}>
<Chart x={[-1, 11]} y={[0, 100]} padding={{ left: 60, top: 50 }}>
<Ticks left bottom />
<TickLabels left bottom />
<Axis left bottom />
Expand All @@ -114,7 +123,7 @@ This is a simple bar chart.

```jsx
<Box sx={{ width: '100%', height: '400px' }}>
<Chart x={[-1, 11]} y={[0, 100]} padding={{ left: 60, top: 50 }}>
<Chart x={[-1, 11]} y={[0, 100]} padding={{ left: 60, top: 50 }}>
<Ticks left bottom />
<TickLabels left bottom />
<Axis left bottom />
Expand All @@ -126,29 +135,37 @@ This is a simple bar chart.
```

#### Completely customized colors

<Box sx={{ width: '100%', height: '400px' }}>
<Chart x={[-1, 11]} y={[0, 100]} padding={{ left: 60, top: 50 }}>
<Chart x={[-1, 11]} y={[0, 100]} padding={{ left: 60, top: 50 }}>
<Ticks left bottom />
<TickLabels left bottom />
<Axis left bottom />
<Plot>
<StackedBar data={data} color={data.map((d) => d.slice(2).map((_, i) => getRandomColor()))} />
<StackedBar
data={data}
color={data.map((d) => d.slice(2).map((_, i) => getRandomColor()))}
/>
</Plot>
</Chart>
</Box>

```jsx
<Box sx={{ width: '100%', height: '400px' }}>
<Chart x={[-1, 11]} y={[0, 100]} padding={{ left: 60, top: 50 }}>
<Chart x={[-1, 11]} y={[0, 100]} padding={{ left: 60, top: 50 }}>
<Ticks left bottom />
<TickLabels left bottom />
<Axis left bottom />
<Plot>
<StackedBar data={data} color={data.map((d) => d.slice(2).map(() => getRandomColor()))} />
<StackedBar
data={data}
color={data.map((d) => d.slice(2).map(() => getRandomColor()))}
/>
</Plot>
</Chart>
</Box>
```


export default ({ children }) => <Section name='stacked-bar'>{children}</Section>
export default ({ children }) => (
<Section name='stacked-bar'>{children}</Section>
)

0 comments on commit d50c685

Please sign in to comment.