From 64cb795037354efbb20feec429d5b38a3ed82f24 Mon Sep 17 00:00:00 2001 From: Chris Williams Date: Fri, 13 Dec 2019 14:04:33 -0800 Subject: [PATCH 1/6] delete(@vx/boxplot) --- packages/vx-boxplot/.npmrc | 1 - packages/vx-boxplot/Readme.md | 85 ------- packages/vx-boxplot/docs/api.md | 55 ----- packages/vx-boxplot/docs/description.md | 11 - packages/vx-boxplot/docs/docs.md | 85 ------- packages/vx-boxplot/docs/install.md | 5 - packages/vx-boxplot/package.json | 43 ---- packages/vx-boxplot/src/boxplots/BoxPlot.jsx | 233 ------------------- packages/vx-boxplot/src/index.js | 2 - packages/vx-boxplot/src/util/computeStats.js | 49 ---- packages/vx-boxplot/test/BoxPlot.test.jsx | 57 ----- 11 files changed, 626 deletions(-) delete mode 100644 packages/vx-boxplot/.npmrc delete mode 100644 packages/vx-boxplot/Readme.md delete mode 100644 packages/vx-boxplot/docs/api.md delete mode 100644 packages/vx-boxplot/docs/description.md delete mode 100644 packages/vx-boxplot/docs/docs.md delete mode 100644 packages/vx-boxplot/docs/install.md delete mode 100644 packages/vx-boxplot/package.json delete mode 100644 packages/vx-boxplot/src/boxplots/BoxPlot.jsx delete mode 100644 packages/vx-boxplot/src/index.js delete mode 100644 packages/vx-boxplot/src/util/computeStats.js delete mode 100644 packages/vx-boxplot/test/BoxPlot.test.jsx diff --git a/packages/vx-boxplot/.npmrc b/packages/vx-boxplot/.npmrc deleted file mode 100644 index 9cf9495031..0000000000 --- a/packages/vx-boxplot/.npmrc +++ /dev/null @@ -1 +0,0 @@ -package-lock=false \ No newline at end of file diff --git a/packages/vx-boxplot/Readme.md b/packages/vx-boxplot/Readme.md deleted file mode 100644 index 21db24b588..0000000000 --- a/packages/vx-boxplot/Readme.md +++ /dev/null @@ -1,85 +0,0 @@ -# @vx/boxplot - - - - - -A boxplot shows the minimum, maximum, and quartiles of a dataset. - -You can pass in props to target the `min`, `max`, `median`, and `box (interquartile range)` shapes using `minProps`, `maxProps`, `medianProps`, and `boxProps`. - -If you are looking to add events over the each boxplot group you can pass in `container={true}` and `containerProps={{ /** */ }}`. - - -## Installation - -``` -npm install --save @vx/boxplot -``` - - -## Components - - - - - [BoxPlot](#boxplot-) - -## API - - - -

<BoxPlot />

- - - -# *BoxPlot*.**boxProps**<object>
Default{}
- -# *BoxPlot*.**boxWidth**<number> - -# *BoxPlot*.**children**<func> - -# *BoxPlot*.**className**<string> - -# *BoxPlot*.**container**<bool>
Defaultfalse
- -# *BoxPlot*.**containerProps**<object>
Default{}
- -# *BoxPlot*.**fill**<string> - -# *BoxPlot*.**fillOpacity**<union(number|string)> - -# *BoxPlot*.**firstQuartile**<number> - -# *BoxPlot*.**horizontal**<bool> - -# *BoxPlot*.**left**<number>
Default0
- -# *BoxPlot*.**max**<number> - -# *BoxPlot*.**maxProps**<object>
Default{}
- -# *BoxPlot*.**median**<number> - -# *BoxPlot*.**medianProps**<object>
Default{}
- -# *BoxPlot*.**min**<number> - -# *BoxPlot*.**minProps**<object>
Default{}
- -# *BoxPlot*.**outlierProps**<object>
Default{}
- -# *BoxPlot*.**outliers**<array>
Default[]
- -# *BoxPlot*.**rx**<number>
Default2
- -# *BoxPlot*.**ry**<number>
Default2
- -# *BoxPlot*.**stroke**<string> - -# *BoxPlot*.**strokeWidth**<union(number|string)> - -# *BoxPlot*.**thirdQuartile**<number> - -# *BoxPlot*.**top**<number>
Default0
- -# *BoxPlot*.**valueScale**<func> diff --git a/packages/vx-boxplot/docs/api.md b/packages/vx-boxplot/docs/api.md deleted file mode 100644 index 6bd7ca00c2..0000000000 --- a/packages/vx-boxplot/docs/api.md +++ /dev/null @@ -1,55 +0,0 @@ -

<BoxPlot />

- - - -# *BoxPlot*.**boxProps**<object>
Default{}
- -# *BoxPlot*.**boxWidth**<number> - -# *BoxPlot*.**children**<func> - -# *BoxPlot*.**className**<string> - -# *BoxPlot*.**container**<bool>
Defaultfalse
- -# *BoxPlot*.**containerProps**<object>
Default{}
- -# *BoxPlot*.**fill**<string> - -# *BoxPlot*.**fillOpacity**<union(number|string)> - -# *BoxPlot*.**firstQuartile**<number> - -# *BoxPlot*.**horizontal**<bool> - -# *BoxPlot*.**left**<number>
Default0
- -# *BoxPlot*.**max**<number> - -# *BoxPlot*.**maxProps**<object>
Default{}
- -# *BoxPlot*.**median**<number> - -# *BoxPlot*.**medianProps**<object>
Default{}
- -# *BoxPlot*.**min**<number> - -# *BoxPlot*.**minProps**<object>
Default{}
- -# *BoxPlot*.**outlierProps**<object>
Default{}
- -# *BoxPlot*.**outliers**<array>
Default[]
- -# *BoxPlot*.**rx**<number>
Default2
- -# *BoxPlot*.**ry**<number>
Default2
- -# *BoxPlot*.**stroke**<string> - -# *BoxPlot*.**strokeWidth**<union(number|string)> - -# *BoxPlot*.**thirdQuartile**<number> - -# *BoxPlot*.**top**<number>
Default0
- -# *BoxPlot*.**valueScale**<func> diff --git a/packages/vx-boxplot/docs/description.md b/packages/vx-boxplot/docs/description.md deleted file mode 100644 index 72f0dff42c..0000000000 --- a/packages/vx-boxplot/docs/description.md +++ /dev/null @@ -1,11 +0,0 @@ -# @vx/boxplot - - - - - -A boxplot shows the minimum, maximum, and quartiles of a dataset. - -You can pass in props to target the `min`, `max`, `median`, and `box (interquartile range)` shapes using `minProps`, `maxProps`, `medianProps`, and `boxProps`. - -If you are looking to add events over the each boxplot group you can pass in `container={true}` and `containerProps={{ /** */ }}`. diff --git a/packages/vx-boxplot/docs/docs.md b/packages/vx-boxplot/docs/docs.md deleted file mode 100644 index 21db24b588..0000000000 --- a/packages/vx-boxplot/docs/docs.md +++ /dev/null @@ -1,85 +0,0 @@ -# @vx/boxplot - - - - - -A boxplot shows the minimum, maximum, and quartiles of a dataset. - -You can pass in props to target the `min`, `max`, `median`, and `box (interquartile range)` shapes using `minProps`, `maxProps`, `medianProps`, and `boxProps`. - -If you are looking to add events over the each boxplot group you can pass in `container={true}` and `containerProps={{ /** */ }}`. - - -## Installation - -``` -npm install --save @vx/boxplot -``` - - -## Components - - - - - [BoxPlot](#boxplot-) - -## API - - - -

<BoxPlot />

- - - -# *BoxPlot*.**boxProps**<object>
Default{}
- -# *BoxPlot*.**boxWidth**<number> - -# *BoxPlot*.**children**<func> - -# *BoxPlot*.**className**<string> - -# *BoxPlot*.**container**<bool>
Defaultfalse
- -# *BoxPlot*.**containerProps**<object>
Default{}
- -# *BoxPlot*.**fill**<string> - -# *BoxPlot*.**fillOpacity**<union(number|string)> - -# *BoxPlot*.**firstQuartile**<number> - -# *BoxPlot*.**horizontal**<bool> - -# *BoxPlot*.**left**<number>
Default0
- -# *BoxPlot*.**max**<number> - -# *BoxPlot*.**maxProps**<object>
Default{}
- -# *BoxPlot*.**median**<number> - -# *BoxPlot*.**medianProps**<object>
Default{}
- -# *BoxPlot*.**min**<number> - -# *BoxPlot*.**minProps**<object>
Default{}
- -# *BoxPlot*.**outlierProps**<object>
Default{}
- -# *BoxPlot*.**outliers**<array>
Default[]
- -# *BoxPlot*.**rx**<number>
Default2
- -# *BoxPlot*.**ry**<number>
Default2
- -# *BoxPlot*.**stroke**<string> - -# *BoxPlot*.**strokeWidth**<union(number|string)> - -# *BoxPlot*.**thirdQuartile**<number> - -# *BoxPlot*.**top**<number>
Default0
- -# *BoxPlot*.**valueScale**<func> diff --git a/packages/vx-boxplot/docs/install.md b/packages/vx-boxplot/docs/install.md deleted file mode 100644 index c72678b437..0000000000 --- a/packages/vx-boxplot/docs/install.md +++ /dev/null @@ -1,5 +0,0 @@ -## Installation - -``` -npm install --save @vx/boxplot -``` diff --git a/packages/vx-boxplot/package.json b/packages/vx-boxplot/package.json deleted file mode 100644 index 05767af797..0000000000 --- a/packages/vx-boxplot/package.json +++ /dev/null @@ -1,43 +0,0 @@ -{ - "name": "@vx/boxplot", - "version": "0.0.192", - "description": "vx box plot", - "sideEffects": false, - "main": "lib/index.js", - "module": "esm/index.js", - "files": [ - "lib", - "esm" - ], - "scripts": { - "docs": "cd ./docs && ../../../node_modules/.bin/react-docgen ../src/boxplots | ../../../scripts/buildDocs.sh" - }, - "repository": { - "type": "git", - "url": "git+https://github.com/hshoff/vx.git" - }, - "keywords": [ - "vx", - "react", - "d3", - "visualizations", - "charts" - ], - "author": "@conglei", - "license": "MIT", - "bugs": { - "url": "https://github.com/hshoff/vx/issues" - }, - "homepage": "https://github.com/hshoff/vx#readme", - "dependencies": { - "@vx/group": "0.0.192", - "classnames": "^2.2.5", - "prop-types": "^15.5.10" - }, - "peerDependencies": { - "react": "^15.0.0-0 || ^16.0.0-0" - }, - "publishConfig": { - "access": "public" - } -} diff --git a/packages/vx-boxplot/src/boxplots/BoxPlot.jsx b/packages/vx-boxplot/src/boxplots/BoxPlot.jsx deleted file mode 100644 index 787aafbfea..0000000000 --- a/packages/vx-boxplot/src/boxplots/BoxPlot.jsx +++ /dev/null @@ -1,233 +0,0 @@ -import React from 'react'; -import classnames from 'classnames'; -import PropTypes from 'prop-types'; -import { Group } from '@vx/group'; - -function verticalToHorizontal({ x1, x2, y1, y2 }) { - return { - x1: y1, - x2: y2, - y1: x1, - y2: x2, - }; -} - -BoxPlot.propTypes = { - left: PropTypes.number, - top: PropTypes.number, - className: PropTypes.string, - max: PropTypes.number, - min: PropTypes.number, - firstQuartile: PropTypes.number, - thirdQuartile: PropTypes.number, - median: PropTypes.number, - boxWidth: PropTypes.number, - fill: PropTypes.string, - fillOpacity: PropTypes.oneOfType([PropTypes.number, PropTypes.string]), - stroke: PropTypes.string, - strokeWidth: PropTypes.oneOfType([PropTypes.number, PropTypes.string]), - rx: PropTypes.number, - ry: PropTypes.number, - valueScale: PropTypes.func, - outliers: PropTypes.array, - horizontal: PropTypes.bool, - medianProps: PropTypes.object, - maxProps: PropTypes.object, - minProps: PropTypes.object, - boxProps: PropTypes.object, - outlierProps: PropTypes.object, - container: PropTypes.bool, - containerProps: PropTypes.object, - children: PropTypes.func, -}; - -export default function BoxPlot({ - left = 0, - top = 0, - className, - max, - min, - firstQuartile, - thirdQuartile, - median, - boxWidth, - fill, - fillOpacity, - stroke, - strokeWidth, - rx = 2, - ry = 2, - valueScale, - outliers = [], - horizontal, - medianProps = {}, - maxProps = {}, - minProps = {}, - boxProps = {}, - outlierProps = {}, - container = false, - containerProps = {}, - children, -}) { - const offset = horizontal ? top : left; - const center = offset + boxWidth / 2; - const valueRange = valueScale.range(); - - const boxplot = { - valueRange, - center, - offset, - boxWidth, - max: { - x1: center - boxWidth / 4, - x2: center + boxWidth / 4, - y1: valueScale(max), - y2: valueScale(max), - }, - maxToThird: { - x1: center, - x2: center, - y1: valueScale(max), - y2: valueScale(thirdQuartile), - }, - median: { - x1: offset, - x2: offset + boxWidth, - y1: valueScale(median), - y2: valueScale(median), - }, - minToFirst: { - x1: center, - x2: center, - y1: valueScale(firstQuartile), - y2: valueScale(min), - }, - min: { - x1: center - boxWidth / 4, - x2: center + boxWidth / 4, - y1: valueScale(min), - y2: valueScale(min), - }, - box: { - x1: offset, - x2: boxWidth, - y1: valueScale(thirdQuartile), - y2: Math.abs(valueScale(thirdQuartile) - valueScale(firstQuartile)), - }, - container: { - x1: offset, - x2: boxWidth, - y1: Math.min(...valueRange), - y2: Math.abs(valueRange[0] - valueRange[1]), - }, - }; - - if (horizontal) { - boxplot.max = verticalToHorizontal(boxplot.max); - boxplot.maxToThird = verticalToHorizontal(boxplot.maxToThird); - boxplot.box.y1 = valueScale(firstQuartile); - boxplot.box = verticalToHorizontal(boxplot.box); - boxplot.median = verticalToHorizontal(boxplot.median); - boxplot.minToFirst = verticalToHorizontal(boxplot.minToFirst); - boxplot.min = verticalToHorizontal(boxplot.min); - boxplot.container = verticalToHorizontal(boxplot.container); - boxplot.container.y1 = Math.min(...valueRange); - } - - if (children) return children(boxplot); - - return ( - - {outliers.map((d, i) => { - const cx = horizontal ? valueScale(d) : center; - const cy = horizontal ? center : valueScale(d); - return ( - - ); - })} - - - - - - - {container && ( - - )} - - ); -} diff --git a/packages/vx-boxplot/src/index.js b/packages/vx-boxplot/src/index.js deleted file mode 100644 index 66fb571ea9..0000000000 --- a/packages/vx-boxplot/src/index.js +++ /dev/null @@ -1,2 +0,0 @@ -export { default as BoxPlot } from './boxplots/BoxPlot'; -export { default as computeStats } from './util/computeStats'; diff --git a/packages/vx-boxplot/src/util/computeStats.js b/packages/vx-boxplot/src/util/computeStats.js deleted file mode 100644 index c2e62cacb4..0000000000 --- a/packages/vx-boxplot/src/util/computeStats.js +++ /dev/null @@ -1,49 +0,0 @@ -export default function computeStats(numericalArray) { - const points = [...numericalArray].sort((a, b) => a - b); - const sampleSize = points.length; - const firstQuartile = points[Math.round(sampleSize / 4)]; - const thirdQuartile = points[Math.round((3 * sampleSize) / 4)]; - const IQR = thirdQuartile - firstQuartile; - - const min = firstQuartile - 1.5 * IQR; - const max = thirdQuartile + 1.5 * IQR; - - const outliers = points.filter(p => p < min || p > max); - const binWidth = 2 * IQR * (sampleSize - outliers.length) ** (-1 / 3); - const binNum = Math.round((max - min) / binWidth); - const actualBinWidth = (max - min) / binNum; - - const bins = new Array(binNum + 2).fill(0); - const values = new Array(binNum + 2).fill(min); - - for (let i = 1; i <= binNum; i += 1) { - values[i] += actualBinWidth * (i - 0.5); - } - - values[values.length - 1] = max; - - points - .filter(p => p >= min && p <= max) - .forEach(p => { - bins[Math.floor((p - min) / actualBinWidth) + 1] += 1; - }); - - const binData = values.map((v, i) => ({ - value: v, - count: bins[i], - })); - - const boxPlot = { - min, - firstQuartile, - median: points[Math.round(sampleSize / 2)], - thirdQuartile, - max, - outliers, - }; - - return { - boxPlot, - binData, - }; -} diff --git a/packages/vx-boxplot/test/BoxPlot.test.jsx b/packages/vx-boxplot/test/BoxPlot.test.jsx deleted file mode 100644 index 0e165aab00..0000000000 --- a/packages/vx-boxplot/test/BoxPlot.test.jsx +++ /dev/null @@ -1,57 +0,0 @@ -import React from 'react'; -import { shallow } from 'enzyme'; - -import { scaleLinear } from '../../vx-scale/src'; -import { BoxPlot, computeStats } from '../src'; - -const data = [1, 2, 3, 4, 5, 6, 6, 7, 8, 9, 1]; -const { boxPlot: boxPlotData } = computeStats(data); -const { min, firstQuartile, median, thirdQuartile, max, outliers } = boxPlotData; - -const valueScale = scaleLinear({ - rangeRound: [10, 0], - domain: [0, 10], -}); - -describe('', () => { - test('it should be defined', () => { - expect(BoxPlot).toBeDefined(); - }); - - test('it should have className .vx-boxplot', () => { - const wrapper = shallow( - , - ); - expect(wrapper.prop('className')).toEqual('vx-boxplot'); - }); - - test('it should render 5 lines and one rectangle', () => { - const wrapper = shallow( - , - ); - expect(wrapper.find('line')).toHaveLength(5); - expect(wrapper.find('rect')).toHaveLength(1); - }); -}); From 5a024cfc18b14b4ad29d82c059ad1b2d0df05d4c Mon Sep 17 00:00:00 2001 From: Chris Williams Date: Fri, 13 Dec 2019 14:05:29 -0800 Subject: [PATCH 2/6] delete(@vx/boxplot): remove references, update tiles/boxplot => statsplots --- packages/vx-demo/package.json | 1 - packages/vx-demo/src/components/gallery.js | 8 +- .../tiles/{boxplot.js => statsplots.js} | 4 +- .../vx-demo/src/static/docs/vx-boxplot.html | 84 ----------------- packages/vx-demo/src/static/docs/vx-vx.html | 92 +++++++++++++------ packages/vx-vx/package.json | 1 - 6 files changed, 71 insertions(+), 119 deletions(-) rename packages/vx-demo/src/components/tiles/{boxplot.js => statsplots.js} (98%) delete mode 100644 packages/vx-demo/src/static/docs/vx-boxplot.html diff --git a/packages/vx-demo/package.json b/packages/vx-demo/package.json index 2ac7110aab..4c785441bb 100644 --- a/packages/vx-demo/package.json +++ b/packages/vx-demo/package.json @@ -18,7 +18,6 @@ "dependencies": { "@vx/annotation": "0.0.192", "@vx/axis": "0.0.192", - "@vx/boxplot": "0.0.192", "@vx/brush": "0.0.192", "@vx/chord": "0.0.192", "@vx/clip-path": "0.0.192", diff --git a/packages/vx-demo/src/components/gallery.js b/packages/vx-demo/src/components/gallery.js index a3ac6ae1b5..9d82fe05d8 100644 --- a/packages/vx-demo/src/components/gallery.js +++ b/packages/vx-demo/src/components/gallery.js @@ -26,7 +26,7 @@ import Trees from './tiles/tree'; import Cluster from './tiles/dendrogram'; import Voronoi from './tiles/voronoi'; import Legends from './tiles/legends'; -import BoxPlot from './tiles/boxplot'; +import StatsPlots from './tiles/statsplots'; import GeoMercator from './tiles/geo-mercator'; import GeoCustom from './tiles/geo-custom'; import Network from './tiles/network'; @@ -507,11 +507,13 @@ export default function() { - +
- {({ width, height }) => } + {({ width, height }) => ( + + )}
diff --git a/packages/vx-demo/src/components/tiles/boxplot.js b/packages/vx-demo/src/components/tiles/statsplots.js similarity index 98% rename from packages/vx-demo/src/components/tiles/boxplot.js rename to packages/vx-demo/src/components/tiles/statsplots.js index 2789698a6f..89a425eb28 100644 --- a/packages/vx-demo/src/components/tiles/boxplot.js +++ b/packages/vx-demo/src/components/tiles/statsplots.js @@ -57,8 +57,8 @@ export default withTooltip( return (
- - + + - - - - -
- -
-

@vx/boxplot

-

- -

-

A boxplot shows the minimum, maximum, and quartiles of a dataset.

-

You can pass in props to target the min, max, median, and box (interquartile range) shapes using minProps, maxProps, medianProps, and boxProps.

-

If you are looking to add events over the each boxplot group you can pass in container={true} and containerProps={{ /** */ }}.

-

Installation

-
npm install --save @vx/boxplot
-

Components

- -

API

-

<BoxPlot />

- - - -

# BoxPlot.boxProps<object>
Default{}

-

# BoxPlot.boxWidth<number>

-

# BoxPlot.children<func>

-

# BoxPlot.className<string>

-

# BoxPlot.container<bool>
Defaultfalse

-

# BoxPlot.containerProps<object>
Default{}

-

# BoxPlot.fill<string>

-

# BoxPlot.fillOpacity<union(number|string)>

-

# BoxPlot.firstQuartile<number>

-

# BoxPlot.horizontal<bool>

-

# BoxPlot.left<number>
Default0

-

# BoxPlot.max<number>

-

# BoxPlot.maxProps<object>
Default{}

-

# BoxPlot.median<number>

-

# BoxPlot.medianProps<object>
Default{}

-

# BoxPlot.min<number>

-

# BoxPlot.minProps<object>
Default{}

-

# BoxPlot.outlierProps<object>
Default{}

-

# BoxPlot.outliers<array>
Default[]

-

# BoxPlot.rx<number>
Default2

-

# BoxPlot.ry<number>
Default2

-

# BoxPlot.stroke<string>

-

# BoxPlot.strokeWidth<union(number|string)>

-

# BoxPlot.thirdQuartile<number>

-

# BoxPlot.top<number>
Default0

-

# BoxPlot.valueScale<func>

- -
-
- - \ No newline at end of file diff --git a/packages/vx-demo/src/static/docs/vx-vx.html b/packages/vx-demo/src/static/docs/vx-vx.html index b7d5f251ed..ca83a1d3ac 100644 --- a/packages/vx-demo/src/static/docs/vx-vx.html +++ b/packages/vx-demo/src/static/docs/vx-vx.html @@ -1,13 +1,12 @@ - - - - - -