-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(axes): improve tickValues support
- Loading branch information
Raphaël Benitte
committed
Aug 30, 2018
1 parent
a88e50f
commit 58aeaab
Showing
13 changed files
with
445 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* 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 Helmet from 'react-helmet' | ||
import { Link } from 'react-router-dom' | ||
import AxesPosition from './AxesPosition' | ||
import AxesTicks from './AxesTicks' | ||
import AxesLegend from './AxesLegend' | ||
|
||
export default class Axes extends Component { | ||
render() { | ||
return ( | ||
<div className="inner-content"> | ||
<Helmet title="Gradients" /> | ||
<div className="page_content"> | ||
<div className="guide__header"> | ||
<h1 className="page_header">Axes</h1> | ||
</div> | ||
</div> | ||
<div className="guide__description text-content"> | ||
<h2>Using axes in nivo components</h2> | ||
<p> | ||
Axes are built on top of{' '} | ||
<a | ||
href="https://github.com/d3/d3-scale" | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
> | ||
d3 scales | ||
</a> | ||
. A lot of nivo components make use of it (<Link to="/bar">Bar</Link>,{' '} | ||
<Link to="/line">Line</Link>, <Link to="/scatterplot">ScatterPlot</Link> | ||
…). | ||
</p> | ||
</div> | ||
<AxesPosition /> | ||
<AxesTicks /> | ||
<AxesLegend /> | ||
</div> | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* | ||
* 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, Fragment } from 'react' | ||
import { Axis, defaultTheme } from '@nivo/core' | ||
import { linearXScale, linearYScale } from './scales' | ||
|
||
const axisPositions = ['start', 'center', 'end'] | ||
|
||
export default class AxesLegend extends Component { | ||
render() { | ||
return ( | ||
<Fragment> | ||
<div className="guide__description text-content"> | ||
<h2 id="legend">Axis legend</h2> | ||
<p> | ||
You can optionally add a legend to an axis by setting the value of the{' '} | ||
<code>legend</code> property. | ||
</p> | ||
<h3 id="legend-position">Legend position</h3> | ||
<p> | ||
Legend position is controlled by two properties, <code>legendPosition</code>{' '} | ||
and <code>legendOffset</code>.<code>legendPosition</code> must be one of:{' '} | ||
<code>start</code>, <code>center</code> or <code>end</code>,{' '} | ||
<code>legendOffset</code> will affect y position for <strong>top</strong>{' '} | ||
and <strong>bottom</strong> axes and x position for <strong>left</strong>{' '} | ||
and <strong>right</strong> axes. | ||
</p> | ||
</div> | ||
<div className="banner"> | ||
<div | ||
className="guide__illustrations" | ||
style={{ justifyContent: 'center', alignItems: 'center' }} | ||
> | ||
<svg role="img" width={380} height={180}> | ||
{axisPositions.map((position, i) => ( | ||
<g key={position} transform={`translate(50,${i * 70 + 40})`}> | ||
<Axis | ||
scale={linearXScale} | ||
width={280} | ||
height={0} | ||
position="top" | ||
theme={defaultTheme} | ||
animate={false} | ||
motionStiffness={0} | ||
motionDamping={0} | ||
legend={position} | ||
legendPosition={position} | ||
legendOffset={-32} | ||
/> | ||
</g> | ||
))} | ||
</svg> | ||
<svg role="img" width={260} height={260}> | ||
{axisPositions.map((position, i) => ( | ||
<g key={position} transform={`translate(${i * 90 + 50},50)`}> | ||
<Axis | ||
scale={linearYScale} | ||
width={0} | ||
height={160} | ||
position="left" | ||
theme={defaultTheme} | ||
animate={false} | ||
motionStiffness={0} | ||
motionDamping={0} | ||
legend={position} | ||
legendPosition={position} | ||
legendOffset={-32} | ||
/> | ||
</g> | ||
))} | ||
</svg> | ||
</div> | ||
</div> | ||
</Fragment> | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* 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, Fragment } from 'react' | ||
import { Axes, defaultTheme } from '@nivo/core' | ||
import { linearXScale, linearYScale } from './scales' | ||
|
||
export default class AxesPosition extends Component { | ||
render() { | ||
return ( | ||
<Fragment> | ||
<div className="guide__description text-content"> | ||
<h2 id="position">Axis position</h2> | ||
<p> | ||
Axis position is determined by the property you use{' '} | ||
<strong>(top|right|bottom|left)Axis</strong>. | ||
</p> | ||
</div> | ||
<div className="banner"> | ||
<div className="guide__illustrations"> | ||
<svg role="img" width={380} height={260}> | ||
<g transform="translate(50,50)"> | ||
<Axes | ||
xScale={linearXScale} | ||
yScale={linearYScale} | ||
width={280} | ||
height={160} | ||
theme={defaultTheme} | ||
animate={false} | ||
motionStiffness={0} | ||
motionDamping={0} | ||
top={{ | ||
legend: 'axisTop', | ||
legendPosition: 'center', | ||
legendOffset: -32, | ||
}} | ||
right={{ | ||
legend: 'axisRight', | ||
legendPosition: 'center', | ||
legendOffset: 42, | ||
}} | ||
bottom={{ | ||
legend: 'axisBottom', | ||
legendPosition: 'center', | ||
legendOffset: 38, | ||
}} | ||
left={{ | ||
legend: 'axisLeft', | ||
legendPosition: 'center', | ||
legendOffset: -36, | ||
}} | ||
/> | ||
</g> | ||
</svg> | ||
</div> | ||
</div> | ||
</Fragment> | ||
) | ||
} | ||
} |
Oops, something went wrong.