Skip to content
本页导读

Chart-bar

组件类型:UxChartBarComponentPublicInstance

canvas绘制的柱状图图表

平台兼容性

UniApp X

AndroidiOSweb鸿蒙 Next小程序
x

UniApp Vue Nvue

AndroidiOSweb鸿蒙 Next小程序
xxxx

Props

属性名类型默认值说明
dataObject数据
delayNumber0延迟初始化

示例代码

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">
				<view style="height: 200px;">
					<ux-chart-bar :data="data"></ux-chart-bar>
				</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">
				<view style="height: 200px;">
					<ux-chart-bar :data="data"></ux-chart-bar>
				</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 { UxChartBarType, useThemeColor } from '@/uni_modules/ux-frame'
	import * as plus from '@/uni_modules/ux-plus'
	
	const title = ref('')
	const showDoc = ref(false)
	
	const data = computed(() => {
		return {
			data: [[1.85, -1, -2, -0.15, 0.23, 0.8, 0.95]],
			xAxis: ["02-24", "02-25", "02-26", "02-27", "02-28", "03-01", "03-02"],
			width: 0.5,
			labelAngle: 45,
			backgroundColor: useThemeColor('primary'),
		} as UxChartBarType
	})
	
	function onDoc() {
		plus.openWeb({
			title: '在线文档',
			url: 'https://www.uxframe.cn/component/chart-bar.html',
			// blur: 1,
			success: () => {
				showDoc.value = true
			},
			complete: () => {
				showDoc.value = false
			}
		})
	}
	
	onLoad((e) => {
		title.value = e['title'] ?? ''
	})
</script>
<script setup>
	import { UxChartBarType, useThemeColor } from '@/uni_modules/ux-frame'
	import * as plus from '@/uni_modules/ux-plus'
	
	const title = ref('')
	const showDoc = ref(false)
	
	const data = computed(() => {
		return {
			data: [[1.85, -1, -2, -0.15, 0.23, 0.8, 0.95]],
			xAxis: ["02-24", "02-25", "02-26", "02-27", "02-28", "03-01", "03-02"],
			width: 0.5,
			labelAngle: 45,
			backgroundColor: useThemeColor('primary'),
		} as UxChartBarType
	})
	
	function onDoc() {
		plus.openWeb({
			title: '在线文档',
			url: 'https://www.uxframe.cn/component/chart-bar.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>