vue前端Echars

<template><div :class="className" :style="{height:height,width:width}" />
</template><script>
import * as echarts from 'echarts'
require('echarts/theme/macarons') // echarts theme  柱状图
import resize from './mixins/resize'
import { insertUserList } from "@/api/system/user";const animationDuration = 6000export default {mixins: [resize],props: {className: {type: String,default: 'chart'},width: {type: String,default: '100%'},height: {type: String,default: '300px'}},data() {return {chart: null,sevenDays: [],newUsers:[],date:[]}},mounted() {this.$nextTick(() => {this.initChart()})this.getSevenDays();//this.getList();},beforeDestroy() {if (!this.chart) {return}this.chart.dispose()this.chart = null},methods: {//近七天getSevenDays() {const today = new Date();const sevenDays = [];for (let i = 0; i < 7; i++) {const date = new Date(today);date.setDate(today.getDate() - i);sevenDays.push(date.toISOString().split('T')[0]);}this.sevenDays = sevenDays;},//获取新增用户值//getList() {// },initChart() {this.chart = echarts.init(this.$el, 'macarons')insertUserList().then(response => {let insertUserList = response.data;for (let i = 0; i < insertUserList.length; i++) {this.newUsers.push(insertUserList[i].newUsers);this.date.push(insertUserList[i].date);}console.log("insertUserList:"+this.newUsers);this.chart.setOption({tooltip: {trigger: 'axis',axisPointer: { // 坐标轴指示器,坐标轴触发有效type: 'shadow' // 默认为直线,可选为:'line' | 'shadow'}},grid: {top: 10,left: '2%',right: '2%',bottom: '3%',containLabel: true},xAxis: [{type: 'category',data: this.date,axisTick: {alignWithLabel: true}}],yAxis: [{type: 'value',axisTick: {show: false,}}],series: [{color: "#c23616",name: '新增用户',type: 'bar',stack: 'vistors',barWidth: '60%',data: this.newUsers,animationDuration}, // {//   color: "#c23616",//   name: '活跃用户',//   type: 'bar',//   stack: 'vistors',//   barWidth: '60%',//   data: [80, 52, 200, 334, 390, 330, 220],//   animationDuration// }]})});}}
}
</script><template><div :class="className" :style="{ height: height, width: width }" />
</template><script>
import * as echarts from 'echarts'
require('echarts/theme/macarons') // echarts theme  折线图
import resize from './mixins/resize'
import { pagingUserExam, isPassed, listUserExam, getUserExam, delUserExam, addUserExam, updateUserExam } from "@/api/exam/userExam";
export default {mixins: [resize],props: {className: {type: String,default: 'chart'},width: {type: String,default: '100%'},height: {type: String,default: '350px'},autoResize: {type: Boolean,default: true},chartData: {type: Object,required: true}},data() {return {chart: null,sevenDays: [],passedCount: [],failedCount: [],updateTime: [],// 查询参数queryParams: {pageNum: 1,pageSize: 100,deptId: undefined},}},watch: {chartData: {deep: true,handler(val) {this.setOptions(val)}}},mounted() {this.$nextTick(() => {this.initChart()})this.getSevenDays();//this.getList(); },beforeDestroy() {if (!this.chart) {return}this.chart.dispose()this.chart = null},methods: {//近七天getSevenDays() {const today = new Date();const sevenDays = [];for (let i = 0; i < 7; i++) {const date = new Date(today);date.setDate(today.getDate() - i);sevenDays.push(date.toISOString().split('T')[0]);}this.sevenDays = sevenDays;},initChart() {this.chart = echarts.init(this.$el, 'macarons')this.setOptions(this.chartData)},setOptions({ } = {}) {isPassed().then(response => {let projectList = response.data;for (let i = 0; i < projectList.length; i++) {this.passedCount.push(projectList[i].passedCount);this.failedCount.push(projectList[i].failedCount);this.updateTime.push(projectList[i].date);}console.log("updateTime");console.log(this.updateTime);this.chart.setOption({xAxis: {data: this.updateTime,boundaryGap: false,axisTick: {show: false}},grid: {left: 10,right: 10,bottom: 20,top: 30,containLabel: true},tooltip: {trigger: 'axis',axisPointer: {type: 'cross'},padding: [5, 10]},yAxis: {axisTick: {show: false}},legend: {data: ['通过人数', '不通过人数']},series: [{name: '通过人数', itemStyle: {normal: {color: '#FF005A',lineStyle: {color: '#FF005A',width: 2}}},smooth: false,type: 'line',data: this.passedCount,animationDuration: 2800,animationEasing: 'cubicInOut'},{name: '不通过人数',smooth: false,type: 'line',itemStyle: {normal: {color: '#3888fa',lineStyle: {color: '#3888fa',width: 2},areaStyle: {color: '#f3f8ff'}}},data: this.failedCount,animationDuration: 2800,animationEasing: 'quadraticOut'}]})});}}
}
</script>

在这里插入图片描述

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/pingmian/20742.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

代码随想录算法训练营Day24|216.组合总和III、17.电话号码的字母组合

组合总和III 216. 组合总和 III - 力扣&#xff08;LeetCode&#xff09; 思路和昨日的组合题类似&#xff0c;但注意对回溯算法中&#xff0c;收获时的条件需要写对&#xff0c;path的长度要为k的同时&#xff0c;path中元素总和要为n。 class Solution { public:vector<…

禁用USB端口的办法,哪一种禁用USB端口的方法好

禁用USB端口的办法&#xff0c;哪一种禁用USB端口的方法好 禁用USB端口是保护公司数据安全的一种常见做法&#xff0c;旨在防止未经授权的数据传输和潜在的恶意软件传播。以下是几种常见的禁用USB端口方法及其效果评价。 1、硬件方法&#xff1a; BIOS设置&#xff1a;通过BIO…

混合动力电动汽车介绍(一)

电动汽车发展的技术背景主要包含环境问题和能源问题两大方面。环境问题的表现形式为空气污染&#xff0c;而能源问题的表现形式为现有能源供应体系对化石燃料的过分依赖。《新能源汽车产业发展规划&#xff08;2021-2035&#xff09;》中明确我国新能源汽车技术研发的“三纵”、…

探索Python机器学习:从基础到实践

探索Python机器学习&#xff1a;从基础到实践 本文将带您从机器学习的基础知识出发&#xff0c;逐步深入到实际应用&#xff0c;帮助您掌握Python机器学习的核心技能。 一、机器学习概述 1. 什么是机器学习&#xff1f; 机器学习是一种通过分析数据来自动发现模式并做出预测…

软件架构设计属性之5:可维护性属性分析与应用

文章目录 引言一、可维护性定义和重要性1.1 定义1.2 重要性 二、可维护性关键要素2.1 模块化2.2 单一职责2.3 低耦合2.4 高内聚2.5 抽象和封装2.6 实践建议 三、设计原则3.1 开闭原则3.2 依赖倒置原则3.3 评估方法3.4 挑战与解决方案 四、实战应用总结 引言 在当今数字化飞速发…

Java学习路径图

1.学习路径 JAVA架构师学习路径 2.路径拆解 2.1 Spring 2.1.1 SpringBoot原理 SpringBoot2学习视频 SpringBoot2笔记 SpringBoo2代码 2.2.2 SpringBoot项目 《谷粒商城》学习视频

Implicit-SDF-Planner代码详解(2)

Implicit-SDF-Planner代码详解&#xff08;2&#xff09; 第三部分:轨迹优化 在获得了一条初始路径后,下一步就是在此基础上生成一条光滑、安全、动力学可行的轨迹,这就是轨迹优化要解决的问题。 让我们回到plan_manager.cpp,看看PlannerManager的generateTraj函数: void P…

IPv6在军事中的价值

计算机网络作为信息传输的主要通道&#xff0c;将在未来战场上发挥主导作用。当前的网络是基于IPv4协议构建的&#xff0c;然而&#xff0c;IPv4面临着一系列问题&#xff0c;如地址枯竭、路由瓶颈等&#xff0c;这些问题导致网络安全和服务质量难以适应军事网络的高速发展。在…

一文了解JVM面试篇(上)

Java内存区域 1、如何解释 Java 堆空间及 GC? 当通过 Java 命令启动 Java 进程的时候,会为它分配内存。内存的一部分用于创建 堆空间,当程序中创建对象的时候,就从对空间中分配内存。GC 是 JVM 内部的一 个进程,回收无效对象的内存用于将来的分配。 2、JVM 的主要组成…

前端工程化工具系列(四)—— Commitlint(v19.3.0):规范化 Git 提交

commitlint 是对 Git 提交的信息进行校验的工具。 1. 环境要求 v19 以上的 Stylelint&#xff0c;支持 Node.js 的版本为 v18 。 在命令行中输入以下内容来查看当前系统中 node 的版本。 node -vNode.js 推荐使用 v18.20.3 或者 v20.13.1。 这里使用的包管理器是 PNPM&#…

NextJs 数据篇 - 数据获取 | 缓存 | Server Actions

NextJs 数据篇 - 数据获取 | 缓存 | Server Actions 前言一. 数据获取 fetch1.1 缓存 caching① 服务端组件使用fetch② 路由处理器 GET 请求使用fetch 1.2 重新验证 revalidating① 基于时间的重新验证② 按需重新验证revalidatePathrevalidateTag 1.3 缓存的退出方式 二. Ser…

PostgreSQL的多态函数

项目中遇到一个需求,需要模拟Oracle的NVL2函数实现一个对应功能的函数 于是就写了一个自定义函数 CREATE OR REPLACE FUNCTION bkdb3.nvl2(expr anyelement, expr2 anyelement, expr3 anyelement)RETURNS anyelementLANGUAGE plpgsql AS $$ BEGINIF expr IS NOT NULL AND expr…

windows操作系统提权之服务提权实战rottenpotato

RottenPotato&#xff1a; 将服务帐户本地提权至SYSTEM load incognito list_tokens –u upload /home/kali/Desktop rottenpotato.exe . execute -Hc -f rottenpotato.exe impersonate_token "NT AUTHORITY\SYSTEM" load incognito 这条命令用于加载 Metasploi…

vue 关闭页面前释放资源

mounted() {window.addEventListener(beforeunload, e > this.handleBeforeUnload(e)) }beforeDestroy() {//监听-关闭页面的时候释放资源window.removeEventListener(beforeunload, e > this.handleBeforeUnload(e))},methods: {handleBeforeUnload(event){event.preven…

【Linux】在Windows环境下配置两台Linux机器的文件互传

相信有很多云服务器小伙伴都有想把一台linux资源传到另一台机器&#xff0c;那么该怎样实现&#xff1f; 本篇文章的演示案例都是基于centous进行传输&#xff0c;ubuntu进行接收&#xff01; 别的方法也都是一样的&#xff01; 方法一&#xff08;基于xshell进行的压缩包win…

Java项目:92 基于SSM的办公管理系统

作者主页&#xff1a;舒克日记 简介&#xff1a;Java领域优质创作者、Java项目、学习资料、技术互助 文中获取源码 基于SSM的办公管理系统 1、项目介绍 基于SSM的办公管理系统主要是对于办公用品的申领进行管理&#xff0c;系统分为三种角色&#xff0c;超级管理员、企业 职…

Python3 元组

前言 本文主要介绍Python中的元组(tuple)&#xff0c;主要内容包括 元组简介、元组特性、元组的基本操作。 文章目录 前言一、元组简介二、元组特性1、不可变性2、有序性3、异构性4、可以嵌套使用5、元组类型比列表类型更加节省内存空间 三、元组的基本操作1、创建2、索引3、…

利用WMI横向移动

一. WMI介绍和使用 1. WMI介绍 WMI是Windows在Powershell还未发布前&#xff0c;微软用来管理Windows系统的重要数据库工具&#xff0c;WMI本身的组织架构是一个数据库架构&#xff0c;WMI 服务使用 DCOM或 WinRM 协议, 在使用 wmiexec 进行横向移动时&#xff0c;windows 操…

Go_unsafe包

是什么&#xff1f;为什么&#xff1f; 如何利用unsafe包修改私有成员&#xff1f; 结构体会被分配到一块连续的内存&#xff0c;结构体的地址也代表第一个成员的地址。 如何利用unsafe包获取slice和map的长度&#xff1f; // 利用unsafe包修改私有成员 type S struct {name …

vue中使用svg图像

一 、svg图像是什么 SVG&#xff08;可缩放矢量图形&#xff09;是一种图像格式&#xff0c;它以XML文档的形式存在&#xff0c;用以描述图像中的形状、线条、文本和颜色等元素。由于其基于矢量的特性&#xff0c;SVG图像在放大或改变尺寸时能够保持图形质量不受影响。这种格式…