1、主页实现一个仪表盘echarts

This commit is contained in:
xjs 2022-01-26 16:44:31 +08:00
parent 0d1664c88e
commit 204c458aad
2 changed files with 143 additions and 48 deletions

View File

@ -1,44 +1,44 @@
module.exports = { module.exports = {
/** /**
* 侧边栏主题 深色主题theme-dark浅色主题theme-light * 侧边栏主题 深色主题theme-dark浅色主题theme-light
*/ */
sideTheme: 'theme-dark', sideTheme: 'theme-light',
/** /**
* 是否系统布局配置 * 是否系统布局配置
*/ */
showSettings: false, showSettings: false,
/** /**
* 是否显示顶部导航 * 是否显示顶部导航
*/ */
topNav: false, topNav: true,
/** /**
* 是否显示 tagsView * 是否显示 tagsView
*/ */
tagsView: true, tagsView: true,
/** /**
* 是否固定头部 * 是否固定头部
*/ */
fixedHeader: false, fixedHeader: false,
/** /**
* 是否显示logo * 是否显示logo
*/ */
sidebarLogo: true, sidebarLogo: true,
/** /**
* 是否显示动态标题 * 是否显示动态标题
*/ */
dynamicTitle: false, dynamicTitle: false,
/** /**
* @type {string | array} 'production' | ['production', 'development'] * @type {string | array} 'production' | ['production', 'development']
* @description Need show err logs component. * @description Need show err logs component.
* The default is only used in the production env * The default is only used in the production env
* If you want to also use it in dev, you can pass ['production', 'development'] * If you want to also use it in dev, you can pass ['production', 'development']
*/ */
errorLog: 'production' errorLog: 'production'
} }

View File

@ -1,33 +1,128 @@
<template> <template>
<div> <div>
<el-row :gutter="20">
<el-col :span="12">
<div>
<el-card shadow="hover" class="card" ref="renderersChart">
</el-card>
</div>
</el-col>
<el-col :span="12">
<div>
<el-card shadow="hover" class="card">
</el-card>
</div>
</el-col>
</el-row>
<el-row :gutter="20">
<el-col :span="12">
<div>
<el-card shadow="hover" class="card">
</el-card>
</div>
</el-col>
<el-col :span="12">
<div>
<el-card shadow="hover" class="card">
</el-card>
</div>
</el-col>
</el-row>
</div> </div>
</template> </template>
<script> <script>
// echarts
var echarts = require('echarts/lib/echarts');
require('echarts/lib/component/tooltip');
require('echarts/lib/chart/gauge');
export default { export default {
name: "Index", name: "Index",
data() { data() {
return { return {};
};
}, },
created() { created() {
}, },
mounted() {
this.initRenderers();
},
methods: { methods: {
initRenderers() {
var myDate = new Date();
var s = myDate.getSeconds();
let renderersChart = echarts.init(this.$refs.renderersChart.$el)
renderersChart.setOption({
tooltip: {
formatter: '单位:{a} <br/>当前 : {c}s'
},
series: [
{
name: '秒',
type: 'gauge',
progress: {
show: true
},
detail: {
valueAnimation: true,
formatter: '{value}'
},
data: [
{
value: s,
name: '单位:秒',
}
],
min: 0,
max: 60,
splitNumber: 6,
}
]
})
//
setInterval(function () {
var myDate = new Date();
var s = myDate.getSeconds();
renderersChart.setOption({
series: [
{
data: [
{
value: s
}
]
},
]
});
}, 1000);
},
}, },
}; };
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.card {
height: 410px;
margin: 0 auto;
}
</style> </style>