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

81 lines
2.1 KiB
Vue
Raw Normal View History

2019-01-12 11:33:27 +08:00
import { Circle } from '../index';
import '../assets/index.less';
2018-04-03 11:00:05 +08:00
2019-02-19 22:35:03 +08:00
const colorMap = ['#3FC7FA', '#85D262', '#FE8C6A'];
function getColor(index) {
return colorMap[(index + colorMap.length) % colorMap.length];
}
2018-04-03 11:00:05 +08:00
export default {
2019-01-12 11:33:27 +08:00
data() {
2018-04-03 11:00:05 +08:00
return {
percent: 30,
2019-02-19 22:35:03 +08:00
colorIndex: 0,
2019-01-12 11:33:27 +08:00
};
2018-04-03 11:00:05 +08:00
},
methods: {
2019-01-12 11:33:27 +08:00
changeState() {
const value = parseInt(Math.random() * 100, 10);
2019-02-19 22:35:03 +08:00
const colorIndex = parseInt(Math.random() * 3, 10);
2019-01-12 11:33:27 +08:00
this.percent = value;
2019-02-19 22:35:03 +08:00
this.colorIndex = colorIndex;
2018-04-03 11:00:05 +08:00
},
},
2019-01-12 11:33:27 +08:00
render() {
2018-04-03 11:00:05 +08:00
const circleContainerStyle = {
width: '200px',
height: '200px',
2019-01-12 11:33:27 +08:00
};
2019-02-19 22:35:03 +08:00
const { percent, colorIndex } = this;
const color = getColor(colorIndex);
2018-04-03 11:00:05 +08:00
return (
<div>
2019-02-19 22:35:03 +08:00
<p>
<button onClick={this.changeState}>Change State [{percent}]</button>
</p>
2018-04-03 11:00:05 +08:00
<div style={circleContainerStyle}>
<Circle
percent={this.percent}
2019-01-12 11:33:27 +08:00
gapDegree="70"
2019-02-19 22:35:03 +08:00
gapPosition="bottom"
2019-01-12 11:33:27 +08:00
strokeWidth="6"
strokeLinecap="square"
2018-04-03 11:00:05 +08:00
strokeColor={this.color}
/>
</div>
<div style={circleContainerStyle}>
<Circle
2019-02-19 22:35:03 +08:00
percent={[percent / 3, percent / 3, percent / 3]}
2019-01-12 11:33:27 +08:00
gapDegree="70"
gapPosition="bottom"
strokeWidth="6"
2019-02-19 22:35:03 +08:00
trailWidth="6"
strokeLinecap="round"
strokeColor={[color, getColor(colorIndex + 1), getColor(colorIndex + 2)]}
2018-04-03 11:00:05 +08:00
/>
</div>
<div style={circleContainerStyle}>
<Circle
percent={this.percent}
2019-01-12 11:33:27 +08:00
gapDegree="70"
gapPosition="left"
strokeWidth="6"
strokeLinecap="square"
2018-04-03 11:00:05 +08:00
strokeColor={this.color}
/>
</div>
<div style={circleContainerStyle}>
<Circle
percent={this.percent}
2019-01-12 11:33:27 +08:00
gapDegree="70"
gapPosition="right"
strokeWidth="6"
strokeLinecap="square"
2018-04-03 11:00:05 +08:00
strokeColor={this.color}
/>
</div>
</div>
2019-01-12 11:33:27 +08:00
);
2018-04-03 11:00:05 +08:00
},
2019-01-12 11:33:27 +08:00
};