Skip to content

Commit

Permalink
feat(scatterplot): rename symbolSize to nodeSize
Browse files Browse the repository at this point in the history
  • Loading branch information
Raphaël Benitte authored and Raphaël Benitte committed Jun 8, 2019
1 parent 4b667da commit 501ee0f
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 38 deletions.
3 changes: 1 addition & 2 deletions packages/scatterplot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@
"d3-scale": "^3.0.0",
"d3-shape": "^1.3.5",
"lodash": "^4.17.11",
"react-motion": "^0.5.2",
"recompose": "^0.30.0"
"react-motion": "^0.5.2"
},
"peerDependencies": {
"prop-types": ">= 15.5.10 < 16.0.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/scatterplot/src/ScatterPlot.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const ScatterPlot = props => {
colors,
blendMode,

size,
nodeSize,
renderNode,

enableGridX,
Expand Down Expand Up @@ -65,7 +65,7 @@ const ScatterPlot = props => {
yScaleSpec,
width: innerWidth,
height: innerHeight,
size,
nodeSize,
colors,
})

Expand Down
40 changes: 18 additions & 22 deletions packages/scatterplot/src/StaticNodes.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,28 +23,24 @@ const StaticNodes = ({
tooltip,
blendMode,
}) => {
return (
<>
{nodes.map(node => (
<NodeWrapper
key={node.id}
node={node}
renderNode={renderNode}
x={node.x}
y={node.y}
size={node.size}
color={node.style.color}
isInteractive={isInteractive}
onMouseEnter={onMouseEnter}
onMouseMove={onMouseMove}
onMouseLeave={onMouseLeave}
onClick={onClick}
tooltip={tooltip}
blendMode={blendMode}
/>
))}
</>
)
return nodes.map(node => (
<NodeWrapper
key={node.id}
node={node}
renderNode={renderNode}
x={node.x}
y={node.y}
size={node.size}
color={node.style.color}
isInteractive={isInteractive}
onMouseEnter={onMouseEnter}
onMouseMove={onMouseMove}
onMouseLeave={onMouseLeave}
onClick={onClick}
tooltip={tooltip}
blendMode={blendMode}
/>
))
}

StaticNodes.propTypes = {
Expand Down
2 changes: 1 addition & 1 deletion packages/scatterplot/src/compute.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import isNumber from 'lodash/isNumber'
import isPlainObject from 'lodash/isPlainObject'
import { scaleLinear } from 'd3-scale'

export const getSizeGenerator = size => {
export const getNodeSizeGenerator = size => {
if (typeof size === 'function') return size
if (isNumber(size)) return () => size
if (isPlainObject(size)) {
Expand Down
12 changes: 6 additions & 6 deletions packages/scatterplot/src/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ import { useMemo } from 'react'
import { useTheme } from '@nivo/core'
import { useOrdinalColorScale } from '@nivo/colors'
import { computeXYScalesForSeries } from '@nivo/scales'
import { computePoints, getSizeGenerator } from './compute'
import { computePoints, getNodeSizeGenerator } from './compute'

const useSize = size => useMemo(() => getSizeGenerator(size), [size])
const useNodeSize = size => useMemo(() => getNodeSizeGenerator(size), [size])

export const useScatterPlot = ({
data,
xScaleSpec,
yScaleSpec,
width,
height,
size,
nodeSize,
colors,
}) => {
const {
Expand All @@ -37,7 +37,7 @@ export const useScatterPlot = ({
[series]
)

const getSize = useSize(size)
const getNodeSize = useNodeSize(nodeSize)

const theme = useTheme()
const getColor = useOrdinalColorScale(colors, 'serie.id')
Expand All @@ -46,13 +46,13 @@ export const useScatterPlot = ({
() => rawNodes.map(rawNode => {
return {
...rawNode,
size: getSize(rawNode.data),
size: getNodeSize(rawNode.data),
style: {
color: getColor(rawNode.data)
}
}
}),
[rawNodes, getSize, getColor]
[rawNodes, getNodeSize, getColor]
)

return {
Expand Down
4 changes: 2 additions & 2 deletions packages/scatterplot/src/props.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const commonPropTypes = {
axisBottom: axisPropType,
axisLeft: axisPropType,

size: PropTypes.oneOfType([
nodeSize: PropTypes.oneOfType([
PropTypes.number,
PropTypes.shape({
key: PropTypes.string.isRequired,
Expand Down Expand Up @@ -122,7 +122,7 @@ const commonDefaultProps = {
axisBottom: {},
axisLeft: {},

size: 9,
nodeSize: 9,
renderNode: Node,

colors: { scheme: 'nivo' },
Expand Down
4 changes: 2 additions & 2 deletions website/src/data/components/scatterplot/props.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,9 @@ const props = [
},
},
{
key: 'size',
key: 'nodeSize',
group: 'Base',
defaultValue: defaults.size,
defaultValue: defaults.nodeSize,
type: 'number | object | Function',
help: `How to compute node size, static or dynamic.`,
description: `
Expand Down
2 changes: 1 addition & 1 deletion website/src/pages/scatterplot/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const initialProperties = {
colors: ScatterPlotDefaultProps.colors,
blendMode: 'multiply',

size: ScatterPlotDefaultProps.size,
nodeSize: ScatterPlotDefaultProps.nodeSize,

enableGridX: ScatterPlotDefaultProps.enableGridX,
enableGridY: ScatterPlotDefaultProps.enableGridY,
Expand Down

0 comments on commit 501ee0f

Please sign in to comment.