Skip to content

Commit

Permalink
feat(rose): init package
Browse files Browse the repository at this point in the history
  • Loading branch information
Raphaël Benitte committed Dec 1, 2018
1 parent 5024596 commit 54b1b52
Show file tree
Hide file tree
Showing 55 changed files with 1,674 additions and 121 deletions.
124 changes: 14 additions & 110 deletions README.md

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions conf/base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,14 @@ capture:
selector: .chart-tabs__content
output: ./packages/radar/doc/radar.png

- path: /rose
selector: .chart-tabs__content
output: ./packages/rose/doc/rose.png

- path: /rose/canvas
selector: .chart-tabs__content
output: ./packages/rose/doc/rose-canvas.png

- path: /sankey
selector: .chart-tabs__content
output: ./packages/sankey/doc/sankey.png
Expand Down
Binary file modified packages/bar/doc/bar-canvas.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified packages/bar/doc/bar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified packages/bullet/doc/bullet.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified packages/calendar/doc/calendar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified packages/chord/doc/chord-canvas.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified packages/chord/doc/chord.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified packages/circle-packing/doc/bubble-canvas.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified packages/circle-packing/doc/bubble-html.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified packages/circle-packing/doc/bubble.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified packages/heatmap/doc/heatmap-canvas.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified packages/heatmap/doc/heatmap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified packages/line/doc/line.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified packages/parallel-coordinates/doc/parallel-coordinates.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified packages/pie/doc/pie.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified packages/radar/doc/radar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions packages/rose/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright (c) Raphaël Benitte

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
15 changes: 15 additions & 0 deletions packages/rose/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# `@nivo/rose`

[![version](https://img.shields.io/npm/v/@nivo/rose.svg?style=flat-square)](https://www.npmjs.com/package/@nivo/rose)

## Rose

[documentation](https://nivo.rocks/rose)

![Rose](./doc/rose.png)

## RoseCanvas

[documentation](https://nivo.rocks/rose/canvas)

![RoseCanvas](./doc/rose-canvas.png)
Binary file added packages/rose/doc/rose-canvas.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/rose/doc/rose.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions packages/rose/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('./cjs/nivo-rose')
47 changes: 47 additions & 0 deletions packages/rose/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"name": "@nivo/rose",
"version": "0.51.6",
"license": "MIT",
"author": {
"name": "Raphaël Benitte",
"url": "https://github.com/plouc"
},
"keywords": [
"nivo",
"dataviz",
"react",
"d3",
"charts",
"polar",
"nightingale",
"rose"
],
"main": "./index.js",
"files": [
"README.md",
"LICENSE.md",
"index.js",
"index.d.ts",
"cjs/",
"umd/"
],
"dependencies": {
"@nivo/axes": "0.51.0",
"@nivo/core": "0.51.0",
"@nivo/legends": "0.51.0",
"@nivo/scales": "0.51.0",
"@nivo/voronoi": "0.51.0",
"d3-scale": "^2.1.2",
"d3-shape": "^1.2.2",
"lodash": "^4.17.4",
"react-motion": "^0.5.2",
"recompose": "^0.26.0"
},
"peerDependencies": {
"prop-types": "^15.5.10",
"react": ">= 16.2.0 < 17.0.0"
},
"publishConfig": {
"access": "public"
}
}
19 changes: 19 additions & 0 deletions packages/rose/src/ResponsiveRose.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* 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 Rose from './Rose'

const ResponsiveRose = props => (
<ResponsiveWrapper>
{({ width, height }) => <Rose width={width} height={height} {...props} />}
</ResponsiveWrapper>
)

export default ResponsiveRose
19 changes: 19 additions & 0 deletions packages/rose/src/ResponsiveRoseCanvas.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* 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 RoseCanvas from './RoseCanvas'

const ResponsiveRoseCanvas = props => (
<ResponsiveWrapper>
{({ width, height }) => <RoseCanvas width={width} height={height} {...props} />}
</ResponsiveWrapper>
)

export default ResponsiveRoseCanvas
124 changes: 124 additions & 0 deletions packages/rose/src/Rose.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
/*
* 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, { Component } from 'react'
import setDisplayName from 'recompose/setDisplayName'
import { Container, SvgWrapper } from '@nivo/core'
import { enhanceSvg } from './enhance'
import { RosePropTypes } from './props'

class Rose extends Component {
static propTypes = RosePropTypes

handleMouseEnter = showTooltip => (point, event) => {
const { isInteractive, onMouseEnter } = this.props

if (!isInteractive) return

onMouseEnter && onMouseEnter(point, event)
this.showTooltip(showTooltip, point, event)
}

handleMouseMove = showTooltip => (point, event) => {
const { isInteractive, onMouseMove } = this.props

if (!isInteractive) return

onMouseMove && onMouseMove(point, event)
this.showTooltip(showTooltip, point, event)
}

handleMouseLeave = hideTooltip => (point, event) => {
const { isInteractive, onMouseLeave } = this.props

if (!isInteractive) return

onMouseLeave && onMouseLeave(point, event)
hideTooltip()
}

handleClick = (point, event) => {
const { isInteractive, onClick } = this.props
if (!isInteractive || onClick === undefined) return

onClick(point.data, event)
}

render() {
console.log(this.props)
const {
arcs,
arcGenerator,
centerX,
centerY,

borderWidth,

margin,
outerWidth,
outerHeight,

theme,
getColor,

animate,
motionStiffness,
motionDamping,

isInteractive,
} = this.props

const motionProps = {
animate,
motionDamping,
motionStiffness,
}
const springConfig = {
damping: motionDamping,
stiffness: motionStiffness,
}

return (
<Container isInteractive={isInteractive} theme={theme}>
{({ showTooltip, hideTooltip }) => {
const onMouseEnter = this.handleMouseEnter(showTooltip)
const onMouseMove = this.handleMouseMove(showTooltip)
const onMouseLeave = this.handleMouseLeave(hideTooltip)

return (
<SvgWrapper
width={outerWidth}
height={outerHeight}
margin={margin}
theme={theme}
>
<g transform={`translate(${centerX}, ${centerY})`}>
{arcs.map(arc => {
return (
<path
key={arc.id}
d={arcGenerator(arc)}
fill={getColor(arc)}
stroke={"white"}
strokeWidth={borderWidth}
onClick={() => {
console.log(arc)
}}
/>
)
})}
</g>
</SvgWrapper>
)
}}
</Container>
)
}
}

export default setDisplayName('Rose')(enhanceSvg(Rose))
122 changes: 122 additions & 0 deletions packages/rose/src/RoseCanvas.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
/*
* 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, { Component } from 'react'
import setDisplayName from 'recompose/setDisplayName'
import { Container, SvgWrapper } from '@nivo/core'
import { enhanceSvg } from './enhance'
import { RosePropTypes } from './props'

class RoseCanvas extends Component {
static propTypes = RosePropTypes

handleMouseEnter = showTooltip => (point, event) => {
const { isInteractive, onMouseEnter } = this.props

if (!isInteractive) return

onMouseEnter && onMouseEnter(point, event)
this.showTooltip(showTooltip, point, event)
}

handleMouseMove = showTooltip => (point, event) => {
const { isInteractive, onMouseMove } = this.props

if (!isInteractive) return

onMouseMove && onMouseMove(point, event)
this.showTooltip(showTooltip, point, event)
}

handleMouseLeave = hideTooltip => (point, event) => {
const { isInteractive, onMouseLeave } = this.props

if (!isInteractive) return

onMouseLeave && onMouseLeave(point, event)
hideTooltip()
}

handleClick = (point, event) => {
const { isInteractive, onClick } = this.props
if (!isInteractive || onClick === undefined) return

onClick(point.data, event)
}

render() {
console.log(this.props)
const {
arcs,
arcGenerator,
centerX,
centerY,

margin,
width,
height,
outerWidth,
outerHeight,

theme,
getColor,

animate,
motionStiffness,
motionDamping,

isInteractive,
} = this.props

const motionProps = {
animate,
motionDamping,
motionStiffness,
}
const springConfig = {
damping: motionDamping,
stiffness: motionStiffness,
}

return (
<Container isInteractive={isInteractive} theme={theme}>
{({ showTooltip, hideTooltip }) => {
const onMouseEnter = this.handleMouseEnter(showTooltip)
const onMouseMove = this.handleMouseMove(showTooltip)
const onMouseLeave = this.handleMouseLeave(hideTooltip)

return (
<SvgWrapper
width={outerWidth}
height={outerHeight}
margin={margin}
theme={theme}
>
<g transform={`translate(${centerX}, ${centerY})`}>
{arcs.map(arc => {
return (
<path
key={arc.id}
d={arcGenerator(arc)}
fill={getColor(arc)}
onClick={() => {
console.log(arc)
}}
/>
)
})}
</g>
</SvgWrapper>
)
}}
</Container>
)
}
}

export default setDisplayName('RoseCanvas')(enhanceSvg(RoseCanvas))
Empty file added packages/rose/src/compute.js
Empty file.
Loading

0 comments on commit 54b1b52

Please sign in to comment.