栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 前沿技术 > 大数据 > 大数据系统

springboot,vue,echart,mysql数据可视化-男女比例图-需求数据不存储在数据库中

springboot,vue,echart,mysql数据可视化-男女比例图-需求数据不存储在数据库中

由于自己的项目需要大数据可视化,所以就得学习,对于数据的处理就是一个难事,我在想如何对男女这个数据进行处理,因为两个数据不可能专门为此数据建一张表去存储,所以我就想到需要hashmap这种形式去存储,应为hashmap的特性,所以我将hashmap的键值对转换为list,用户的性别男女是存储在用户表中的,需要使用sql去计算男女人数。代码如下:

后端代码:
controller:

package com.controller;

import com.alibaba.fastjson.JSON;
import com.entity.Problem;
import com.entity.R;
import com.github.pagehelper.PageInfo;
import com.service.DrugInfoService;
import com.service.YonghuService;
import com.service.impl.YonghuServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.*;

@RequestMapping("/dashuju")
@RestController
public class DashujuController {
    @Autowired
    private YonghuService yonghuService;

    @RequestMapping("/getnannv")
    public R list2() {
        String sex="男";
        String sex1="女";
        HashMap map=new HashMap<>();
        List name=new ArrayList<>();
        List value=new ArrayList<>();
        int man=yonghuService.getyonghunan(sex);
        int woman=yonghuService.getyonghunan(sex1);
        name.add(sex);
        name.add(sex1);
        value.add(man);
        value.add(woman);
        map.put("name",name);
        map.put("value",value);
        System.out.println(map);
        System.out.println(map);
        return R.ok().put("data",map);
    }
}



Dao层
部分代码:

//   大数据展示数据
   int getyonghunan(String xingbie);

mybatis.xml

用于统计数据的男女总数


		SELECT COUNT(*)
		FROM yonghu AS s
		WHERe s.xingbie =#{xingbie}
	

前端核心代码:
对于echart的安装需要自己去安装,我就不在写了










大功完成,哈哈哈,点个赞在走呗

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/706203.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号