New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Progress dashboard type (half circle) #5225
Comments
这个要考虑缺口角度的可配置么。 |
我看了progress/src/Circle.js,建议修改如下: const radius = (50 - strokeWidth / 2);
const pathString = `M 50,50 m 0,-${radius}
a ${radius},${radius} 0 1 1 0,${2 * radius}
a ${radius},${radius} 0 1 1 0,-${2 * radius}`;
const len = Math.PI * 2 * radius;
const pathStyle = {
strokeDasharray: `${len}px ${len}px`,
strokeDashoffset: `${((100 - percent) / 100 * len)}px`,
transition: 'stroke-dashoffset 0.3s ease 0s, stroke 0.3s ease',
}; 修改为如下: const pathString = `M 50,50 m 0,${radius}
a ${radius},${radius} 0 1 1 0,-${2 * radius}
a ${radius},${radius} 0 1 1 0,${2 * radius}`;
const len = Math.PI * 2 * radius;
const trailPathStyle = {
strokeDasharray: `${len - openWidth}px ${len}px`,
strokeDashoffset: `-${openWidth / 2}px`,
transition: 'stroke-dashoffset 0.3s ease 0s, stroke 0.3s ease',
};
const strokePathStyle = {
strokeDasharray: `${percent / 100 * (len - openWidth)}px ${len}px`,
strokeDashoffset: `-${openWidth / 2}px`,
transition: 'stroke-dashoffset 0.3s ease 0s, stroke 0.3s ease',
}; 通过openWidth来控制下发圆的开口,如果为0还之前相同;trailPathStyle为底图圆的样式,strokePathStyle为进度的样式。 |
@benjycui 我觉得很少有其他角度,可以不考虑 |
其实这个需求已经修改了 Progress 起点的角度,默认的起点在顶部,see https://ant.design/components/progress/#components-progress-demo-circle |
是的,起点应该要可配了 |
还是先重载缺口属性的语义吧,设置了缺口就意味着起点在左下开始。 |
@qiaolb 能来个 PR 么,感觉需求很清晰,不妨抽时间参与一下? |
由于急用,先临时写了一个,当Ant Design支持后再切换回来: |
@afc163 弱弱的问一下,什么是PR? |
https://github.com/ant-design/ant-design/pulls 就是给我们提交代码,这个特性交给你来完成。 |
明白了。可以 |
More about PR: http://makeapullrequest.com/ |
<Progress type="dashboard" /> |
@afc163 在rc-progress中增加了两个属性gapWidth和gapPosition,表现还是一个圆形,可以在属性中直接指定。由于这两个值都有缺省值,缺省值保持和以前效果相同。这样是否需要增加一个type(dashboard)呢? |
我是想,上层就不显式暴露这两个值了,封装成一个类型即可。 |
@afc163 如果不暴露,开口的大小开发者就没有办法定义了。开口方向一般都是下面,问题到不大。 |
我意思是不显式暴露,属性还是会传递到 rc-progress 上,如果高级开发者要定义也是能行的。
|
@afc163 OK. |
@afc163 请教一个问题,我代码已经修改,但由于rc-progress修改的版本还没有发布,我如何测试Ant Design的修改呢? |
@qiaolb 你可以直接修改node_modules/rc-progress地下的源码来测试。 |
rc-progress 里跑一下 |
我运行 |
确实不行。用这个: |
@afc163 可以了,谢谢 |
rc-progress@2.1.0 发布了,gapWidth 我又改成 gapDegree 了,角度比较准确。 |
@afc163 太好了,效率真高! |
Progress dashboard type (half circle)[ant-design#5225]
* Upgrade `rc-progress` to `2.1.0`. Support dashboard. Progress dashboard type (half circle)[#5225] * restore removed code, it is for compatibility * format code
This thread has been automatically locked because it has not had recent activity. Please open a new issue for related bugs and link to relevant comments in this thread. |
我想实现一个半圆效果,其实是一个仪表盘,如图:
有没有办法让Progress支持呢?
The text was updated successfully, but these errors were encountered: