Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Boxplot doc #2316

Merged
merged 6 commits into from
Apr 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion conf/base.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
baseUrl: http://localhost:8000
baseUrl: http://localhost:9000
capture:
pages:
- id: home
Expand Down Expand Up @@ -28,6 +28,10 @@ capture:
- id: voronoi

charts:
- pkg: boxplot
chart: boxplot
flavors: [svg]

- pkg: bump
chart: bump
flavors: [svg]
Expand Down
4 changes: 2 additions & 2 deletions packages/boxplot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

# `@nivo/boxplot`

[![version](https://img.shields.io/npm/v/@nivo/boxplot?style=for-the-badge)](https://www.npmjs.com/package/@nivo/bar)
[![downloads](https://img.shields.io/npm/dm/@nivo/boxplot?style=for-the-badge)](https://www.npmjs.com/package/@nivo/bar)
[![version](https://img.shields.io/npm/v/@nivo/boxplot?style=for-the-badge)](https://www.npmjs.com/package/@nivo/boxplot)
[![downloads](https://img.shields.io/npm/dm/@nivo/boxplot?style=for-the-badge)](https://www.npmjs.com/package/@nivo/boxplot)

## Boxplot

Expand Down
2 changes: 1 addition & 1 deletion packages/boxplot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@
"publishConfig": {
"access": "public"
}
}
}
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 15 additions & 26 deletions scripts/capture.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,16 @@ const getChartUrl = (chart, flavor) => {

return `${Path.join(...chunks)}/?capture=1`
}
const getChartIconFilePath = (chart, variant) => Path.join(
websiteIconsDir,
`${chart}-${variant}.png`
)
const getHomeDemoFilePath = (id) => Path.join(websiteHomeDemosDir, `${id}.png`)
const getPageUrl = (path) => {
return `${Path.join(config.get('baseUrl'), path)}/?capture=1`
}
const getPageFilePath = (id) => Path.join(websitePagesDir, `${id}.png`)

const delay = (time) => new Promise((resolve) => {
setTimeout(resolve, time)
})
const getChartIconFilePath = (chart, variant) =>
Path.join(websiteIconsDir, `${chart}-${variant}.png`)
const getHomeDemoFilePath = id => Path.join(websiteHomeDemosDir, `${id}.png`)
const getPageUrl = path => `${Path.join(config.get('baseUrl'), path)}/?capture=1`
const getPageFilePath = id => Path.join(websitePagesDir, `${id}.png`)

const delay = time =>
new Promise(resolve => {
setTimeout(resolve, time)
})

const captureChart = async (page, { pkg, chart, flavor, theme }) => {
const url = getChartUrl(chart, flavor)
Expand Down Expand Up @@ -136,11 +133,7 @@ const captureIcons = async () => {
})
const page = await browser.newPage()
await page.setViewport(VIEWPORT.icons)
await page.goto(`${Path.join(
config.get('baseUrl'),
'internal',
'icons'
)}/`)
await page.goto(`${Path.join(config.get('baseUrl'), 'internal', 'icons')}/?capture=1`)

for (let icon of icons) {
console.log(chalk`{yellow Capturing {white ${icon}} chart icons}`)
Expand Down Expand Up @@ -191,11 +184,7 @@ const captureHomeDemos = async () => {
})
const page = await browser.newPage()
await page.setViewport(VIEWPORT.homeDemos)
await page.goto(`${Path.join(
config.get('baseUrl'),
'internal',
'home-demos'
)}/?capture=1`)
await page.goto(`${Path.join(config.get('baseUrl'), 'internal', 'home-demos')}/?capture=1`)

for (let demo of demos) {
console.log(chalk`{yellow Capturing {white ${demo.id}} demo}`)
Expand Down Expand Up @@ -287,9 +276,9 @@ const capturePages = async () => {
}

const run = async () => {
await capturePages()
await captureHomeDemos()
await captureCharts()
// await capturePages()
// await captureHomeDemos()
// await captureCharts()
await captureIcons()
}

Expand Down
1 change: 1 addition & 0 deletions website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"@nivo/arcs": "workspace:*",
"@nivo/axes": "workspace:*",
"@nivo/bar": "workspace:*",
"@nivo/boxplot": "workspace:*",
"@nivo/bullet": "workspace:*",
"@nivo/bump": "workspace:*",
"@nivo/calendar": "workspace:*",
Expand Down
9 changes: 9 additions & 0 deletions website/src/@types/file_types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ declare module '*bar/meta.yml' {
export default meta
}

declare module '*boxplot/meta.yml' {
const meta: {
flavors: ChartMetaFlavors
BoxPlot: ChartMeta
}

export default meta
}

declare module '*bullet/meta.yml' {
const meta: {
flavors: ChartMetaFlavors
Expand Down
Binary file modified website/src/assets/icons.png
Loading
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/icons/boxplot-dark-colored.png
Loading
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/icons/boxplot-dark-neutral.png
Loading
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/icons/boxplot-light-colored.png
Loading
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/icons/boxplot-light-neutral.png
Loading
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/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
96 changes: 96 additions & 0 deletions website/src/components/icons/BoxPlotIcon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
import React, { useMemo } from 'react'
import { BoxPlot, BoxPlotSvgProps } from '@nivo/boxplot'
import boxplotLightNeutralImg from '../../assets/icons/boxplot-light-neutral.png'
import boxplotLightColoredImg from '../../assets/icons/boxplot-light-colored.png'
import boxplotDarkNeutralImg from '../../assets/icons/boxplot-dark-neutral.png'
import boxplotDarkColoredImg from '../../assets/icons/boxplot-dark-colored.png'
import { ICON_SIZE, Icon, colors, IconImg } from './styled'
import { IconType } from './types'

const quantiles = [0.1, 0.25, 0.5, 0.75, 0.9]

const chartProps: BoxPlotSvgProps<any> = {
width: ICON_SIZE,
height: ICON_SIZE,
layout: 'horizontal',
margin: {
top: 6,
right: 2,
bottom: 6,
left: 2,
},
padding: 0.15,
enableGridX: false,
enableGridY: false,
axisTop: null,
axisRight: null,
axisBottom: null,
axisLeft: null,
// Using pre-computed data for predictability.
data: [
{
group: 'A',
subGroup: '',
quantiles: quantiles,
values: [1.5, 2.2, 2.9, 3.6, 4.3],
extrema: [1, 5],
mean: 2.5,
n: 100,
},
{
group: 'B',
subGroup: '',
quantiles: quantiles,
values: [2, 2.5, 3.7, 4.5, 5],
extrema: [2, 7],
mean: 3.75,
n: 200,
},
{
group: 'C',
subGroup: '',
quantiles: quantiles,
values: [1, 1.5, 2, 2.5, 3],
extrema: [2, 7],
mean: 3.75,
n: 200,
},
],
medianWidth: 2,
whiskerWidth: 3,
whiskerEndSize: 0.6,
borderRadius: 2,
isInteractive: false,
animate: false,
}

const BoxPlotIconItem = ({ type }: { type: IconType }) => {
const typedColors = useMemo(
() => [colors[type].colors[1], colors[type].colors[2], colors[type].colors[4]],
[type]
)

return (
<Icon id={`boxplot-${type}`} type={type}>
<BoxPlot<any>
{...chartProps}
colors={[typedColors[1]]}
medianColor={typedColors[2]}
whiskerColor={typedColors[2]}
/>
</Icon>
)
}

export const BoxPlotIcon = () => (
<>
<BoxPlotIconItem type="lightNeutral" />
<IconImg url={boxplotLightNeutralImg} />
<BoxPlotIconItem type="lightColored" />
<IconImg url={boxplotLightColoredImg} />
<BoxPlotIconItem type="darkNeutral" />
<IconImg url={boxplotDarkNeutralImg} />
<BoxPlotIconItem type="darkColored" />
<IconImg url={boxplotDarkColoredImg} />
</>
)
2 changes: 2 additions & 0 deletions website/src/components/icons/Icons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { Fragment } from 'react'
import { Container } from './styled'
import { AreaBumpIcon } from './AreaBumpIcon'
import { BarIcon } from './BarIcon'
import { BoxPlotIcon } from './BoxPlotIcon'
import { BulletIcon } from './BulletIcon'
import { BumpIcon } from './BumpIcon'
import { CalendarIcon } from './CalendarIcon'
Expand Down Expand Up @@ -63,6 +64,7 @@ export const Icons = () => (
<ColorsDemo type="lightColored" />
<ColorsDemo type="darkNeutral" />
<ColorsDemo type="darkColored" />
<BoxPlotIcon />
<AreaBumpIcon />
<BarIcon />
<BulletIcon />
Expand Down
15 changes: 15 additions & 0 deletions website/src/data/components/boxplot/generator.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { generateBoxPlotData } from '@nivo/generators'

export const generateLightDataSet = () =>
generateBoxPlotData([
{ group: 'Alpha', subgroup: 'A', mu: 5, sd: 1, n: 20 },
{ group: 'Alpha', subgroup: 'B', mu: 6, sd: 1, n: 20 },
{ group: 'Beta', subgroup: 'A', mu: 8, sd: 1.4, n: 20 },
{ group: 'Beta', subgroup: 'B', mu: 7.5, sd: 1.4, n: 20 },
{ group: 'Gamma', subgroup: 'A', mu: 5, sd: 1, n: 20 },
{ group: 'Gamma', subgroup: 'B', mu: 7.2, sd: 1.8, n: 20 },
{ group: 'Delta', subgroup: 'A', mu: 5, sd: 1, n: 20 },
{ group: 'Delta', subgroup: 'B', mu: 6, sd: 1, n: 20 },
{ group: 'Epsilon', subgroup: 'A', mu: 5, sd: 1.4, n: 20 },
{ group: 'Epsilon', subgroup: 'B', mu: 6, sd: 3, n: 20 },
])
14 changes: 14 additions & 0 deletions website/src/data/components/boxplot/mapper.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { settingsMapper, mapAxis, mapFormat } from '../../../lib/settings'

export default settingsMapper(
{
valueFormat: mapFormat,
axisTop: mapAxis('top'),
axisRight: mapAxis('right'),
axisBottom: mapAxis('bottom'),
axisLeft: mapAxis('left'),
},
{
exclude: ['enable axisTop', 'enable axisRight', 'enable axisBottom', 'enable axisLeft'],
}
)
34 changes: 34 additions & 0 deletions website/src/data/components/boxplot/meta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
flavors:
- flavor: svg
path: /boxplot/

BoxPlot:
package: '@nivo/boxplot'
tags: []
stories: []
# - label: Using markers
# link: bar--with-marker
# - label: Stacked diverging bar chart
# link: bar--diverging-stacked
# - label: Grouped diverging bar chart
# link: bar--diverging-grouped
# - label: Custom bar element
# link: bar--custom-bar-item
# - label: Formatting values
# link: bar--with-formatted-values
# - label: Using custom tooltip
# link: bar--custom-tooltip
# - label: Custom axis ticks
# link: bar--custom-axis-ticks
# - label: With symlog scale
# link: bar--with-symlog-scale
# - label: Race bar chart
# link: bar--race-chart
# - label: Initial hidden ids
# link: bar--initial-hidden-ids
# - label: Using custom label for legends
# link: bar--custom-legend-labels
# - label: Using annotations
# link: bar--with-annotations
description: |
BoxPlot description.
Loading