
一、(1)插件市场,导入使用秋云插件
<!-- 列表页 -->
<template>
<view>
<!--1 start -->
<view class="sales-view">
<view class="title"></view>
<view>
<!--uCharts组件事件及方法: @getIndex -->
<!-- https://www.ucharts.cn/v2/#/guide/index -->
<!-- (3),使用 customType="column" 树状图,line折线,scatter散点图-->
<tree-charts
customType="column"
:showTitle="true"
:chartData="chartDataObj"
@getIndex="getTreeIndexTap">
</tree-charts>
</view>
</view>
<!--1 end -->
</view>
</template>
<script>
import treeCharts from '@/pages/sales/components/tree-charts.vue';
export default {
components: {
treeCharts,
},
data(){
return{
chartDataObj:{
categories:['01','02','03','04','05','06','07','08','09','10','11','12'],
series:[{
color: "#007aff",
legendShape: "circle",
name: "销售",
data:["7769.84","8051.73","43077.18","11853.73","25637.62","43024.84","26610.34","1794.47","158.32","0.00" ,"0.00" ,"0.00"]
}]
},
}
},
onLoad() {},
methods:{
getTreeIndexTap(row){
console.log('----',row)
}
},
}
</script>
<style lang="scss" scoped>
page{
background-color: #f6f7fb;
}
.sales-view{
margin: 20rpx;
border-radius: 16rpx;
background-color: white;
padding: 20rpx;
.title{
font-size: 26rpx;
}
}
</style>
一、(2)封装组件
<!-- 封装树状图组件-->
<template>
<view class="charts-box">
<qiun-data-charts :type="customType" :chartData="chartData" :tooltipShow="false" :animation="false" :opts="opts" />
</view>
</template>
<script>
export default {
props: {
customType:{
type:String,
default:'line'
},
chartData: {
type: Object
},
profitMin:{
type:[Number,String],
default:0
}
},
data() {
return {
opts: {
canvasId: 'lineChartId',
canvas2d: false,
background: '#FFFFFF',
animation: true,
timing: 'easeOut',
duration: 1000,
dataLabel: false,
fontSize: 10,
fontColor: '#BEC1CD',
padding: [0, 0, 0, 0],
xAxis: {
axisLineColor: '#F0F0F0'
},
yAxis: {
gridColor: '#F0F0F0',
data: [
{
type: 'value',
unit: '%',
min: this.profitMin,
tofix: 2,
axisLineColor: '#F0F0F0',
textAlign: 'right',
axisLine: false
}
]
},
legend: {
show: true,
position: 'top',
float: 'left',
padding: 20,
lineHeight: 11,
margin: 0
},
extra: {
line: {
type: 'curve'
},
column: {
type: 'stack',
width: 10
},
tooltip: {
showBox: true
}
}
}
};
},
mounted() {}
};
</script>
<style lang="scss" scoped>
.charts-box {
height: 450rpx;
}
</style>