ant-design-vue/components/vc-progress/demo/simple.jsx

51 lines
1.3 KiB
Vue
Raw Normal View History

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() {
2019-08-26 13:12:11 +00:00
const { percent, color } = this;
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>
2019-08-26 13:12:11 +00:00
<h3>Line Progress {percent}%</h3>
2018-04-03 03:00:05 +00:00
<div style={containerStyle}>
2019-08-26 13:12:11 +00:00
<Line percent={percent} strokeWidth="4" strokeColor={color} />
2019-02-19 14:35:03 +00:00
<Line
2019-08-26 13:12:11 +00:00
percent={[percent / 2, percent / 2]}
2019-02-19 14:35:03 +00:00
strokeWidth="4"
2019-08-26 13:12:11 +00:00
strokeColor={[color, '#CCC']}
2019-02-19 14:35:03 +00:00
/>
2018-04-03 03:00:05 +00:00
</div>
2019-08-26 13:12:11 +00:00
<h3>Circle Progress {percent}%</h3>
2018-04-03 03:00:05 +00:00
<div style={circleContainerStyle}>
2019-08-26 14:47:19 +00:00
<Circle percent={percent} strokeWidth="6" strokeLinecap="round" strokeColor={color} />
2018-04-03 03:00:05 +00:00
</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
};