123 lines
2.4 KiB
Vue
123 lines
2.4 KiB
Vue
<template>
|
|
<custom-echart-bar :chart-data="state.data" height="100%" :option="state.option" />
|
|
</template>
|
|
<script setup>
|
|
import { reactive } from 'vue';
|
|
|
|
const state = reactive({
|
|
data: [
|
|
{
|
|
name: '其他',
|
|
value: 3500,
|
|
},
|
|
{
|
|
name: '烟叶',
|
|
value: 4000,
|
|
},
|
|
{
|
|
name: '甘蔗',
|
|
value: 6000,
|
|
},
|
|
{
|
|
name: '核桃',
|
|
value: 8000,
|
|
},
|
|
{
|
|
name: '茶叶',
|
|
value: 12000,
|
|
},
|
|
],
|
|
option: {
|
|
grid: {
|
|
left: '5%',
|
|
right: '5%',
|
|
bottom: '5%',
|
|
top: '10%',
|
|
containLabel: true,
|
|
},
|
|
tooltip: {
|
|
trigger: 'axis',
|
|
axisPointer: {
|
|
type: 'shadow',
|
|
},
|
|
backgroundColor: 'rgba(18, 55, 85, 0.8);',
|
|
borderColor: '#35d0c0',
|
|
formatter: (data) => {
|
|
const params = data[0];
|
|
let str = `<div class="custom-echarts-tips">
|
|
<span>${params.name}</span><br/>
|
|
<span>${params.marker} ${params.data}吨</span>
|
|
</div>`;
|
|
return str;
|
|
},
|
|
},
|
|
barStyle: {
|
|
barWidth: 14,
|
|
itemStyle: {
|
|
borderWidth: 14,
|
|
borderRadius: [8, 8, 8, 8], // 设置柱子的圆角半径
|
|
},
|
|
color: {
|
|
type: 'linear',
|
|
x: 0,
|
|
y: 0,
|
|
x2: 0,
|
|
y2: 1,
|
|
colorStops: [
|
|
{ offset: 0, color: '#35D0C0' },
|
|
{ offset: 1, color: '#35D0C0' },
|
|
],
|
|
global: false,
|
|
},
|
|
},
|
|
xAxis: {
|
|
type: 'value',
|
|
splitLine: {
|
|
show: false,
|
|
lineStyle: {
|
|
type: 'dashed',
|
|
color: '#E5E5E5',
|
|
},
|
|
},
|
|
axisLabel: {
|
|
show: false,
|
|
textStyle: {
|
|
color: '#424242',
|
|
},
|
|
},
|
|
show: false,
|
|
axisLine: {
|
|
show: true,
|
|
},
|
|
axisTick: {
|
|
show: false,
|
|
},
|
|
},
|
|
yAxis: {
|
|
type: 'category',
|
|
data: ['茶叶', '核桃', '甘蔗', '烟叶', '其他'],
|
|
axisLabel: {
|
|
color: '#fff',
|
|
},
|
|
axisTick: {
|
|
show: false,
|
|
},
|
|
splitLine: {
|
|
show: false,
|
|
},
|
|
axisLine: {
|
|
show: false,
|
|
},
|
|
},
|
|
series: [
|
|
{
|
|
type: 'bar',
|
|
// barWidth: '40%', // 设置柱的宽度
|
|
// barMinHeight: 2, // 设置柱的最小高度
|
|
// barGap: '20%', // 设置柱之间的间隙
|
|
},
|
|
],
|
|
},
|
|
});
|
|
</script>
|