Chart-line
组件类型:UxChartLineComponentPublicInstance
canvas绘制的折线图图表
平台兼容性
UniApp X
Android | iOS | web | 鸿蒙 Next | 小程序 |
---|---|---|---|---|
√ | √ | √ | x | √ |
UniApp Vue Nvue
Android | iOS | web | 鸿蒙 Next | 小程序 |
---|---|---|---|---|
x | x | √ | x | x |
Props
属性名 | 类型 | 默认值 | 说明 |
---|---|---|---|
data | Object | 数据 | |
delay | Number | 0 | 延迟初始化 |
示例代码
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-line :data="data"></ux-chart-line>
</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-line :data="data"></ux-chart-line>
</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 { UxChartLineType, 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: [[820, 932, 901, 934, 1290, 1330, 1320], [520, 666, 250, 888, 1520, 866, 700]],
xAxis: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
areaColor: [useThemeColor('primary'), useThemeColor('success')],
lineColor: useThemeColor('primary')
} as UxChartLineType
})
function onDoc() {
plus.openWeb({
title: '在线文档',
url: 'https://www.uxframe.cn/component/chart-line.html',
// blur: 1,
success: () => {
showDoc.value = true
},
complete: () => {
showDoc.value = false
}
})
}
onLoad((e) => {
title.value = e['title'] ?? ''
})
</script>
<script setup>
import { UxChartLineType, 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: [[820, 932, 901, 934, 1290, 1330, 1320], [520, 666, 250, 888, 1520, 866, 700]],
xAxis: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
areaColor: [useThemeColor('primary'), useThemeColor('success')],
lineColor: useThemeColor('primary')
} as UxChartLineType
})
function onDoc() {
plus.openWeb({
title: '在线文档',
url: 'https://www.uxframe.cn/component/chart-line.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>