Chart-ring
组件类型:UxChartRingComponentPublicInstance
canvas绘制的环形进度条图表
平台兼容性
UniApp X
Android | iOS | web | 鸿蒙 Next | 小程序 |
---|---|---|---|---|
√ | √ | √ | x | √ |
UniApp Vue Nvue
Android | iOS | web | 鸿蒙 Next | 小程序 |
---|---|---|---|---|
x | x | √ | x | x |
Props
属性名 | 类型 | 默认值 | 说明 |
---|---|---|---|
mode | String | ring | 模式 |
data | UxChartRingType | 数据 | |
delay | Number | 0 | 延迟初始化 |
mode
值 | 说明 |
---|---|
ring圆环 | |
dashboard仪表盘 |
Events
事件名 | 说明 | 参数 |
---|---|---|
changing | 进度发生改变时触发 |
示例代码
html
<template>
<ux-page :stack="showDoc">
<ux-navbar :title="title" :bold="true">
<template v-slot:right>
<!-- #ifndef MP -->
<ux-button theme="text" icon="/static/tip.png" :icon-size="22" @click="onDoc()"></ux-button>
<!-- #endif -->
</template>
</ux-navbar>
<ux-scroll>
<ux-card direction="column" icon="flag-filled" title="环形图" :bold="true">
<ux-text text="canvas绘制的环形图,支持全端"></ux-text>
</ux-card>
<ux-card direction="column" icon="arrowright" title="仪表盘" :bold="true">
<template #subtitle>
<ux-row>
<ux-button @click="add" text="+" :ml="15"></ux-button>
<ux-button @click="mut" text="-" :ml="10"></ux-button>
</ux-row>
</template>
<view style="height: 100px;">
<ux-chart-ring mode="dashboard" :data="data1"></ux-chart-ring>
</view>
</ux-card>
<ux-card direction="column" icon="arrowright" title="圆环" :bold="true">
<view style="height: 120px;">
<ux-chart-ring mode="ring" :data="data2"></ux-chart-ring>
</view>
</ux-card>
<ux-placeholder :height="200">
<ux-row justify="center" align="center" style="height: 100%;">
<ux-text prefix-icon="soapbubble-filled" text="真的没有了~"></ux-text>
</ux-row>
</ux-placeholder>
</ux-scroll>
</ux-page>
</template>
<template>
<ux-page :stack="showDoc">
<ux-navbar :title="title" :bold="true">
<template v-slot:right>
<!-- #ifndef MP -->
<ux-button theme="text" icon="/static/tip.png" :icon-size="22" @click="onDoc()"></ux-button>
<!-- #endif -->
</template>
</ux-navbar>
<ux-scroll>
<ux-card direction="column" icon="flag-filled" title="环形图" :bold="true">
<ux-text text="canvas绘制的环形图,支持全端"></ux-text>
</ux-card>
<ux-card direction="column" icon="arrowright" title="仪表盘" :bold="true">
<template #subtitle>
<ux-row>
<ux-button @click="add" text="+" :ml="15"></ux-button>
<ux-button @click="mut" text="-" :ml="10"></ux-button>
</ux-row>
</template>
<view style="height: 100px;">
<ux-chart-ring mode="dashboard" :data="data1"></ux-chart-ring>
</view>
</ux-card>
<ux-card direction="column" icon="arrowright" title="圆环" :bold="true">
<view style="height: 120px;">
<ux-chart-ring mode="ring" :data="data2"></ux-chart-ring>
</view>
</ux-card>
<ux-placeholder :height="200">
<ux-row justify="center" align="center" style="height: 100%;">
<ux-text prefix-icon="soapbubble-filled" text="真的没有了~"></ux-text>
</ux-row>
</ux-placeholder>
</ux-scroll>
</ux-page>
</template>
ts
<script setup>
import { UxChartRingType, useThemeColor } from '@/uni_modules/ux-frame'
import * as plus from '@/uni_modules/ux-plus'
const title = ref('')
const showDoc = ref(false)
const val = ref(20)
const data1 = computed(() => {
return {
value: val.value,
radius: [70, 80],
progressColor: useThemeColor('primary'),
bottom: 10
} as UxChartRingType
})
const data2 = computed(() => {
return {
value: val.value,
radius: [50, 60],
progressColor: useThemeColor('primary')
} as UxChartRingType
})
function add() {
val.value += 20
val.value = Math.min(val.value, 100)
}
function mut() {
val.value -= 20
val.value = Math.max(val.value, 0)
}
function onDoc() {
plus.openWeb({
title: '在线文档',
url: 'https://www.uxframe.cn/component/chart-ring.html',
// blur: 1,
success: () => {
showDoc.value = true
},
complete: () => {
showDoc.value = false
}
})
}
onLoad((e) => {
title.value = e['title'] ?? ''
})
</script>
<script setup>
import { UxChartRingType, useThemeColor } from '@/uni_modules/ux-frame'
import * as plus from '@/uni_modules/ux-plus'
const title = ref('')
const showDoc = ref(false)
const val = ref(20)
const data1 = computed(() => {
return {
value: val.value,
radius: [70, 80],
progressColor: useThemeColor('primary'),
bottom: 10
} as UxChartRingType
})
const data2 = computed(() => {
return {
value: val.value,
radius: [50, 60],
progressColor: useThemeColor('primary')
} as UxChartRingType
})
function add() {
val.value += 20
val.value = Math.min(val.value, 100)
}
function mut() {
val.value -= 20
val.value = Math.max(val.value, 0)
}
function onDoc() {
plus.openWeb({
title: '在线文档',
url: 'https://www.uxframe.cn/component/chart-ring.html',
// blur: 1,
success: () => {
showDoc.value = true
},
complete: () => {
showDoc.value = false
}
})
}
onLoad((e) => {
title.value = e['title'] ?? ''
})
</script>
css
<style lang="scss">
</style>
<style lang="scss">
</style>