Skip to content
本页导读

Chart-ring

组件类型:UxChartRingComponentPublicInstance

canvas绘制的环形进度条图表

平台兼容性

UniApp X

AndroidiOSweb鸿蒙 Next小程序
x

UniApp Vue Nvue

AndroidiOSweb鸿蒙 Next小程序
xxxx

Props

属性名类型默认值说明
modeStringring模式
dataUxChartRingType数据
delayNumber0延迟初始化

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>