2019-01-12 03:33:27 +00:00
|
|
|
import { Line, Circle } from '../index';
|
|
|
|
import '../assets/index.less';
|
2018-04-03 03:00:05 +00:00
|
|
|
|
|
|
|
export default {
|
2019-01-12 03:33:27 +00:00
|
|
|
data() {
|
2018-04-03 03:00:05 +00:00
|
|
|
return {
|
|
|
|
percent: 30,
|
|
|
|
color: '#3FC7FA',
|
2019-01-12 03:33:27 +00:00
|
|
|
};
|
2018-04-03 03:00:05 +00:00
|
|
|
},
|
|
|
|
methods: {
|
2019-01-12 03:33:27 +00:00
|
|
|
changeState() {
|
|
|
|
const colorMap = ['#3FC7FA', '#85D262', '#FE8C6A'];
|
|
|
|
const value = parseInt(Math.random() * 100, 10);
|
|
|
|
this.percent = value;
|
|
|
|
this.color = colorMap[parseInt(Math.random() * 3, 10)];
|
2018-04-03 03:00:05 +00:00
|
|
|
},
|
|
|
|
},
|
2019-01-12 03:33:27 +00:00
|
|
|
render() {
|
2018-04-03 03:00:05 +00:00
|
|
|
const containerStyle = {
|
|
|
|
width: '250px',
|
2019-01-12 03:33:27 +00:00
|
|
|
};
|
2018-04-03 03:00:05 +00:00
|
|
|
const circleContainerStyle = {
|
|
|
|
width: '250px',
|
|
|
|
height: '250px',
|
|
|
|
display: 'inline-block',
|
2019-01-12 03:33:27 +00:00
|
|
|
};
|
2018-04-03 03:00:05 +00:00
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<h3>Line Progress {this.percent}%</h3>
|
|
|
|
<div style={containerStyle}>
|
2019-01-12 03:33:27 +00:00
|
|
|
<Line percent={this.percent} strokeWidth="4" strokeColor={this.color} />
|
2019-02-19 14:35:03 +00:00
|
|
|
<Line
|
|
|
|
percent={[this.percent / 2, this.percent / 2]}
|
|
|
|
strokeWidth="4"
|
|
|
|
strokeColor={[this.color, '#CCC']}
|
|
|
|
/>
|
2018-04-03 03:00:05 +00:00
|
|
|
</div>
|
|
|
|
<h3>Circle Progress {this.percent}%</h3>
|
|
|
|
<div style={circleContainerStyle}>
|
|
|
|
<Circle
|
|
|
|
percent={this.percent}
|
2019-01-12 03:33:27 +00:00
|
|
|
strokeWidth="6"
|
|
|
|
strokeLinecap="round"
|
2018-04-03 03:00:05 +00:00
|
|
|
strokeColor={this.color}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<p>
|
|
|
|
<button onClick={this.changeState}>Change State</button>
|
|
|
|
</p>
|
|
|
|
</div>
|
2019-01-12 03:33:27 +00:00
|
|
|
);
|
2018-04-03 03:00:05 +00:00
|
|
|
},
|
2019-01-12 03:33:27 +00:00
|
|
|
};
|