2018-10-12 12:23:21 +00:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import { ResponsiveLine } from '@nivo/line';
|
|
|
|
|
|
|
|
import './Line.css';
|
|
|
|
|
|
|
|
const Line = props => (
|
|
|
|
props.data &&
|
|
|
|
<ResponsiveLine
|
|
|
|
data={props.data}
|
|
|
|
margin={{
|
|
|
|
top: 15,
|
|
|
|
right: 0,
|
|
|
|
bottom: 1,
|
|
|
|
left: 0,
|
|
|
|
}}
|
|
|
|
minY="auto"
|
|
|
|
stacked={false}
|
|
|
|
curve='linear'
|
|
|
|
axisBottom={{
|
|
|
|
tickSize: 0,
|
2018-10-27 18:17:48 +00:00
|
|
|
tickPadding: 10,
|
2018-10-12 12:23:21 +00:00
|
|
|
}}
|
|
|
|
axisLeft={{
|
|
|
|
tickSize: 0,
|
2018-10-27 18:17:48 +00:00
|
|
|
tickPadding: 10,
|
2018-10-12 12:23:21 +00:00
|
|
|
}}
|
|
|
|
enableGridX={false}
|
|
|
|
enableGridY={false}
|
|
|
|
enableDots={false}
|
|
|
|
enableArea={true}
|
|
|
|
animate={false}
|
|
|
|
colorBy={() => (props.color)}
|
|
|
|
tooltip={slice => (
|
|
|
|
<div>
|
|
|
|
{slice.data.map(d => (
|
|
|
|
<div key={d.serie.id} className="line__tooltip">
|
|
|
|
<span className="line__tooltip-text">
|
2018-10-14 20:50:13 +00:00
|
|
|
<strong>{d.data.y}</strong>
|
|
|
|
<br/>
|
|
|
|
<small>{d.data.x}</small>
|
2018-10-12 12:23:21 +00:00
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
))}
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
theme={{
|
|
|
|
tooltip: {
|
|
|
|
container: {
|
|
|
|
padding: '0',
|
|
|
|
background: '#333',
|
|
|
|
borderRadius: '4px',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
|
|
|
|
Line.propTypes = {
|
|
|
|
data: PropTypes.array.isRequired,
|
|
|
|
color: PropTypes.string.isRequired,
|
|
|
|
};
|
|
|
|
|
|
|
|
export default Line;
|