当前位置: 首页 > news >正文

摄影做网站百度联盟是什么

摄影做网站,百度联盟是什么,雨发建设集团有限公司网站,海口oa项目实战第十二记 1.写在前面2. 整合Echarts2.1 vue安装Echarts2.2 使用Echarts2.3 EchartsController编写2.4 Home.vue编写 总结写在最后 1.写在前面 本篇主要讲解系统整合Echarts 2. 整合Echarts 2.1 vue安装Echarts npm i echarts -S2.2 使用Echarts vue中使用echarts的…

项目实战第十二记

  • 1.写在前面
  • 2. 整合Echarts
    • 2.1 vue安装Echarts
    • 2.2 使用Echarts
    • 2.3 EchartsController编写
    • 2.4 Home.vue编写
  • 总结
  • 写在最后

1.写在前面

本篇主要讲解系统整合Echarts

2. 整合Echarts

2.1 vue安装Echarts

npm i echarts -S

2.2 使用Echarts

vue中使用echarts的demo

<template><div><div id="main" style="width: 100%; height: 500px;"></div></div>
</template><script>
import * as echarts from 'echarts'export default {name: "Home",data() {return {}},mounted() {   // 主要用于对DOM进行操作和进行一些需要DOM的逻辑处理this.initEcharts();},methods: {initEcharts() {let chartDom = document.getElementById('main');let myChart = echarts.init(chartDom);let option;option = {xAxis: {type: 'category',data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']},yAxis: {type: 'value'},series: [{data: [150, 230, 224, 218, 135, 147, 260],type: 'line'}]};myChart.setOption(option);}}
}
</script><style scoped></style>

注:可以去Echarts官网进一步实践不同类型的图表
示例地址

2.3 EchartsController编写

该接口主要统计每个季度的用户人数,然后传递数据给前端

package com.ppj.controller;import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.date.LocalDateTimeUtil;
import cn.hutool.core.date.Quarter;
import com.ppj.common.Result;
import com.ppj.entity.User;
import com.ppj.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;@RestController
@RequestMapping("/echarts")
public class EchartsController {@Autowiredprivate IUserService userService;/*** 获取每个季度的会员数* @return*/@GetMapping("/members")public Result getMembers(){List<User> userList = userService.list();int q1 = 0;int q2 = 0;int q3 = 0;int q4 = 0;for (User user : userList) {Date createTime = user.getCreateTime();// 季度Quarter quarter = DateUtil.quarterEnum(createTime);switch (quarter){case Q1:q1++;break;case Q2:q2++;break;case Q3:q3++;break;case Q4:q4++;break;default:break;}}return Result.success(CollUtil.newArrayList(q1,q2,q3,q4));}}

2.4 Home.vue编写

模拟各种统计实时展示,用折线,柱状,饼状图展示各月度会员人数

<template><div><el-row :gutter="10" style="margin-bottom: 50px;"><el-col :span="6"><el-card style="color: #409EFF;"><div><i class="el-icon-user-solid"/>用户总数</div><div style="padding: 10px 0;text-align: center;font-weight: bold;">100</div></el-card></el-col><el-col :span="6"><el-card style="color: #67C23A;"><div><i class="el-icon-s-goods"/>销售总量</div><div style="padding: 10px 0;text-align: center;font-weight: bold;">10000</div></el-card></el-col><el-col :span="6"><el-card style="color: #E6A23C;"><div><i class="el-icon-coin"/>收益总额</div><div style="padding: 10px 0;text-align: center;font-weight: bold;">999</div></el-card></el-col><el-col :span="6"><el-card style="color: #F56C6C;"><div><i class="el-icon-medal-1"/>门店总数</div><div style="padding: 10px 0;text-align: center;font-weight: bold;">1000</div></el-card></el-col></el-row><el-row><el-col :span="12"><!-- 为 ECharts 准备一个定义了宽高的 DOM --><div id="line" style="width: 600px; height: 400px"></div></el-col><el-col :span="12"><div id="pie" style="width: 600px; height: 400px"></div></el-col></el-row></div>
</template><script>
import * as echarts from 'echarts'export default {name: "Home",data() {return {}},mounted() {   // 主要用于对DOM进行操作和进行一些需要DOM的逻辑处理this.initEcharts();},methods: {initEcharts() {//页面元素渲染之后再触发let lineChartDom = document.getElementById("line");let lineChart = echarts.init(lineChartDom);let pieChartDom = document.getElementById("pie");let pieChart = echarts.init(pieChartDom);const lineOption = {title: {text: "各季度会员数量统计",subtext: "趋势图",left: "center",},xAxis: {   // 横坐标type: "category",data: ["第一季度", "第二季度", "第三季度", "第四季度"],},yAxis: {type: "value",},// 显示数据series: [{data: [],type: "line",   // 折线数据},{data: [],type: "bar",   // 柱状数据},],};this.request.get("/echarts/members").then(res => {if(res.code === "200"){// 获取数据lineOption.series[0].data =res.datalineOption.series[1].data =res.data}// 绘制图表lineChart.setOption(lineOption)})const pieOption = {title: {text: "各季度会员数量统计",subtext: "比例图",left: "center",},tooltip: {trigger: "item",},legend: {orient: "vertical",left: "left",},series: [{type: "pie",radius: "50%",data: [],emphasis: {itemStyle: {shadowBlur: 10,shadowOffsetX: 0,shadowColor: "rgba(0, 0, 0, 0.5)",},},},],};this.request.get("/echarts/members").then(res => {if (res.code === "200") {pieOption.series[0].data = [{ value: res.data[0], name: '第一季度' },{ value: res.data[1], name: '第二季度' },{ value: res.data[2], name: '第三季度' },{ value: res.data[3], name: '第四季度' }]pieChart.setOption(pieOption)}})}}
}
</script><style scoped></style>

总结

  • 这只是简单的整合echarts使用示例,后期可以根据自己的需求,看官方文档更加深入的使用echarts
  • 代码内部有详细的注释

写在最后

如果此文对您有所帮助,请帅戈靓女们务必不要吝啬你们的Zan,感谢!!不懂的可以在评论区评论,有空会及时回复。
文章会一直更新

http://www.15wanjia.com/news/50855.html

相关文章:

  • 东坑东莞微信网站建设app开发公司排行榜
  • 帮妈妈做家务作文网站影响seo排名的因素
  • 怎样免费创建网站推广下载app拿佣金
  • 政府网站建设滞后微信营销平台有哪些
  • wordpress会员认证谷歌seo课程
  • 做魔杖网站seo建站教学
  • 通达oa 做网站网络广告推广公司
  • mugeda做网站张家界网站seo
  • 网站建设公司官网seo是什么的
  • 帮人做分销网站违法么网络推广工作好吗
  • 网站源码怎么打开免费发布广告信息的网站
  • 制作网站的基本步骤是营销推广方式有哪些
  • d?t网站模版全达seo
  • 广州有哪些广告公司深圳seo优化公司
  • 网站备案号码查询seo平台有哪些
  • 万网做网站花多少钱网络营销策划包括哪些内容
  • 软件开发工程师多少钱一个月西安seo包年服务
  • 深圳自适应网站建设价格长沙网络推广外包费用
  • 网站免费建站叉手网络营销推广方案
  • 项目网络图关键路径免费seo免费培训
  • 做帖子的网站有哪些seo关键词快速排名软件
  • 中国网站建设公司有哪些方面cms建站
  • 商业网站建站目的八八网
  • 网站建设中企动力优百度推广怎么收费标准案例
  • 书店商城网站建设方案市场营销说白了就是干什么的
  • 电子商务企业网站的基本功能企业网站cms
  • 哪个网站是做红酒酒的中国搜索引擎排名
  • 西安网站优化平台链接交易网
  • 吉首公司网站找谁做网站查询关键词排名软件
  • 网站必须做301重定向吗百度收录方法