仪表盘的实现 #4390
仪表盘的实现
#4390
Replies: 4 comments 3 replies
-
后面可以按照一个固定的格式去写设计文档(我把它放入规范中),其实和 API 文档的模版很像,这样也方便直接放入文档中。 # Gauge
`[一段描述]`
## 开始使用
`[一张截图]`
~~~js
// 代码片段
~~~
## 选项
`一个表格`
## 案例
`[展示更多能力]` |
Beta Was this translation helpful? Give feedback.
0 replies
-
下面一些需要注意的地方:
const options = {
scale: {
color: { domain: [0, 0.5, 1], range: ['#F4664A', '#FAAD14', '#30BF78'] },
}
}
const options = {
style: {
arcFill: 'red', // 比如取名为 arc
arcType: 'meter',
meterSteps: '',
}
}
const options = {
style: {
text: false, // 不展示文本
}
}
const options = {
style: {
text: 1,
textFormatter: d => `${d/100}%`
}
}
const options = {
style: {
text: '100%'
}
}
function Gauge(options) {
return [
{
type: 'view',
coordinates: [],
children: [
{ type: 'interval' },
{ type: 'shape' },
{ type: 'shape' },
{ type: 'text' },
],
},
];
}
const options = {
style: {
textShape: () => {}, // 可以透传给 shape 的 render 函数
pinShape: () => {}
}
} |
Beta Was this translation helpful? Give feedback.
1 reply
-
我补充一两个疑惑点,但可能你们已经考虑了 💭
|
Beta Was this translation helpful? Give feedback.
1 reply
-
这里拍平: const options = {
style: {
arcMeterSteps: '',
arcMeterGap: ''
}
} |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
仪表盘 - Gauge
仪表盘需要通过 Shape 组合定制。主要分为三个部分:圆环部分、指针部分、统计文字部分。
开始使用
选项
1.
data: { target: 4000, total: 10000 }
2.
data: { percent: 0.75 }
arc
|pointer
|text
指定样式Arc 样式配置
0-1
1
-Math.PI
Math.PI
linear
|meter
linear
meter
样式时的配置meter
总步长50
meter
间隔长度,范围[0, 1]
0.5
pin 和 pointer 配置
() => Shape
() => Shape
text 样式配置
() => Shape
string
customHtml > formatter > content
number
number
number
实现思路
Composition 里面添加一个 Gauge。
案例验证
Beta Was this translation helpful? Give feedback.
All reactions