Skip to content

Commit 790c928

Browse files
author
Raphaël Benitte
committed
feat(rose): init package
1 parent 5024596 commit 790c928

23 files changed

+1646
-11
lines changed

packages/rose/LICENSE.md

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) Raphaël Benitte
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy of
4+
this software and associated documentation files (the "Software"), to deal in
5+
the Software without restriction, including without limitation the rights to
6+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
7+
of the Software, and to permit persons to whom the Software is furnished to do
8+
so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all
11+
copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19+
SOFTWARE.

packages/rose/README.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# `@nivo/rose`
2+
3+
[![version](https://img.shields.io/npm/v/@nivo/rose.svg?style=flat-square)](https://www.npmjs.com/package/@nivo/rose)
4+
5+
## Rose
6+
7+
[documentation](http://nivo.rocks/rose)
8+
9+
![Rose](./doc/rose.png)

packages/rose/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require('./cjs/nivo-rose')

packages/rose/package.json

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{
2+
"name": "@nivo/rose",
3+
"version": "0.51.6",
4+
"license": "MIT",
5+
"author": {
6+
"name": "Raphaël Benitte",
7+
"url": "https://github.com/plouc"
8+
},
9+
"keywords": [
10+
"nivo",
11+
"dataviz",
12+
"react",
13+
"d3",
14+
"charts",
15+
"polar",
16+
"nightingale",
17+
"rose"
18+
],
19+
"main": "./index.js",
20+
"files": [
21+
"README.md",
22+
"LICENSE.md",
23+
"index.js",
24+
"index.d.ts",
25+
"cjs/",
26+
"umd/"
27+
],
28+
"dependencies": {
29+
"@nivo/axes": "0.51.0",
30+
"@nivo/core": "0.51.0",
31+
"@nivo/legends": "0.51.0",
32+
"@nivo/scales": "0.51.0",
33+
"@nivo/voronoi": "0.51.0",
34+
"d3-scale": "^2.1.2",
35+
"d3-shape": "^1.2.2",
36+
"lodash": "^4.17.4",
37+
"react-motion": "^0.5.2",
38+
"recompose": "^0.26.0"
39+
},
40+
"peerDependencies": {
41+
"prop-types": "^15.5.10",
42+
"react": ">= 16.2.0 < 17.0.0"
43+
},
44+
"publishConfig": {
45+
"access": "public"
46+
}
47+
}

packages/rose/src/ResponsiveRose.js

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
* This file is part of the nivo project.
3+
*
4+
* Copyright 2016-present, Raphaël Benitte.
5+
*
6+
* For the full copyright and license information, please view the LICENSE
7+
* file that was distributed with this source code.
8+
*/
9+
import React from 'react'
10+
import { ResponsiveWrapper } from '@nivo/core'
11+
import Rose from './Rose'
12+
13+
const ResponsiveRose = props => (
14+
<ResponsiveWrapper>
15+
{({ width, height }) => <Rose width={width} height={height} {...props} />}
16+
</ResponsiveWrapper>
17+
)
18+
19+
export default ResponsiveRose
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
* This file is part of the nivo project.
3+
*
4+
* Copyright 2016-present, Raphaël Benitte.
5+
*
6+
* For the full copyright and license information, please view the LICENSE
7+
* file that was distributed with this source code.
8+
*/
9+
import React from 'react'
10+
import { ResponsiveWrapper } from '@nivo/core'
11+
import RoseCanvas from './RoseCanvas'
12+
13+
const ResponsiveRoseCanvas = props => (
14+
<ResponsiveWrapper>
15+
{({ width, height }) => <RoseCanvas width={width} height={height} {...props} />}
16+
</ResponsiveWrapper>
17+
)
18+
19+
export default ResponsiveRoseCanvas

packages/rose/src/Rose.js

+124
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
/*
2+
* This file is part of the nivo project.
3+
*
4+
* Copyright 2016-present, Raphaël Benitte.
5+
*
6+
* For the full copyright and license information, please view the LICENSE
7+
* file that was distributed with this source code.
8+
*/
9+
import React, { Component } from 'react'
10+
import setDisplayName from 'recompose/setDisplayName'
11+
import { Container, SvgWrapper } from '@nivo/core'
12+
import { enhanceSvg } from './enhance'
13+
import { RosePropTypes } from './props'
14+
15+
class Rose extends Component {
16+
static propTypes = RosePropTypes
17+
18+
handleMouseEnter = showTooltip => (point, event) => {
19+
const { isInteractive, onMouseEnter } = this.props
20+
21+
if (!isInteractive) return
22+
23+
onMouseEnter && onMouseEnter(point, event)
24+
this.showTooltip(showTooltip, point, event)
25+
}
26+
27+
handleMouseMove = showTooltip => (point, event) => {
28+
const { isInteractive, onMouseMove } = this.props
29+
30+
if (!isInteractive) return
31+
32+
onMouseMove && onMouseMove(point, event)
33+
this.showTooltip(showTooltip, point, event)
34+
}
35+
36+
handleMouseLeave = hideTooltip => (point, event) => {
37+
const { isInteractive, onMouseLeave } = this.props
38+
39+
if (!isInteractive) return
40+
41+
onMouseLeave && onMouseLeave(point, event)
42+
hideTooltip()
43+
}
44+
45+
handleClick = (point, event) => {
46+
const { isInteractive, onClick } = this.props
47+
if (!isInteractive || onClick === undefined) return
48+
49+
onClick(point.data, event)
50+
}
51+
52+
render() {
53+
console.log(this.props)
54+
const {
55+
arcs,
56+
arcGenerator,
57+
centerX,
58+
centerY,
59+
60+
borderWidth,
61+
62+
margin,
63+
outerWidth,
64+
outerHeight,
65+
66+
theme,
67+
getColor,
68+
69+
animate,
70+
motionStiffness,
71+
motionDamping,
72+
73+
isInteractive,
74+
} = this.props
75+
76+
const motionProps = {
77+
animate,
78+
motionDamping,
79+
motionStiffness,
80+
}
81+
const springConfig = {
82+
damping: motionDamping,
83+
stiffness: motionStiffness,
84+
}
85+
86+
return (
87+
<Container isInteractive={isInteractive} theme={theme}>
88+
{({ showTooltip, hideTooltip }) => {
89+
const onMouseEnter = this.handleMouseEnter(showTooltip)
90+
const onMouseMove = this.handleMouseMove(showTooltip)
91+
const onMouseLeave = this.handleMouseLeave(hideTooltip)
92+
93+
return (
94+
<SvgWrapper
95+
width={outerWidth}
96+
height={outerHeight}
97+
margin={margin}
98+
theme={theme}
99+
>
100+
<g transform={`translate(${centerX}, ${centerY})`}>
101+
{arcs.map(arc => {
102+
return (
103+
<path
104+
key={arc.id}
105+
d={arcGenerator(arc)}
106+
fill={getColor(arc)}
107+
stroke={"white"}
108+
strokeWidth={borderWidth}
109+
onClick={() => {
110+
console.log(arc)
111+
}}
112+
/>
113+
)
114+
})}
115+
</g>
116+
</SvgWrapper>
117+
)
118+
}}
119+
</Container>
120+
)
121+
}
122+
}
123+
124+
export default setDisplayName('Rose')(enhanceSvg(Rose))

packages/rose/src/RoseCanvas.js

+122
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
/*
2+
* This file is part of the nivo project.
3+
*
4+
* Copyright 2016-present, Raphaël Benitte.
5+
*
6+
* For the full copyright and license information, please view the LICENSE
7+
* file that was distributed with this source code.
8+
*/
9+
import React, { Component } from 'react'
10+
import setDisplayName from 'recompose/setDisplayName'
11+
import { Container, SvgWrapper } from '@nivo/core'
12+
import { enhanceSvg } from './enhance'
13+
import { RosePropTypes } from './props'
14+
15+
class RoseCanvas extends Component {
16+
static propTypes = RosePropTypes
17+
18+
handleMouseEnter = showTooltip => (point, event) => {
19+
const { isInteractive, onMouseEnter } = this.props
20+
21+
if (!isInteractive) return
22+
23+
onMouseEnter && onMouseEnter(point, event)
24+
this.showTooltip(showTooltip, point, event)
25+
}
26+
27+
handleMouseMove = showTooltip => (point, event) => {
28+
const { isInteractive, onMouseMove } = this.props
29+
30+
if (!isInteractive) return
31+
32+
onMouseMove && onMouseMove(point, event)
33+
this.showTooltip(showTooltip, point, event)
34+
}
35+
36+
handleMouseLeave = hideTooltip => (point, event) => {
37+
const { isInteractive, onMouseLeave } = this.props
38+
39+
if (!isInteractive) return
40+
41+
onMouseLeave && onMouseLeave(point, event)
42+
hideTooltip()
43+
}
44+
45+
handleClick = (point, event) => {
46+
const { isInteractive, onClick } = this.props
47+
if (!isInteractive || onClick === undefined) return
48+
49+
onClick(point.data, event)
50+
}
51+
52+
render() {
53+
console.log(this.props)
54+
const {
55+
arcs,
56+
arcGenerator,
57+
centerX,
58+
centerY,
59+
60+
margin,
61+
width,
62+
height,
63+
outerWidth,
64+
outerHeight,
65+
66+
theme,
67+
getColor,
68+
69+
animate,
70+
motionStiffness,
71+
motionDamping,
72+
73+
isInteractive,
74+
} = this.props
75+
76+
const motionProps = {
77+
animate,
78+
motionDamping,
79+
motionStiffness,
80+
}
81+
const springConfig = {
82+
damping: motionDamping,
83+
stiffness: motionStiffness,
84+
}
85+
86+
return (
87+
<Container isInteractive={isInteractive} theme={theme}>
88+
{({ showTooltip, hideTooltip }) => {
89+
const onMouseEnter = this.handleMouseEnter(showTooltip)
90+
const onMouseMove = this.handleMouseMove(showTooltip)
91+
const onMouseLeave = this.handleMouseLeave(hideTooltip)
92+
93+
return (
94+
<SvgWrapper
95+
width={outerWidth}
96+
height={outerHeight}
97+
margin={margin}
98+
theme={theme}
99+
>
100+
<g transform={`translate(${centerX}, ${centerY})`}>
101+
{arcs.map(arc => {
102+
return (
103+
<path
104+
key={arc.id}
105+
d={arcGenerator(arc)}
106+
fill={getColor(arc)}
107+
onClick={() => {
108+
console.log(arc)
109+
}}
110+
/>
111+
)
112+
})}
113+
</g>
114+
</SvgWrapper>
115+
)
116+
}}
117+
</Container>
118+
)
119+
}
120+
}
121+
122+
export default setDisplayName('RoseCanvas')(enhanceSvg(RoseCanvas))

packages/rose/src/compute.js

Whitespace-only changes.

0 commit comments

Comments
 (0)