当前位置:   article > 正文

【11】数据可视化:基于 Echarts + Python 实现的动态实时大屏 - 销售指标大屏_echarts大屏网店销售

echarts大屏网店销售

目录

精彩案例汇总

效果展示

1、首先看动态效果图 

2、再看实时分片数据图

3、丰富的主题样式

一、 确定需求方案

1、确定产品上线部署的屏幕LED分辨率

2、功能模块

3、部署方式 

二、整体架构设计

三、编码实现 (基于篇幅及可读性考虑,此处展示部分关键代码)

1、前端html代码 

2、前端JS代码

产品销量分析

 利润目标达成率

3、后端python代码

四、上线运行

五、源码下载

精彩案例汇总


近年来,数据可视化大屏的出现,掀起一番又一番的浪潮,众多企业主纷纷想要打造属于自己的 “酷炫吊炸天” 的霸道总裁大屏驾驶舱。今天为大家分享的是 【 销售指标 - 数据可视化大屏解决方案】。

之前小伙伴们建议我出一些视频课程来学习Echarts,这样可以更快上手,所以我就追星赶月的录制了精彩案例汇总 ,希望小伙伴们多多支持。 

话不多说,开始分享干货,欢迎讨论!QQ微信同号: 6550523

精彩案例汇总

YYDatav的数据可视化《精彩案例汇总》_YYDataV的博客-CSDN博客

效果展示

1、首先看动态效果图 

2、再看实时分片数据图

3、丰富的主题样式

  

一、 确定需求方案

1、确定产品上线部署的屏幕LED分辨率

1280px*768px,F11全屏后占满整屏无滚动条;其它分辨率屏幕可自适应显示。

2、功能模块

  • 销量目标达成率

  • 利润目标达成率

  • 产品销量分析

  • 門店TOP

  • 3D 地图 总销量

  • 合同目标达成率

  • 成本目标达成率

  • 成本分析

  • 门店数量

3、部署方式 

  • 基于免安装可执行程序:支持Windows、Linux、Mac等各种主流操作系统;将可执行程序exe复制到服务器上即可,无需其它环境依赖;
  • 观看方式:既可在服务器上直接观看程序界面,也可远程使用浏览器打开播放,支持Chrome浏览器、360浏览器等主流浏览器。

二、整体架构设计

  1. 前端基于Echarts开源库设计,使用WebStorm编辑器;
  2. 后端基于Python Web实现,使用Pycharm编辑器;
  3. 数据传输格式:JSON;
  4. 数据源类型:目前已支持PostgreSQL、MySQL、Oracle、Microsoft SQL Server、SQLite、Excel表格等,还可以定制HTTP API接口方式或其它类型数据库。
  5. 数据更新方式:摒弃了前端页面定时拉取的方式(这种方式带来严重的资源浪费),采用后端数据实时更新,实时推送到前端展示;

三、编码实现 (基于篇幅及可读性考虑,此处展示部分关键代码)

1、前端html代码 

  1. <body background="/myimg/starfield.jpg" style="color: rgb(230, 171, 84);">
  2. <div class="container_fluid">
  3. <div class="row_fluid" id="vue_app">
  4. <div style="padding:0 0" class="col-xs-12 col-md-12">
  5. <dv-decoration-1 style="height:4%;">
  6. </dv-decoration-1>
  7. <h3 id="container_h"></h3>
  8. </div>
  9. <div style="padding:0 0" class="col-xs-12 col-md-3">
  10. <dv-border-box-1 style="height:29%;padding:0 0">
  11. <div style="height:100%;padding:5% 5% 5% 5%;" id="container_0_0"
  12. class="col-xs-12 col-md-6"></div>
  13. <div style="height:100%;padding:5% 5% 5% 5%; " id="container_0_1"
  14. class="col-xs-12 col-md-6"></div>
  15. </dv-border-box-1>
  16. <dv-border-box-1 style="height:29%;padding:0 0">
  17. <div style="height:100%;padding:5% 5% 5% 5%;" id="container_1"
  18. class="col-xs-12 col-md-12"></div>
  19. </dv-border-box-1>
  20. <dv-border-box-1 style="height:29%;padding:0 0">
  21. <div style="height:100%;padding:5% 5% 5% 5%;" id="container_2"
  22. class="col-xs-12 col-md-12"></div>
  23. </dv-border-box-1>
  24. </div>
  25. <div style="padding:0 0" class="col-xs-12 col-md-6">
  26. <dv-border-box-1 style="height:87%;padding:0 0" class="col-xs-12 col-md-12">
  27. <div style="height:100%;padding: 2% 2% 2% 2%" id="container_3"></div>
  28. <div style="position: absolute; z-index: 2; left:25%; top:10%; right: 25%; bottom: 20%; height:20%; width: 50%; ">
  29. <h3 id="container_3_top_title"> </h3>
  30. <h1 id="container_3_top"></h1>
  31. </div>
  32. </dv-border-box-1>
  33. </div>
  34. <div style="padding:0 0" class="col-xs-12 col-md-3">
  35. <dv-border-box-1 style="height:29%;padding:0 0">
  36. <div style="height:100%;padding:5% 5% 5% 5%;" id="container_4_0"
  37. class="col-xs-12 col-md-6"></div>
  38. <div style="height:100%;padding:5% 5% 5% 5%; " id="container_4_1"
  39. class="col-xs-12 col-md-6"></div>
  40. </dv-border-box-1>
  41. <dv-border-box-1 style="height:29%;padding:0 0" class="col-xs-12 col-md-12">
  42. <div style="height:100%;padding:5% 5% 5% 5%;" id="container_5"></div>
  43. </dv-border-box-1>
  44. <dv-border-box-1 style="height:29%;padding:0 0" class="col-xs-12 col-md-12">
  45. <div style="height:100%;padding:5% 5% 5% 5%;" id="container_6"></div>
  46. </dv-border-box-1>
  47. </div>
  48. </div>
  49. </div>
  50. </body>

2、前端JS代码

产品销量分析

  1. // import * as echarts from 'echarts';
  2. var idContainer_1 = "container_1";
  3. var chartDom = document.getElementById(idContainer_1);
  4. function initEchart_1(){
  5. var myChart = echarts.init(chartDom, window.gTheme);
  6. var option = {
  7. title: {
  8. text: "产品销量分析",
  9. left: "left",
  10. textStyle: {
  11. color: "#3690be",
  12. fontSize: "10",
  13. },
  14. },
  15. tooltip: {
  16. trigger: "item",
  17. formatter: "{a} <br/>{b}: {c} 百万",
  18. position: function (p) {
  19. //其中p为当前鼠标的位置
  20. return [p[0] + 10, p[1] - 10];
  21. },
  22. },
  23. legend: {
  24. data: ["成本", "利润"],
  25. textStyle: {
  26. color: "rgba(255,255,255,.5)",
  27. fontSize: "10",
  28. },
  29. // 距离顶部边框的相对距离,太近压到了title
  30. top: "10%",
  31. // orient:"vertical"
  32. },
  33. grid: {
  34. left: "3%",
  35. right: "4%",
  36. bottom: "3%",
  37. // 距离顶部边框的相对距离,太近压到了legend
  38. top: "30%",
  39. containLabel: true,
  40. },
  41. xAxis: {
  42. name: '百万',
  43. type: "value",
  44. axisLabel: {
  45. textStyle: {
  46. color: "rgba(255,255,255,.5)",
  47. fontSize: 10,
  48. },
  49. },
  50. axisLine: {
  51. lineStyle: {
  52. color: "rgba(255,255,255,.2)",
  53. },
  54. },
  55. splitLine: {
  56. lineStyle: {
  57. color: "rgba(255,255,255,.1)",
  58. },
  59. },
  60. },
  61. yAxis: {
  62. type: "category",
  63. data: ["Mate", "P", "Nova", "畅享"],
  64. axisLabel: {
  65. textStyle: {
  66. color: "rgba(255,255,255,.5)",
  67. fontSize: 10,
  68. },
  69. },
  70. axisLine: {
  71. lineStyle: {
  72. color: "rgba(255,255,255,.2)",
  73. },
  74. },
  75. splitLine: {
  76. lineStyle: {
  77. color: "rgba(255,255,255,.1)",
  78. },
  79. },
  80. },
  81. series: [
  82. {
  83. name: "成本",
  84. type: "bar",
  85. stack: "total",
  86. label: {
  87. show: true,
  88. },
  89. emphasis: {
  90. focus: "series",
  91. },
  92. data: [334, 390, 330, 320],
  93. },
  94. {
  95. name: "利润",
  96. type: "bar",
  97. stack: "total",
  98. label: {
  99. show: true,
  100. },
  101. emphasis: {
  102. focus: "series",
  103. },
  104. data: [134, 90, 230, 210],
  105. },
  106. ],
  107. };
  108. // 使用刚指定的配置项和数据显示图表。
  109. myChart.setOption(option);
  110. window.addEventListener("resize", function () {
  111. myChart.resize();
  112. });
  113. }
  114. function asyncData_1() {
  115. $.getJSON("json/bar_stacked.json").done(function (data) {
  116. var myChart = echarts.init(document.getElementById(idContainer_1));
  117. myChart.setOption({
  118. series: [{ data: data }],
  119. });
  120. }); //end $.getJSON}
  121. }
  122. initEchart_1();
  123. asyncData_1();

 利润目标达成率

  1. var idContainer_0_1 = 'container_0_1'
  2. var chartDom_0_1 = document.getElementById(idContainer_0_1);
  3. function initEchart_0_1() {
  4. var myChart = echarts.init(chartDom_0_1, window.gTheme);
  5. var option = {
  6. title: {
  7. text: '利润目标达成率',
  8. left: 'left',
  9. textStyle: {
  10. color: '#3690be',
  11. fontSize: '10'
  12. }
  13. },
  14. series: [{
  15. type: 'gauge',
  16. progress: {
  17. show: true,
  18. width: 12
  19. },
  20. axisLine: {
  21. lineStyle: {
  22. width: 12
  23. }
  24. },
  25. axisTick: {
  26. show: false,
  27. },
  28. splitLine: {
  29. show: false,
  30. },
  31. axisLabel: {
  32. show: false,
  33. },
  34. pointer:{
  35. show: false,
  36. },
  37. anchor:{
  38. show: false,
  39. },
  40. title:{
  41. show: false,
  42. },
  43. detail: {
  44. valueAnimation: true,
  45. offsetCenter: [0, 0],
  46. formatter: '{value}%',
  47. },
  48. data: []
  49. }]
  50. };
  51. // 使用刚指定的配置项和数据显示图表。
  52. myChart.setOption(option);
  53. window.addEventListener("resize", function () {
  54. myChart.resize();
  55. });
  56. }
  57. function asyncData_0_1() {
  58. $.getJSON('json/gauge_benefit_rate.json').done(function (data) {
  59. var myChart = echarts.init(document.getElementById(idContainer_0_1));
  60. myChart.setOption({
  61. series: [{ data: data }],
  62. });
  63. });//end $.getJSON}
  64. }
  65. initEchart_0_1();
  66. asyncData_0_1();

3、后端python代码

  1. # -*- coding:utf-8 -*-
  2. import io
  3. import os
  4. import sys
  5. import urllib
  6. import json
  7. from http.server import HTTPServer, SimpleHTTPRequestHandler, ThreadingHTTPServer
  8. ip = "localhost" # 监听IP,配置项
  9. port = 8811 # 监听端口,配置项
  10. index_url = "http://%s:%d/index.html" %(ip, port) # 监听主页url,配置项
  11. class MyRequestHandler(SimpleHTTPRequestHandler):
  12. protocol_version = "HTTP/1.0"
  13. server_version = "PSHS/0.1"
  14. sys_version = "Python/3.7.x"
  15. target = "./" # 监听目录,配置项
  16. def do_GET(self):
  17. if self.path.find("/json/") > 0:
  18. print(self.path)
  19. req = {"success": "true"}
  20. self.send_response(200)
  21. self.send_header("Content-type", "json")
  22. self.end_headers()
  23. with open(self.path, 'r', encoding="utf-8") as f:
  24. data = json.load(f)
  25. rspstr = json.dumps(data)
  26. self.wfile.write(rspstr.encode("utf-8"))
  27. else:
  28. SimpleHTTPRequestHandler.do_GET(self);
  29. def do_POST(self):
  30. if self.path == "/signin":
  31. print("postmsg recv, path right")
  32. else:
  33. print("postmsg recv, path error")
  34. data = self.rfile.read(int(self.headers["content-length"]))
  35. data = json.loads(data)
  36. self.send_response(200)
  37. self.send_header("Content-type", "text/html")
  38. self.end_headers()
  39. rspstr = "recv ok, data = "
  40. rspstr += json.dumps(data, ensure_ascii=False)
  41. self.wfile.write(rspstr.encode("utf-8"))
  42. def HttpServer():
  43. try:
  44. server = HTTPServer((ip, port), MyRequestHandler)
  45. listen = "http://%s:%d" %(ip, port)
  46. print("服务器监听地址: ", listen)
  47. server.serve_forever()
  48. except ValueError as e:
  49. print("Exception", e)
  50. server.socket.close()
  51. if __name__ == "__main__":
  52. HttpServer()

四、上线运行

五、源码下载

11【源码】数据可视化:基于Echarts+Python实现的动态实时大屏范例-销售指标.zip-企业管理文档类资源-CSDN下载

精彩案例汇总

YYDatav的数据可视化《精彩案例汇总》_YYDataV的博客-CSDN博客

本次分享结束,欢迎讨论!QQ微信同号: 6550523

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/IT小白/article/detail/408938
推荐阅读
相关标签
  

闽ICP备14008679号