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

108 lines
2.4 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">
<div id="chartWrapper"></div>
</div>
</template>
2023-03-04 19:32:05 +08:00
<script lang="ts">
2023-03-08 16:35:40 +08:00
import { reactive, onMounted } from "vue";
2023-03-04 18:05:47 +08:00
import * as echarts from "echarts";
export default {
2023-03-08 10:29:35 +08:00
name: "ArchievementChartComponent",
props: {
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
chart_data: props.chart_data,
2023-03-04 18:05:47 +08:00
});
//设置图表
const initCharts = () =>
{
2023-03-05 00:37:24 +08:00
const chartDom = document.getElementById("chartWrapper");
2023-03-12 23:33:27 +08:00
// @ts-ignore
const myChart = echarts.init(chartDom);
2023-03-04 19:32:05 +08:00
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();
});
2023-03-08 13:24:12 +08:00
return { ui, initCharts, };
2023-03-04 18:05:47 +08:00
},
};
</script>
<style lang="scss">
.archievement-wrapper {
2023-03-08 13:24:12 +08:00
height: 100%;
2023-03-04 18:05:47 +08:00
width: 100%;
2023-03-08 13:24:12 +08:00
// display: flex;
// flex-direction: column;
// justify-content: center;
// align-items: stretch;
2023-03-04 18:05:47 +08:00
2023-03-08 13:24:12 +08:00
// span {
// display: block;
// width: 100%;
// color: #25e6e6;
// text-align: center;
2023-03-04 18:05:47 +08:00
2023-03-08 13:24:12 +08:00
// font: {
// size: 35px;
// family: "FZ-ZHUOHEI";
// }
2023-03-04 18:05:47 +08:00
2023-03-08 13:24:12 +08:00
// flex-grow: 0;
// }
2023-03-04 18:05:47 +08:00
#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>