desktop_task_schedule/code/web/task_schedule/src/components/ArchievementChartComponent.vue

120 lines
2.8 KiB
Vue
Raw Normal View History

2023-03-04 18:05:47 +08:00
<!--
* @Author: Kane
* @Date: 2023-03-04 16:09:31
* @LastEditors: Kane
2023-03-08 10:29:35 +08:00
* @FilePath: /task_schedule/src/components/ArchievementChartComponent.vue
* @Description: 业绩图表组件
2023-03-04 18:05:47 +08:00
*
* Copyright (c) ${2022} by Kane, All Rights Reserved.
-->
<template>
<div class="archievement-wrapper">
<span>总业绩</span>
2023-03-04 19:32:05 +08:00
<span>¥&nbsp;{{ archivement_count }}</span>
2023-03-04 18:05:47 +08:00
<div id="chartWrapper"></div>
</div>
</template>
2023-03-04 19:32:05 +08:00
<script lang="ts">
2023-03-04 18:05:47 +08:00
import { reactive, computed, onMounted } from "vue";
import * as echarts from "echarts";
export default {
2023-03-08 10:29:35 +08:00
name: "ArchievementChartComponent",
props: {
total_archievement: {
type: String,
require: true,
},
chart_data: {
type: Array,
require: true,
},
},
setup(props)
2023-03-04 18:05:47 +08:00
{
const ui = reactive({
2023-03-08 10:29:35 +08:00
total_archievement: props.total_archievement,
chart_data: props.chart_data,
2023-03-04 18:05:47 +08:00
});
const archivement_count = computed(() =>
{
return ui.total_archievement;
});
//设置图表
const initCharts = () =>
{
2023-03-05 00:37:24 +08:00
const chartDom = document.getElementById("chartWrapper");
2023-03-04 19:32:05 +08:00
//@ts-ignore
const myChart = echarts.init((chartDom));
const option = {
2023-03-04 18:05:47 +08:00
xAxis: {
2023-03-05 00:37:24 +08:00
type: "category",
2023-03-04 18:05:47 +08:00
data: ["一", "二", "三", "四", "五", "六", "七", "八", "九", "十", "十一", "十二",],
},
yAxis: {
2023-03-05 00:37:24 +08:00
type: "value",
2023-03-04 18:05:47 +08:00
data: [200, 400, 600, 800, 1000,],
},
series: [
{
2023-03-08 10:29:35 +08:00
data: props.chart_data,
2023-03-05 00:37:24 +08:00
type: "line",
2023-03-04 18:05:47 +08:00
},
],
};
option && myChart.setOption(option);
2023-03-04 19:32:05 +08:00
window.onresize = function ()
2023-03-04 18:05:47 +08:00
{
//自适应大小
myChart.resize();
};
};
onMounted(() =>
{
initCharts();
});
return { ui, archivement_count, initCharts, };
},
};
</script>
<style lang="scss">
.archievement-wrapper {
height: 360px;
width: 100%;
display: flex;
flex-direction: column;
justify-content: center;
align-items: stretch;
span {
display: block;
width: 100%;
color: #25e6e6;
text-align: center;
font: {
size: 35px;
family: "FZ-ZHUOHEI";
}
flex-grow: 0;
}
#chartWrapper {
min-height: 200px;
width: 100%;
2023-03-07 17:54:52 +08:00
background-color: $color-charts-bg;
2023-03-04 18:05:47 +08:00
backdrop-filter: blur(10px);
flex-grow: 1;
border-radius: 5px;
}
}
</style>