Skip to content

Commit 257fe2b

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

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+1701
-123
lines changed

README.md

+14-110
Large diffs are not rendered by default.

conf/base.yaml

+8
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,14 @@ capture:
6565
selector: .chart-tabs__content
6666
output: ./packages/radar/doc/radar.png
6767

68+
- path: /rose
69+
selector: .chart-tabs__content
70+
output: ./packages/rose/doc/rose.png
71+
72+
- path: /rose/canvas
73+
selector: .chart-tabs__content
74+
output: ./packages/rose/doc/rose-canvas.png
75+
6876
- path: /sankey
6977
selector: .chart-tabs__content
7078
output: ./packages/sankey/doc/sankey.png

packages/bar/doc/bar-canvas.png

458 Bytes
Loading

packages/bar/doc/bar.png

-981 Bytes
Loading

packages/bullet/doc/bullet.png

-466 Bytes
Loading

packages/calendar/doc/calendar.png

1.46 KB
Loading

packages/chord/doc/chord-canvas.png

4.77 KB
Loading

packages/chord/doc/chord.png

-626 Bytes
Loading
14 Bytes
Loading
7.78 KB
Loading
2.36 KB
Loading
-194 KB
Loading

packages/heatmap/doc/heatmap.png

-1.53 KB
Loading

packages/line/doc/line.png

-10.8 KB
Loading
Loading
Loading

packages/pie/doc/pie.png

-992 Bytes
Loading

packages/radar/doc/radar.png

-864 Bytes
Loading

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

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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](https://nivo.rocks/rose)
8+
9+
![Rose](./doc/rose.png)
10+
11+
## RoseCanvas
12+
13+
[documentation](https://nivo.rocks/rose/canvas)
14+
15+
![RoseCanvas](./doc/rose-canvas.png)

packages/rose/doc/rose-canvas.png

73.4 KB
Loading

packages/rose/doc/rose.png

39.7 KB
Loading

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

+120
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
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+
import RoseArc from './RoseArc'
15+
16+
class Rose extends Component {
17+
static propTypes = RosePropTypes
18+
19+
handleMouseEnter = showTooltip => (point, event) => {
20+
const { isInteractive, onMouseEnter } = this.props
21+
22+
if (!isInteractive) return
23+
24+
onMouseEnter && onMouseEnter(point, event)
25+
this.showTooltip(showTooltip, point, event)
26+
}
27+
28+
handleMouseMove = showTooltip => (point, event) => {
29+
const { isInteractive, onMouseMove } = this.props
30+
31+
if (!isInteractive) return
32+
33+
onMouseMove && onMouseMove(point, event)
34+
this.showTooltip(showTooltip, point, event)
35+
}
36+
37+
handleMouseLeave = hideTooltip => (point, event) => {
38+
const { isInteractive, onMouseLeave } = this.props
39+
40+
if (!isInteractive) return
41+
42+
onMouseLeave && onMouseLeave(point, event)
43+
hideTooltip()
44+
}
45+
46+
handleClick = (point, event) => {
47+
const { isInteractive, onClick } = this.props
48+
if (!isInteractive || onClick === undefined) return
49+
50+
onClick(point.data, event)
51+
}
52+
53+
render() {
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+
<RoseArc
104+
key={arc.id}
105+
arc={arc}
106+
arcGenerator={arcGenerator}
107+
borderWidth={borderWidth}
108+
/>
109+
)
110+
})}
111+
</g>
112+
</SvgWrapper>
113+
)
114+
}}
115+
</Container>
116+
)
117+
}
118+
}
119+
120+
export default setDisplayName('Rose')(enhanceSvg(Rose))

packages/rose/src/RoseArc.js

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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 PropTypes from 'prop-types'
11+
12+
const RoseArc = ({ arc, arcGenerator, borderWidth }) => {
13+
return (
14+
<path
15+
key={arc.id}
16+
d={arcGenerator(arc)}
17+
fill={arc.color}
18+
stroke={'white'}
19+
strokeWidth={borderWidth}
20+
onClick={() => {
21+
console.log(arc)
22+
}}
23+
/>
24+
)
25+
}
26+
27+
RoseArc.propTypes = {
28+
arc: PropTypes.shape({
29+
color: PropTypes.string.isRequired,
30+
}).isRequired,
31+
arcGenerator: PropTypes.func.isRequired,
32+
borderWidth: PropTypes.number.isRequired,
33+
}
34+
35+
export default RoseArc

0 commit comments

Comments
 (0)