Skip to content

Commit

Permalink
feat(chord): use arc hover detection from @nivo/arcs
Browse files Browse the repository at this point in the history
  • Loading branch information
plouc committed Dec 18, 2020
1 parent 30be492 commit 3eece0a
Show file tree
Hide file tree
Showing 17 changed files with 3 additions and 123 deletions.
1 change: 1 addition & 0 deletions packages/chord/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"dist/"
],
"dependencies": {
"@nivo/arcs": "0.66.0",
"@nivo/colors": "0.67.0",
"@nivo/legends": "0.67.0",
"@nivo/tooltip": "0.67.0",
Expand Down
8 changes: 0 additions & 8 deletions packages/chord/src/Chord.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
/*
* This file is part of the nivo project.
*
* Copyright 2016-present, Raphaël Benitte.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import React, { Fragment } from 'react'
import { withContainer, SvgWrapper, useDimensions, useTheme } from '@nivo/core'
import { useInheritedColor } from '@nivo/colors'
Expand Down
8 changes: 0 additions & 8 deletions packages/chord/src/ChordArc.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
/*
* This file is part of the nivo project.
*
* Copyright 2016-present, Raphaël Benitte.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import React, { memo, useMemo } from 'react'
import PropTypes from 'prop-types'
import { useTooltip } from '@nivo/tooltip'
Expand Down
8 changes: 0 additions & 8 deletions packages/chord/src/ChordArcTooltip.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
/*
* This file is part of the nivo project.
*
* Copyright 2016-present, Raphaël Benitte.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import React, { memo } from 'react'
import PropTypes from 'prop-types'
import { BasicTooltip } from '@nivo/tooltip'
Expand Down
8 changes: 0 additions & 8 deletions packages/chord/src/ChordArcs.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
/*
* This file is part of the nivo project.
*
* Copyright 2016-present, Raphaël Benitte.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import React, { memo } from 'react'
import PropTypes from 'prop-types'
import { TransitionMotion, spring } from 'react-motion'
Expand Down
12 changes: 2 additions & 10 deletions packages/chord/src/ChordCanvas.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
/*
* This file is part of the nivo project.
*
* Copyright 2016-present, Raphaël Benitte.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import React, { memo, useRef, useEffect, useCallback } from 'react'
import {
withContainer,
Expand All @@ -15,8 +7,8 @@ import {
getPolarLabelProps,
degreesToRadians,
getRelativeCursor,
getHoveredArc,
} from '@nivo/core'
import { findArcUnderCursor } from '@nivo/arcs'
import { useInheritedColor } from '@nivo/colors'
import { renderLegendToCanvas } from '@nivo/legends'
import { useTooltip } from '@nivo/tooltip'
Expand All @@ -28,7 +20,7 @@ const getArcFromMouseEvent = ({ event, canvasEl, center, margin, radius, innerRa
const centerX = margin.left + center[0]
const centerY = margin.top + center[1]

return getHoveredArc(centerX, centerY, radius, innerRadius, arcs, x, y)
return findArcUnderCursor(centerX, centerY, radius, innerRadius, arcs, x, y)
}

const ChordCanvas = memo(
Expand Down
8 changes: 0 additions & 8 deletions packages/chord/src/ChordLabels.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
/*
* This file is part of the nivo project.
*
* Copyright 2016-present, Raphaël Benitte.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import React from 'react'
import PropTypes from 'prop-types'
import { TransitionMotion, spring } from 'react-motion'
Expand Down
8 changes: 0 additions & 8 deletions packages/chord/src/ChordRibbon.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
/*
* This file is part of the nivo project.
*
* Copyright 2016-present, Raphaël Benitte.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import React, { memo, useMemo } from 'react'
import PropTypes from 'prop-types'
import { blendModePropType } from '@nivo/core'
Expand Down
8 changes: 0 additions & 8 deletions packages/chord/src/ChordRibbonTooltip.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
/*
* This file is part of the nivo project.
*
* Copyright 2016-present, Raphaël Benitte.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import React, { memo } from 'react'
import PropTypes from 'prop-types'
import { useTheme } from '@nivo/core'
Expand Down
8 changes: 0 additions & 8 deletions packages/chord/src/ChordRibbons.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
/*
* This file is part of the nivo project.
*
* Copyright 2016-present, Raphaël Benitte.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import React, { memo } from 'react'
import PropTypes from 'prop-types'
import mapValues from 'lodash/mapValues'
Expand Down
8 changes: 0 additions & 8 deletions packages/chord/src/ResponsiveChord.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
/*
* This file is part of the nivo project.
*
* Copyright 2016-present, Raphaël Benitte.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import React from 'react'
import { ResponsiveWrapper } from '@nivo/core'
import Chord from './Chord'
Expand Down
8 changes: 0 additions & 8 deletions packages/chord/src/ResponsiveChordCanvas.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
/*
* This file is part of the nivo project.
*
* Copyright 2016-present, Raphaël Benitte.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import React from 'react'
import { ResponsiveWrapper } from '@nivo/core'
import ChordCanvas from './ChordCanvas'
Expand Down
8 changes: 0 additions & 8 deletions packages/chord/src/compute.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
/*
* This file is part of the nivo project.
*
* Copyright 2016-present, Raphaël Benitte.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import { arc as d3Arc } from 'd3-shape'
import { chord as d3Chord, ribbon as d3Ribbon } from 'd3-chord'

Expand Down
8 changes: 0 additions & 8 deletions packages/chord/src/hooks.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
/*
* This file is part of the nivo project.
*
* Copyright 2016-present, Raphaël Benitte.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import { useMemo, useState } from 'react'
import { useValueFormatter, getLabelGenerator } from '@nivo/core'
import { useOrdinalColorScale } from '@nivo/colors'
Expand Down
8 changes: 0 additions & 8 deletions packages/chord/src/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
/*
* This file is part of the nivo project.
*
* Copyright 2016-present, Raphaël Benitte.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
export { default as Chord } from './Chord'
export { default as ChordCanvas } from './ChordCanvas'
export { default as ResponsiveChord } from './ResponsiveChord'
Expand Down
8 changes: 0 additions & 8 deletions packages/chord/src/props.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
/*
* This file is part of the nivo project.
*
* Copyright 2016-present, Raphaël Benitte.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import PropTypes from 'prop-types'
import { blendModePropType, motionPropTypes } from '@nivo/core'
import { ordinalColorsPropType, inheritedColorPropType } from '@nivo/colors'
Expand Down
1 change: 0 additions & 1 deletion packages/pie/src/PieCanvas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
// @ts-ignore
import { renderLegendToCanvas } from '@nivo/legends'
import { useInheritedColor, InheritedColorConfig } from '@nivo/colors'
// @ts-ignore
import { useTooltip } from '@nivo/tooltip'
import { Arc, findArcUnderCursor } from '@nivo/arcs'
import { useNormalizedData, usePieFromBox, usePieRadialLabels } from './hooks'
Expand Down

0 comments on commit 3eece0a

Please sign in to comment.