Skip to content

Commit

Permalink
Merge branch 'master' into fix-invalid-core-types
Browse files Browse the repository at this point in the history
  • Loading branch information
wyze authored Apr 23, 2021
2 parents a376a61 + 1d94b5f commit 351d7b0
Show file tree
Hide file tree
Showing 45 changed files with 330 additions and 296 deletions.
199 changes: 118 additions & 81 deletions CHANGELOG.md

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ packages-lint: ##@1 packages run eslint on all packages
@echo "${YELLOW}Running eslint on all packages${RESET}"
@./node_modules/.bin/eslint "./packages/*/{src,tests}/**/*.{js,ts,tsx}"

packages-lint-fix: ##@1 packages run eslint on all packages with a fix option
@echo "${YELLOW}Running eslint on all packages${RESET}"
@./node_modules/.bin/eslint "./packages/*/{src,tests}/**/*.{js,ts,tsx}" --fix

package-test-cover-%: ##@1 packages run tests for a package with code coverage
@yarn jest -c ./packages/jest.config.js --rootDir . --coverage ./packages/${*}/tests

Expand Down Expand Up @@ -207,7 +211,6 @@ website: ##@2 website start website in dev mode

website-build: ##@2 website build website
@echo "${YELLOW}Building website${RESET}"
@node scripts/patch-react-spring.js
@cd website && yarn build

website-serve: ##@2 website build & serve website
Expand Down
2 changes: 1 addition & 1 deletion packages/annotations/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"dependencies": {
"@nivo/colors": "0.67.0",
"lodash": "^4.17.11",
"react-spring": "9.0.0-rc.3"
"react-spring": "9.1.2"
},
"devDependencies": {
"@nivo/core": "0.67.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/arcs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"dependencies": {
"@nivo/colors": "0.67.0",
"d3-shape": "^1.3.5",
"react-spring": "9.0.0-rc.3"
"react-spring": "9.1.2"
},
"devDependencies": {
"@nivo/core": "0.67.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ export const useArcLinkLabelsTransition = <Datum extends DatumWithArcAndColor>({
})

const transition = useTransition<Datum, AnimatedProps>(filteredData, {
key: datum => datum.id,
keys: datum => datum.id,
initial: transitionPhases.update,
from: transitionPhases.enter,
enter: transitionPhases.update,
Expand Down
2 changes: 1 addition & 1 deletion packages/arcs/src/centers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const useArcCentersTransition = <Datum extends DatumWithArc, ExtraProps =
outerRadius: number
} & ExtraProps
>(data, {
key: datum => datum.id,
keys: datum => datum.id,
initial: phases.update,
from: phases.enter,
enter: phases.update,
Expand Down
2 changes: 1 addition & 1 deletion packages/arcs/src/useArcsTransition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const useArcsTransition = <Datum extends DatumWithArc, ExtraProps = unkno
outerRadius: number
} & ExtraProps
>(data, {
key: datum => datum.id,
keys: datum => datum.id,
initial: phases.update,
from: phases.enter,
enter: phases.update,
Expand Down
2 changes: 1 addition & 1 deletion packages/axes/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"d3-format": "^1.4.4",
"d3-time": "^1.0.11",
"d3-time-format": "^2.1.3",
"react-spring": "9.0.0-rc.3"
"react-spring": "9.1.2"
},
"devDependencies": {
"@nivo/core": "0.67.0"
Expand Down
7 changes: 2 additions & 5 deletions packages/axes/src/components/Axis.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ import { computeCartesianTicks, getFormatter } from '../compute'
import { axisPropTypes } from '../props'
import AxisTick from './AxisTick'

const defaultTickRenderer = props => <AxisTick {...props} />

const Axis = ({
axis,
scale,
Expand Down Expand Up @@ -146,7 +144,6 @@ const Axis = ({
animatedProps: transitionProps,
...tick,
...(onClick ? { onClick } : {}),
key: tick.key,
})
})}
<animated.line
Expand All @@ -173,7 +170,7 @@ Axis.propTypes = {
tickPadding: PropTypes.number.isRequired,
tickRotation: PropTypes.number.isRequired,
format: PropTypes.oneOfType([PropTypes.func, PropTypes.string]),
renderTick: PropTypes.func.isRequired,
renderTick: PropTypes.elementType,
legend: PropTypes.node,
legendPosition: PropTypes.oneOf(['start', 'middle', 'end']).isRequired,
legendOffset: PropTypes.number.isRequired,
Expand All @@ -186,7 +183,7 @@ Axis.defaultProps = {
tickSize: 5,
tickPadding: 5,
tickRotation: 0,
renderTick: defaultTickRenderer,
renderTick: AxisTick,
legendPosition: 'end',
legendOffset: 0,
}
Expand Down
2 changes: 1 addition & 1 deletion packages/axes/src/compute.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ export const computeCartesianTicks = ({
}

const ticks = values.map(value => ({
key: value,
key: typeof value === 'number' || typeof value === 'string' ? value : `${value}`,
value,
...translate(value),
...line,
Expand Down
8 changes: 4 additions & 4 deletions packages/bar/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ declare module '@nivo/bar' {

export type ValueFormatter = (value: number) => string | number

type GraphicsContainer = HTMLCanvasElement | SVGRectElement
type GraphicsContainer = HTMLCanvasElement | SVGElement

export type BarMouseEventHandler<T = GraphicsContainer> = (
datum: BarExtendedDatum,
Expand Down Expand Up @@ -146,9 +146,9 @@ declare module '@nivo/bar' {
SvgDefsAndFill<BarDatum> &
Partial<{
layers: Layer[]
onClick: BarMouseEventHandler<SVGRectElement>
onMouseEnter: BarMouseEventHandler<SVGRectElement>
onMouseLeave: BarMouseEventHandler<SVGRectElement>
onClick: BarMouseEventHandler<SVGElement>
onMouseEnter: BarMouseEventHandler<SVGElement>
onMouseLeave: BarMouseEventHandler<SVGElement>
role: string
}>

Expand Down
12 changes: 10 additions & 2 deletions packages/bar/src/compute/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,17 @@ export const getIndexScale = (data, getIndex, range, padding, indexScale) => {

export const normalizeData = (data, keys) =>
data.map(item => ({
...keys.reduce((acc, key) => ({ ...acc, [key]: null }), {}),
...keys.reduce((acc, key) => {
acc[key] = null
return acc
}, {}),
...item,
}))

export const filterNullValues = data =>
Object.keys(data).reduce((acc, key) => (data[key] ? { ...acc, [key]: data[key] } : acc), {})
Object.keys(data).reduce((acc, key) => {
if (data[key]) {
acc[key] = data[key]
}
return acc
}, {})
6 changes: 4 additions & 2 deletions packages/bar/src/compute/grouped.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const generateVerticalGroupedBars = (
const compare = reverse ? lt : gt
const getY = d => (compare(d, 0) ? yScale(d) : yRef)
const getHeight = (d, y) => (compare(d, 0) ? yRef - y : yScale(d) - yRef)
const cleanedData = data.map(filterNullValues)

const bars = flatten(
keys.map((key, i) =>
Expand All @@ -54,7 +55,7 @@ const generateVerticalGroupedBars = (
value: data[index][key],
index,
indexValue: getIndex(data[index]),
data: filterNullValues(data[index]),
data: cleanedData[index],
}

return {
Expand Down Expand Up @@ -98,6 +99,7 @@ const generateHorizontalGroupedBars = (
const compare = reverse ? lt : gt
const getX = d => (compare(d, 0) ? xRef : xScale(d))
const getWidth = (d, x) => (compare(d, 0) ? xScale(d) - xRef : xRef - x)
const cleanedData = data.map(filterNullValues)

const bars = flatten(
keys.map((key, i) =>
Expand All @@ -110,7 +112,7 @@ const generateHorizontalGroupedBars = (
value: data[index][key],
index,
indexValue: getIndex(data[index]),
data: filterNullValues(data[index]),
data: cleanedData[index],
}

return {
Expand Down
2 changes: 1 addition & 1 deletion packages/bullet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"@nivo/legends": "0.67.0",
"@nivo/tooltip": "0.67.0",
"d3-scale": "^3.0.0",
"react-spring": "9.0.0-rc.3"
"react-spring": "9.1.2"
},
"devDependencies": {
"@nivo/core": "0.67.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/bullet/src/BulletMarkers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export const BulletMarkers = ({
const transition = useTransition<MarkerWithPosition, PositionWithColor>(
markers.map(marker => ({ ...marker, position: getPosition(marker) })),
{
key: marker => `${marker.index}`,
keys: marker => `${marker.index}`,
enter: ({ color, position }: MarkerWithPosition) => ({
color,
transform: `rotate(${position.rotation}, ${position.x}, ${position.y})`,
Expand Down
2 changes: 1 addition & 1 deletion packages/bullet/src/BulletRects.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const BulletRects = ({

const { animate, config: springConfig } = useMotionConfig()
const transition = useTransition<BulletRectComputedRect, BulletRectAnimatedProps>(rects, {
key: rect => `${rect.data.index}`,
keys: rect => `${rect.data.index}`,
enter: rect => ({
x: rect.x,
y: rect.y,
Expand Down
2 changes: 1 addition & 1 deletion packages/bump/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"@nivo/legends": "0.67.0",
"@nivo/tooltip": "0.67.0",
"d3-shape": "^1.3.5",
"react-spring": "9.0.0-rc.3"
"react-spring": "9.1.2"
},
"devDependencies": {
"@nivo/core": "0.67.0"
Expand Down
5 changes: 4 additions & 1 deletion packages/core/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ declare module '@nivo/core' {
chip: Partial<React.CSSProperties>
table: Partial<React.CSSProperties>
tableCell: Partial<React.CSSProperties>
tableCellValue: Partial<React.CSSProperties>
}
annotations: {
text: Partial<React.CSSProperties>
Expand Down Expand Up @@ -165,8 +166,10 @@ declare module '@nivo/core' {

export interface CartesianMarkerProps {
axis: 'x' | 'y'
value: string | number | Date
value: DatumValue
legend?: string
legendOrientation?: 'horizontal' | 'vertical'
legendPosition?: BoxAlign
lineStyle?: Partial<React.CSSProperties>
textStyle?: Partial<React.CSSProperties>
}
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"d3-shape": "^1.3.5",
"d3-time-format": "^2.1.3",
"lodash": "^4.17.11",
"react-spring": "9.0.0-rc.3",
"react-spring": "9.1.2",
"recompose": "^0.30.0",
"resize-observer-polyfill": "^1.5.1"
},
Expand Down
3 changes: 3 additions & 0 deletions packages/core/src/theming/defaultTheme.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ export const defaultTheme = {
tableCell: {
padding: '3px 5px',
},
tableCellValue: {
fontWeight: 'bold',
},
},
crosshair: {
line: {
Expand Down
8 changes: 4 additions & 4 deletions packages/funnel/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,18 @@
"dist/"
],
"dependencies": {
"@nivo/annotations": "0.67.0",
"@nivo/colors": "0.67.0",
"@nivo/tooltip": "0.67.0",
"d3-scale": "^3.0.0",
"d3-shape": "^1.3.5",
"react-spring": "9.0.0-rc.3"
"react-spring": "9.1.2"
},
"devDependencies": {
"@nivo/core": "0.67.0"
},
"peerDependencies": {
"@nivo/annotations": "0.63.1",
"@nivo/colors": "0.63.0",
"@nivo/core": "0.67.0",
"@nivo/tooltip": "0.63.0",
"prop-types": ">= 15.5.10 < 16.0.0",
"react": ">= 16.8.4 < 18.0.0"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/heatmap/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"@nivo/colors": "0.67.0",
"@nivo/tooltip": "0.67.0",
"d3-scale": "^3.0.0",
"react-spring": "9.0.0-rc.3"
"react-spring": "9.1.2"
},
"devDependencies": {
"@nivo/core": "0.67.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/line/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"@nivo/tooltip": "0.67.0",
"@nivo/voronoi": "0.67.0",
"d3-shape": "^1.3.5",
"react-spring": "9.0.0-rc.3"
"react-spring": "9.1.2"
},
"devDependencies": {
"@nivo/core": "0.67.0"
Expand Down
18 changes: 7 additions & 11 deletions packages/line/src/SliceTooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,21 @@
*/
import React, { memo } from 'react'
import PropTypes from 'prop-types'
import { TableTooltip } from '@nivo/tooltip'

const Chip = ({ color }) => (
<span style={{ display: 'block', width: '12px', height: '12px', background: color }} />
)

Chip.propTypes = {
color: PropTypes.string.isRequired,
}
import { useTheme } from '@nivo/core'
import { Chip, TableTooltip } from '@nivo/tooltip'

const SliceTooltip = ({ slice, axis }) => {
const theme = useTheme()
const otherAxis = axis === 'x' ? 'y' : 'x'

return (
<TableTooltip
rows={slice.points.map(point => [
<Chip key="chip" color={point.serieColor} />,
<Chip key="chip" color={point.serieColor} style={theme.tooltip.chip} />,
point.serieId,
<strong key="value">{point.data[`${otherAxis}Formatted`]}</strong>,
<span key="value" style={theme.tooltip.tableCellValue}>
{point.data[`${otherAxis}Formatted`]}
</span>,
])}
/>
)
Expand Down
2 changes: 1 addition & 1 deletion packages/marimekko/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"d3-scale": "^3.0.0",
"d3-shape": "^1.3.5",
"lodash": "^4.17.11",
"react-spring": "9.0.0-rc.3"
"react-spring": "9.1.2"
},
"devDependencies": {
"@nivo/core": "0.67.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/marimekko/src/Bars.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const Bars = <RawDatum,>({
borderColor: string
}
>(bars, {
key: bar => bar.key,
keys: bar => bar.key,
initial: bar => ({
x: bar.x,
y: bar.y,
Expand Down
2 changes: 1 addition & 1 deletion packages/parallel-coordinates/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"@nivo/tooltip": "0.67.0",
"d3-scale": "^3.0.0",
"d3-shape": "^1.3.5",
"react-spring": "9.0.0-rc.3"
"react-spring": "9.1.2"
},
"devDependencies": {
"@nivo/core": "0.67.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/pie/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"@nivo/tooltip": "0.67.0",
"d3-shape": "^1.3.5",
"lodash": "^4.17.11",
"react-spring": "9.0.0-rc.3"
"react-spring": "9.1.2"
},
"devDependencies": {
"@nivo/core": "0.67.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/radar/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"@nivo/tooltip": "0.67.0",
"d3-scale": "^3.0.0",
"d3-shape": "^1.3.5",
"react-spring": "9.0.0-rc.3"
"react-spring": "9.1.2"
},
"devDependencies": {
"@nivo/core": "0.67.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/sankey/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"d3-sankey": "^0.12.1",
"d3-shape": "^1.3.5",
"lodash": "^4.17.11",
"react-spring": "9.0.0-rc.3"
"react-spring": "9.1.2"
},
"devDependencies": {
"@nivo/core": "0.67.0"
Expand Down
Loading

0 comments on commit 351d7b0

Please sign in to comment.