企业管理系统定制开发Vue 之 echarts 图表数据可视化常用的一些图表/动态图表/3D图表的简单整理

Vue 之 echarts 企业管理系统定制开发图表常用的一些图表/动态图表/3D企业管理系统定制开发图表的简单整理

目录

(含代码)


一、简单介绍

Vue 企业管理系统定制开发开发的一些知识整理,企业管理系统定制开发方便后期遇到类似的问题,企业管理系统定制开发能够及时查阅使用。

本节介绍,vue 中添加 echarts ,然后在 vue 企业管理系统定制开发中简单使用一些 echarts企业管理系统定制开发中常用的图表,企业管理系统定制开发包括一些动态的图表、3D的图表等 ,如果有不足之处,欢迎指出,或者你有更好的方法,欢迎留言。

ECharts,一个使用 JavaScript 实现的开源可视化库,可以流畅的运行在 PC 和移动设备上,兼容当前绝大部分浏览器(IE9/10/11,Chrome,Firefox,Safari等),底层依赖矢量 ZRender,提供直观,交互丰富,可高度个性化定制的数据可视化图表。

ECharts 提供了常规的折线图、柱状图、散点图、饼图、K线图,用于统计的盒形图,用于地理数据可视化的地图、热力图、线图,用于关系数据可视化的关系图、treemap、旭日图,多维数据可视化的平行坐标,还有用于 BI 的漏斗图,仪表盘,并且支持图与图之间的混搭。

ECharts 针对移动端交互做了细致的优化,例如移动端小屏上适于用手指在坐标系中进行缩放、平移。 PC 端也可以用鼠标在图中进行缩放(用鼠标滚轮)、平移等。

Echarts 官网文档:

Echarts 官网示例:

操作环境:

  • win 10
  • node v14.20.0
  • npm 8.5.3
  • @vue/cli 5.0.6
  • vue 2.6.14
  • echarts 5.3.3
  • echarts-liquidfill 3.1.0
  • echarts-gl 2.0.9

二、效果预览

(有若干图表其实是动态的)

三、注意事项

1、使用水球图时(echarts-liquidfil插件),echarts-liquidfill@3 版本匹配 echarts@5 版本,echarts-liquidfill@2 版本匹配 echarts@4 版本

  1. npm引入:
  2. npm install echarts
  3. npm install echarts-liquidfill
  4. cdn引入:
  5. <script src='echarts.js'></script>
  6. <script src='echarts-liquidfill.js'></script>

2、使用 echarts 3D 的时候,同时也注意下版本匹配,echarts-gl@2 版本匹配 echarts@5 版本,echarts-gl@1 版本匹配 echarts@4 版本

四、各种 echarts 图表(含代码)

1、水球图

注意:除了需要 echarts,还要 echarts-liquidfil 配合

  1. <template>
  2. <div class="wrap-container">
  3. <div class="wp-content">
  4. <div class="wp-title">水球图</div>
  5. <div class="wp-body">
  6. <div class="wrap-container">
  7. <div class="chartsdom" id='chart-polo'></div>
  8. </div>
  9. </div>
  10. </div>
  11. </div>
  12. </template>
  13. <script>
  14. // 注意 echartsLiquidfill ver3对应echarts 版本 5;(echartsLiquidfill ver2对应echarts 版本 4)
  15. // eslint-disable-next-line
  16. import echartsLiquidfill from "echarts-liquidfill";
  17. export default {
  18. name: 'water-polo',
  19. data() {
  20. return {
  21. option: null
  22. }
  23. },
  24. mounted() {
  25. this.getEchart()
  26. },
  27. methods: {
  28. getEchart() {
  29. // 获取渲染元素,创建 chart
  30. let myChart = this.$echarts.init(document.getElementById('chart-polo'))
  31. this.option = {
  32. series: [{
  33. // 水球图类型
  34. type: 'liquidFill',
  35. // 名称
  36. name: "测试",
  37. // 水波值,可多个
  38. data: [0.75],
  39. // 球相对渲染元素的宽高的半径比
  40. radius: '75%',
  41. // 水波颜色
  42. color: ['#00B9F5'],
  43. // 水波背景的样式
  44. backgroundStyle: {
  45. // 背景颜色
  46. color: 'rgba(0,0,0,0.5)',
  47. // 边框颜色
  48. borderColor: '#007bff',
  49. // 边框宽度
  50. borderWidth: 3,
  51. shadowColor: 'rgba(0,123,225,.4)',
  52. shadowBlur: 20
  53. },
  54. // 是否显示外轮廓
  55. outline: {
  56. show: true
  57. },
  58. }],
  59. // 鼠标进入是否显示提示
  60. tooltip:{
  61. show: true
  62. }
  63. }
  64. myChart.setOption(this.option, true)
  65. window.addEventListener('resize', () => {
  66. myChart.resize()
  67. })
  68. // 第二种 水球图
  69. // const dataOption = {
  70. // value: 0.30,
  71. // itemStyle: { //渐变水球颜色
  72. // color: new this.$echarts.graphic.LinearGradient(1, 0, 0, 0, [{
  73. // offset: 0,
  74. // color: "pink",
  75. // },
  76. // {
  77. // offset: 1,
  78. // color: "skyblue",
  79. // },
  80. // ]),
  81. // },
  82. // };
  83. // this.option = {
  84. // series: [{
  85. // type: "liquidFill",
  86. // // 这三个属性值设置为false静止的波浪
  87. // // waveAnimation: false, //静止的波浪效果
  88. // animationDuration: 1000, // 波浪初始上涨时间
  89. // // eslint-disable-next-line
  90. // // animationDurationUpdate: 0,//静止的波浪效果
  91. // // 这三个属性值设置为false静止的波浪
  92. // amplitude: "5%", //振幅波浪大小
  93. // name: "一级预警",
  94. // data: [dataOption],
  95. // waveLength: "60%", //波浪长度
  96. // // eslint-disable-next-line
  97. // outline: {
  98. // //隐藏轮廓
  99. // show: false,
  100. // },
  101. // label: {
  102. // //字体内容、字体颜色、字体大小属性
  103. // formatter: "测试",
  104. // color: "#fff",
  105. // fontSize: 30,
  106. // },
  107. // backgroundStyle: {
  108. // //水球图背景
  109. // color: "#101fff",
  110. // },
  111. // // color: ["#F87900"],
  112. // }, ],
  113. // tooltip: {
  114. // //鼠标滑过展示数据
  115. // show: true,
  116. // },
  117. // };
  118. // myChart.setOption(this.option);
  119. }
  120. }
  121. }
  122. </script>
  123. <style lang="scss" scoped>
  124. .wp-title{
  125. text-align: center;
  126. color: white;
  127. }
  128. .wrap-container {
  129. width: 400px;
  130. height: 400px;
  131. .chartsdom {
  132. width: 100%;
  133. height: 100%;
  134. }
  135. }
  136. </style>

2、滚动弧线图

 

  1. <template>
  2. <div class="wrap-container ra-container">
  3. <div class="ra-content">
  4. <div class="ra-title">滚动弧线图</div>
  5. <div class="ra-body">
  6. <div class="wrap-container">
  7. <div class="chartsdom" id='chart-rollArc'></div>
  8. </div>
  9. </div>
  10. </div>
  11. </div>
  12. </template>
  13. <script>
  14. export default {
  15. name: 'roll-arcline',
  16. data() {
  17. return {
  18. option: null,
  19. xIndex: 0,
  20. timer: null,
  21. xData: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],
  22. yData: [54, 86, 46, 77, 96, 89, 88, 23, 38, 3, 66, 98]
  23. }
  24. },
  25. mounted() {
  26. this.getEchart()
  27. },
  28. methods: {
  29. getEchart() {
  30. // 图标渲染体
  31. const chartRollArc = document.getElementById('chart-rollArc')
  32. // 初始化图表
  33. let myChart = this.$echarts.init(chartRollArc)
  34. this.option = {
  35. tooltip: {
  36. trigger: 'axis',
  37. showContent: true,
  38. axiosPointer: {
  39. type: 'shadow',
  40. shadowStyle: {
  41. color: new this.$echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  42. offset: 1,
  43. color: '#5d83ff'
  44. },
  45. {
  46. offset: 0,
  47. color: 'rgba(255,255,255,0)'
  48. }
  49. ])
  50. }
  51. },
  52. // 重新构造图标信息显示(不写会有默认的格式)
  53. formatter: (params) => {
  54. // console.log(params)
  55. params = params[0]
  56. if (params.seriesIndex === 0)
  57. // console.log(' origin '+ this.xIndex)
  58. this.xIndex = parseInt(params.name) - 1
  59. // console.log(' fuzhi '+ this.xIndex)
  60. return params.name + '月</br>' + params.seriesName + ':' + params.value + ' 人'
  61. },
  62. },
  63. color: ['#5d83ff'],
  64. grid: {
  65. top: 30,
  66. left: 30,
  67. right: 20,
  68. bottom: 20,
  69. containerLabel: true
  70. },
  71. xAxis: {
  72. type: 'category',
  73. data: this.xData,
  74. boundaryGap: false,
  75. axisTick: {
  76. show: false
  77. },
  78. axisLabel: {
  79. formatter: '{value} 月'
  80. },
  81. axisLine: {
  82. lineStyle: {
  83. color: '#999'
  84. }
  85. }
  86. },
  87. yAxis: {
  88. type: 'value',
  89. axisLine: {
  90. show: false,
  91. lineStyle: {
  92. color: '#999'
  93. }
  94. },
  95. },
  96. series: [{
  97. name: '人数',
  98. type: 'line',
  99. data: this.yData,
  100. symbolSize: 10,
  101. itemStyle: {
  102. opacity: 0,
  103. },
  104. emphasis: {
  105. label: {
  106. show: true,
  107. color: '#fff',
  108. fontSize: 20
  109. },
  110. itemStyle: {
  111. color: '#5d83ff',
  112. borderColor: '#fff',
  113. borderWidth: 2,
  114. opacity: 1
  115. },
  116. },
  117. areaStyle: {
  118. normal: {
  119. color: new this.$echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  120. offset: 0,
  121. color: '#5d83ff'
  122. }, {
  123. offset: 1,
  124. color: 'rgba(0, 0, 0, 0)'
  125. }]),
  126. }
  127. },
  128. smooth: true,
  129. }]
  130. }
  131. // 绘制图表
  132. myChart.setOption(this.option, true);
  133. // 监听窗口变化
  134. window.addEventListener('resize', () => {
  135. myChart.resize();
  136. });
  137. // 开启自动显示信息
  138. this.startChartAutoShowTip(myChart)
  139. // 鼠标进入停止自动显示信息
  140. chartRollArc.onmouseover = () => {
  141. // console.log('mouseover')
  142. // alert('mouseover')
  143. this.stopChartAutoShowTip()
  144. }
  145. // 退出 chartRollArc 继续自动显示信息
  146. chartRollArc.onmouseout = () => {
  147. // console.log('mouseout')
  148. // alert('mouseout')
  149. this.startChartAutoShowTip(myChart);
  150. }
  151. },
  152. /**
  153. * 自动显示图标信息函数
  154. * @param {Object} myChart
  155. */
  156. startChartAutoShowTip(myChart) {
  157. this.stopChartAutoShowTip()
  158. this.timer = setInterval(() => {
  159. // 显示图标信息
  160. myChart.dispatchAction({
  161. type: 'showTip',
  162. seriesIndex: 0,
  163. dataIndex: this.xIndex
  164. });
  165. this.xIndex++;
  166. // console.log(this.xIndex)
  167. if (this.xIndex > this.yData.length) {
  168. this.xIndex = 0;
  169. }
  170. }, 1000);
  171. },
  172. /**
  173. * 停止自动显示图标信息函数
  174. */
  175. stopChartAutoShowTip() {
  176. if (this.timer != null) {
  177. clearInterval(this.timer)
  178. this.timer = null
  179. }
  180. }
  181. },
  182. beforeDestroy() {
  183. // 销毁自动显示信息
  184. this.stopChartAutoShowTip()
  185. }
  186. }
  187. </script>
  188. <style lang='scss' scoped>
  189. /* 标题居中 */
  190. .ra-title {
  191. text-align: center;
  192. color: white;
  193. }
  194. /* 内容宽高 */
  195. .wrap-container {
  196. width: 895px;
  197. height: 400px;
  198. .chartsdom {
  199. width: 100%;
  200. height: 90%;
  201. }
  202. }
  203. </style>

3、旋转饼状图

  1. <template>
  2. <div class="wrap-container sn-container">
  3. <div class="sn-content">
  4. <div class="sn-title">旋转的饼状图</div>
  5. <div class="sn-body">
  6. <div class="wrap-container">
  7. <div class="pie">
  8. <div class="pies pie1"></div>
  9. <div class="pies pie2"></div>
  10. <div class="pies pie3"></div>
  11. <div class="pie4"></div>
  12. <div class="chartsdom" id='chart-pie'></div>
  13. </div>
  14. </div>
  15. </div>
  16. </div>
  17. </div>
  18. </template>
  19. <script>
  20. export default {
  21. name: 'rotate-pie',
  22. data() {
  23. return {
  24. }
  25. },
  26. mounted() {
  27. this.getEchart()
  28. },
  29. methods: {
  30. getEchart() {
  31. let myChart = this.$echarts.init(document.getElementById('chart-pie'));
  32. this.option = {
  33. tooltip: {
  34. trigger: 'item',
  35. formatter: '{a} <br/>{b} : {c} ({d}%)',
  36. },
  37. legend: {
  38. show: true,
  39. orient: 'vertical',
  40. left: 'center',
  41. top: 'middle',
  42. data: ['内存', '存储'],
  43. textStyle: {
  44. color: '#4ce5ff',
  45. fontSize: 14,
  46. },
  47. itemWidth: 20,
  48. itemHeight: 10
  49. },
  50. label: {
  51. normal: {
  52. show: false
  53. },
  54. },
  55. labelLine: {
  56. normal: {
  57. show: false
  58. }
  59. },
  60. series: [{
  61. name: '磁盘空间',
  62. type: 'pie',
  63. radius: [60, 110],
  64. center: ['50%', '50%'],
  65. roseType: 'area',
  66. label: {
  67. show: false
  68. },
  69. emphasis: {
  70. label: {
  71. show: false
  72. }
  73. },
  74. data: [{
  75. value: 6.5,
  76. name: '内存',
  77. itemStyle: {
  78. normal: {
  79. color: new this.$echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  80. offset: 0,
  81. color: '#387ed3'
  82. }, {
  83. offset: 1,
  84. color: '#bc8b68'
  85. }])
  86. }
  87. }
  88. }, {
  89. value: 3.5,
  90. name: '存储',
  91. itemStyle: {
  92. normal: {
  93. color: new this.$echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  94. offset: 0,
  95. color: '#188bfd'
  96. }, {
  97. offset: 1,
  98. color: '#51eeff'
  99. }])
  100. }
  101. }
  102. }, {
  103. value: 3,
  104. name: '其他',
  105. itemStyle: {
  106. normal: {
  107. color: 'rgba(0, 0, 106, 1)'
  108. }
  109. }
  110. }, {
  111. value: 0,
  112. name: '其他1',
  113. itemStyle: {
  114. normal: {
  115. color: 'rgba(0, 0, 0, 0)'
  116. }
  117. }
  118. }, {
  119. value: 0,
  120. name: '其他2',
  121. itemStyle: {
  122. normal: {
  123. color: 'rgba(0, 0, 0, 0)'
  124. }
  125. }
  126. }, {
  127. value: 0,
  128. name: '其他3',
  129. itemStyle: {
  130. normal: {
  131. color: 'rgba(0, 0, 0, 0)'
  132. }
  133. }
  134. }]
  135. }]
  136. }
  137. myChart.setOption(this.option, true);
  138. window.addEventListener('resize', () => {
  139. myChart.resize();
  140. });
  141. }
  142. }
  143. }
  144. </script>
  145. <style lang="scss" scoped>
  146. .sn-title {
  147. text-align: center;
  148. color: white;
  149. }
  150. .sn-container{
  151. border:5px solid aqua;
  152. border-radius: 25px;
  153. }
  154. .wrap-container {
  155. background: 'rgba(1,1,1,0)';
  156. width: 432px;
  157. height: 400px;
  158. .chartsdom {
  159. width: 100%;
  160. height: 100%;
  161. }
  162. .pie {
  163. position: relative;
  164. top: 0;
  165. width: 100%;
  166. height: 100%;
  167. .pies {
  168. width: 100%;
  169. height: 100%;
  170. top: 0;
  171. left: 0;
  172. position: absolute;
  173. background-repeat: no-repeat;
  174. background-position: center center;
  175. }
  176. .pie1 {
  177. background-image: url(../../assets/img/whcircle.png);
  178. animation: mymove 20s linear infinite;
  179. -webkit-animation: mymove 20s linear infinite;
  180. }
  181. .pie2 {
  182. background-image: url(../../assets/img/circle2.png);
  183. animation: moveto 20s linear infinite;
  184. -webkit-animation: moveto 20s linear infinite;
  185. }
  186. .pie3 {
  187. background-image: url(../../assets/img/inner.png);
  188. }
  189. // 分割线 内存/存储
  190. .pie4 {
  191. position: absolute;
  192. top: 50%;
  193. left: 36%;
  194. width: 76px;
  195. height: 1px;
  196. background: linear-gradient(to right, rgb(31, 38, 103), rgb(90, 250, 253), rgb(31, 38, 103));
  197. }
  198. }
  199. }
  200. /**
  201. * animation 动画
  202. */
  203. @-webkit-keyframes mymove {
  204. 0% {
  205. -webkit-transform-origin: center;
  206. transform-origin: center;
  207. -webkit-transform: rotate(0deg);
  208. transform: rotate(0deg)
  209. }
  210. 100%{
  211. -webkit-transform-origin: center;
  212. transform-origin: center;
  213. -webkit-transform: rotate(360deg);
  214. transform: rotate(360deg);
  215. }
  216. }
  217. @keyframes mymove{
  218. 0% {
  219. -webkit-transform-origin: center;
  220. transform-origin: center;
  221. -webkit-transform: rotate(0deg);
  222. transform: rotate(0deg);
  223. }
  224. 100%{
  225. -webkit-transform-origin: center;
  226. transform-origin: center;
  227. -webkit-transform: rotate(360deg);
  228. transform: rotate(360deg);
  229. }
  230. }
  231. @-webkit-keyframes moveto {
  232. 0% {
  233. -webkit-transform-origin: center;
  234. transform-origin: center;
  235. -webkit-transform: rotate(0deg);
  236. transform: rotate(0deg)
  237. }
  238. 100%{
  239. -webkit-transform-origin: center;
  240. transform-origin: center;
  241. -webkit-transform: rotate(-360deg);
  242. transform: rotate(-360deg);
  243. }
  244. }
  245. @keyframes moveto{
  246. 0% {
  247. -webkit-transform-origin: center;
  248. transform-origin: center;
  249. -webkit-transform: rotate(0deg);
  250. transform: rotate(0deg);
  251. }
  252. 100%{
  253. -webkit-transform-origin: center;
  254. transform-origin: center;
  255. -webkit-transform: rotate(-360deg);
  256. transform: rotate(-360deg);
  257. }
  258. }
  259. </style>

4、环状饼图

  1. <template>
  2. <div class="wrap-container sn-container">
  3. <div class="sn-content">
  4. <div class="sn-title">环形饼图</div>
  5. <div class="sn-body">
  6. <div class="wrap-container ring-pie">
  7. <div class="back-chart">
  8. <svg width="100%" height="100%" viewBox="0 0 150 150" version="1.1"
  9. xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
  10. <path id="svg_2"
  11. d="m3,75c0,-39.77901 32.22099,-72 72,-72c39.77901,0 72,32.22099 72,72c0,39.77901 -32.22099,72 -72,72c-39.77901,0 -72,-32.22099 -72,-72z"
  12. stroke="#2de6af" fill-opacity="null" fill="none"></path>
  13. </svg>
  14. </div>
  15. <div class="chartsdom" id="chart_rp"></div>
  16. <div class="arrow-cir1">
  17. <div class="arrow-cir11"></div>
  18. </div>
  19. <div class="arrow-cir2">
  20. <div class=" arrow-cir22"></div>
  21. </div>
  22. </div>
  23. </div>
  24. </div>
  25. </div>
  26. </template>
  27. <script>
  28. export default {
  29. name: 'ring-pie',
  30. mounted() {
  31. this.getEchart();
  32. },
  33. methods: {
  34. getEchart() {
  35. let myChart = this.$echarts.init(document.getElementById('chart_rp'));
  36. this.option = {
  37. tooltip:{
  38. show:true
  39. },
  40. series: [{
  41. name: '环形饼图',
  42. type: 'pie',
  43. radius: ['68%', '80%'],
  44. hoverAnimation: true,
  45. avoidLabelOverlap: false,
  46. label: {
  47. show: false,
  48. position: 'center'
  49. },
  50. emphasis: {
  51. label: {
  52. show: true
  53. }
  54. },
  55. labelLine: {
  56. show: true
  57. },
  58. data: [{
  59. value: 6,
  60. name: '区块链',
  61. itemStyle: {
  62. normal: {
  63. color: new this.$echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  64. offset: 0,
  65. color: '#6984fe'
  66. }, {
  67. offset: 1,
  68. color: '#24d1fd'
  69. }])
  70. }
  71. }
  72. }, {
  73. value: 4,
  74. name: '大数据',
  75. itemStyle: {
  76. normal: {
  77. color: '#ee2'
  78. }
  79. }
  80. }]
  81. }]
  82. }
  83. myChart.setOption(this.option, true);
  84. window.addEventListener('resize', () => {
  85. myChart.resize();
  86. });
  87. }
  88. },
  89. }
  90. </script>
  91. <style lang="scss" scoped>
  92. .sn-title {
  93. text-align: center;
  94. color: white;
  95. }
  96. .sn-container {
  97. width: 432px;
  98. height: 400px;
  99. border: 5px solid aqua;
  100. border-radius: 25px;
  101. }
  102. .wrap-container {
  103. position: relative;
  104. width: 432px;
  105. height: 400px;
  106. .back-chart {
  107. position: absolute;
  108. top: 0;
  109. left: 0;
  110. right: 0;
  111. bottom: 0;
  112. margin: auto;
  113. width: 300px;
  114. height: 300px;
  115. background: url(../../assets/img/back_chart.png) no-repeat center;
  116. }
  117. .chartsdom {
  118. position: absolute;
  119. top: 0;
  120. left: 0;
  121. right: 0;
  122. bottom: 0;
  123. margin: auto;
  124. width: 300px;
  125. height: 300px;
  126. z-index: 9999;
  127. }
  128. .arrow-cir1 {
  129. // border: 5px solid red;
  130. // border-radius: 25px;
  131. width: 300px;
  132. height: 300px;
  133. offset-distance: 0%;
  134. position: absolute;
  135. top: 0;
  136. left: 0;
  137. right: 0;
  138. bottom: 0;
  139. margin: auto;
  140. -webkit-animation: arrow-cir1 5s linear infinite;
  141. animation: arrow-cir1 5s linear infinite;
  142. .arrow-cir11 {
  143. position: absolute;
  144. width: 15px;
  145. height: 15px;
  146. top: 0.5%;
  147. left: 50%;
  148. background: url(../../assets/img/icon_04.png) no-repeat 50% 50%;
  149. background-color: blue;
  150. }
  151. }
  152. .arrow-cir2 {
  153. // border: 5px solid red;
  154. // border-radius: 25px;
  155. width: 300px;
  156. height: 300px;
  157. offset-distance: 0%;
  158. position: absolute;
  159. top: 0;
  160. left: 0;
  161. right: 0;
  162. bottom: 0;
  163. margin: auto;
  164. -webkit-animation: arrow-cir2 5s linear infinite;
  165. animation: arrow-cir2 5s linear infinite;
  166. .arrow-cir22 {
  167. position: absolute;
  168. width: 15px;
  169. height: 15px;
  170. top: 0.5%;
  171. left: 50%;
  172. background: url(../../assets/img/icon_04.png) no-repeat 50% 50%;
  173. background-color: yellow;
  174. }
  175. }
  176. }
  177. @-webkit-keyframes arrow-cir1{
  178. 0%{
  179. -webkit-transform-origin: center;
  180. transform-origin: center;
  181. -webkit-transform: rotate(0deg);
  182. transform: rotate(0deg)
  183. }
  184. 100% {
  185. -webkit-transform-origin: center;
  186. transform-origin: center;
  187. -webkit-transform: rotate(360deg);
  188. transform: rotate(360deg);
  189. }
  190. }
  191. @keyframes arrow-cir1{
  192. 0%{
  193. -webkit-transform-origin: center;
  194. transform-origin: center;
  195. -webkit-transform: rotate(0deg);
  196. transform: rotate(0deg)
  197. }
  198. 100% {
  199. -webkit-transform-origin: center;
  200. transform-origin: center;
  201. -webkit-transform: rotate(360deg);
  202. transform: rotate(360deg);
  203. }
  204. }
  205. @-webkit-keyframes arrow-cir2{
  206. 0%{
  207. -webkit-transform-origin: center;
  208. transform-origin: center;
  209. -webkit-transform: rotate(0deg);
  210. transform: rotate(0deg)
  211. }
  212. 100% {
  213. -webkit-transform-origin: center;
  214. transform-origin: center;
  215. -webkit-transform: rotate(-360deg);
  216. transform: rotate(-360deg);
  217. }
  218. }
  219. @keyframes arrow-cir2{
  220. 0%{
  221. -webkit-transform-origin: center;
  222. transform-origin: center;
  223. -webkit-transform: rotate(0deg);
  224. transform: rotate(0deg)
  225. }
  226. 100% {
  227. -webkit-transform-origin: center;
  228. transform-origin: center;
  229. -webkit-transform: rotate(-360deg);
  230. transform: rotate(-360deg);
  231. }
  232. }
  233. </style>

 5、彩虹饼状图

 

  1. <template>
  2. <div class="wrap-container sn-container">
  3. <div class="sn-content">
  4. <div class="sn-title">彩虹饼状图</div>
  5. <div class="sn-body">
  6. <div class="wrap-container">
  7. <div class="chartsdom" id='chart-rainbow'></div>
  8. <div class="preinfo" v-for='(item,ind) in arrData' :key='ind' :class="`preinfo${ind}`">
  9. <span>{{ item.percent }}%</span>
  10. <span>{{ item.name }}</span>
  11. </div>
  12. <div class="preinfos" :class="`pre${i}`" v-for="(v, i) in arrData" :key='i'>
  13. <span></span>
  14. <span></span>
  15. </div>
  16. </div>
  17. </div>
  18. </div>
  19. </div>
  20. </template>
  21. <script>
  22. export default {
  23. name: 'ranbow-pies',
  24. data() {
  25. return {
  26. option: null,
  27. arrData: [{
  28. name: '食品类',
  29. percent: 73
  30. }, {
  31. name: '工业类',
  32. percent: 20
  33. }, {
  34. name: '医疗类',
  35. percent: 32
  36. }, {
  37. name: '政务类',
  38. percent: 60
  39. }, {
  40. name: '金融类',
  41. percent: 14
  42. }]
  43. }
  44. },
  45. mounted() {
  46. this.getEchart();
  47. },
  48. methods: {
  49. getEchart() {
  50. let myChart = this.$echarts.init(document.getElementById('chart-rainbow'));
  51. let itemStyle = {
  52. normal: {
  53. color: 'rgba(0, 0, 0, 0)',
  54. }
  55. }
  56. this.option = {
  57. color: ['#125ec1', '#3fa5c0', '#d68639', '#ad5b68', '#6082a5'],
  58. series: [{
  59. name: '金融类',
  60. type: 'pie',
  61. clockWise: false,
  62. startAngle: 90,
  63. hoverAnimation: false,
  64. radius: ['85%', '90%'],
  65. center: ['50%', '50%'],
  66. label: {
  67. normal: {
  68. show: false
  69. },
  70. },
  71. labelLine: {
  72. normal: {
  73. show: false
  74. }
  75. },
  76. itemStyle: {
  77. shadowColor: '#125ec1',
  78. shadowBlur: 15
  79. },
  80. data: [{
  81. value: 15,
  82. name: '15%',
  83. itemStyle: {
  84. normal: {
  85. color: '#125ec1'
  86. }
  87. }
  88. }, {
  89. value: 85,
  90. name: '50%',
  91. itemStyle: itemStyle
  92. }]
  93. }, {
  94. name: '政务类',
  95. type: 'pie',
  96. clockWise: false,
  97. startAngle: 90,
  98. hoverAnimation: false,
  99. radius: ['72%', '77%'],
  100. center: ['50%', '50%'],
  101. label: {
  102. normal: {
  103. show: false
  104. },
  105. },
  106. labelLine: {
  107. normal: {
  108. show: false
  109. }
  110. },
  111. itemStyle: {
  112. shadowColor: '#3fa5c0',
  113. shadowBlur: 15
  114. },
  115. data: [{
  116. value: 60,
  117. name: '60%',
  118. itemStyle: {
  119. normal: {
  120. color: '#3fa5c0'
  121. }
  122. }
  123. }, {
  124. value: 40,
  125. name: '40%',
  126. itemStyle: itemStyle
  127. }]
  128. }, {
  129. name: '医疗类',
  130. type: 'pie',
  131. clockWise: false,
  132. startAngle: 90,
  133. hoverAnimation: false,
  134. radius: ['59%', '64%'],
  135. center: ['50%', '50%'],
  136. label: {
  137. normal: {
  138. show: false
  139. },
  140. },
  141. labelLine: {
  142. normal: {
  143. show: false
  144. }
  145. },
  146. itemStyle: {
  147. shadowColor: '#d68639',
  148. shadowBlur: 15
  149. },
  150. data: [{
  151. value: 32,
  152. name: '32%',
  153. itemStyle: {
  154. normal: {
  155. color: '#d68639'
  156. }
  157. }
  158. }, {
  159. value: 68,
  160. name: '68%',
  161. itemStyle: itemStyle
  162. }]
  163. }, {
  164. name: '工业类',
  165. type: 'pie',
  166. clockWise: false,
  167. startAngle: 90,
  168. hoverAnimation: false,
  169. radius: ['46%', '51%'],
  170. center: ['50%', '50%'],
  171. label: {
  172. normal: {
  173. show: false
  174. },
  175. },
  176. labelLine: {
  177. normal: {
  178. show: false
  179. }
  180. },
  181. itemStyle: {
  182. shadowColor: '#ad5b68',
  183. shadowBlur: 15
  184. },
  185. data: [{
  186. value: 20,
  187. name: '20%',
  188. itemStyle: {
  189. normal: {
  190. color: '#ad5b68'
  191. }
  192. }
  193. }, {
  194. value: 80,
  195. name: '80%',
  196. itemStyle: itemStyle
  197. }]
  198. }, {
  199. name: '食品类',
  200. type: 'pie',
  201. clockWise: false,
  202. startAngle: 90,
  203. hoverAnimation: false,
  204. radius: ['33%', '38%'],
  205. center: ['50%', '50%'],
  206. label: {
  207. normal: {
  208. show: false
  209. },
  210. },
  211. labelLine: {
  212. normal: {
  213. show: false
  214. }
  215. },
  216. itemStyle: {
  217. shadowColor: '#6082a5',
  218. shadowBlur: 15
  219. },
  220. data: [{
  221. value: 73,
  222. name: '73%',
  223. itemStyle: {
  224. normal: {
  225. color: '#6082a5'
  226. }
  227. }
  228. }, {
  229. value: 27,
  230. name: '27%',
  231. itemStyle: itemStyle
  232. }]
  233. }]
  234. }
  235. // 使用制定的配置项和数据显示图表
  236. myChart.setOption(this.option, true);
  237. window.addEventListener('resize', () => {
  238. myChart.resize();
  239. });
  240. }
  241. },
  242. }
  243. </script>
  244. <style lang="scss" scoped>
  245. .sn-title {
  246. text-align: center;
  247. color: white;
  248. }
  249. .sn-container {
  250. border: 5px solid aqua;
  251. border-radius: 25px;
  252. }
  253. .wrap-container {
  254. position: relative;
  255. width: 432px;
  256. height: 400px;
  257. .chartsdom {
  258. width: 100%;
  259. height: 100%;
  260. }
  261. .preinfo {
  262. position: absolute;
  263. left: 68%;
  264. top: 5%;
  265. margin-left: -2.5em;
  266. -webkit-transform: translate(0%, -50%);
  267. -moz-transform: translate(0%, -50%);
  268. -ms-transform: translate(0%, -50%);
  269. -o-transform: translate(0%, -50%);
  270. transform: translate(0%, -50%);
  271. white-space: nowrap;
  272. font-size: 13px;
  273. span {
  274. &:nth-child(1) {
  275. margin-right: 10px;
  276. }
  277. }
  278. &.preinfo0 {
  279. color: rgb(99, 139, 176);
  280. margin-top: 25%;
  281. }
  282. &.preinfo1 {
  283. color: rgb(180, 91, 111);
  284. margin-top: 19%;
  285. }
  286. &.preinfo2 {
  287. color: rgb(232, 138, 50);
  288. margin-top: 13%;
  289. }
  290. &.preinfo3 {
  291. color: rgb(70, 179, 200);
  292. margin-top: 7%;
  293. }
  294. &.preinfo4 {
  295. color: rgb(19, 98, 201);
  296. margin-top: 1%;
  297. }
  298. }
  299. .preinfos {
  300. position: absolute;
  301. left: 50%;
  302. top: 50%;
  303. width: 1px;
  304. height: 58px;
  305. background-color: rgb(99, 139, 176);
  306. -webkit-transform-origin: 50% 0;
  307. -moz-transform-origin: 50% 0;
  308. -ms-transform-origin: 50% 0;
  309. -o-transform-origin: 50% 0;
  310. transform-origin: 50% 0;
  311. span {
  312. &:nth-child(1) {
  313. width: 8px;
  314. height: 8px;
  315. -webkit-border-radius: 100%;
  316. -moz-border-radius: 100%;
  317. border-radius: 100%;
  318. position: absolute;
  319. left: -3px;
  320. top: 50%;
  321. }
  322. &:nth-child(2) {
  323. width: 0;
  324. height: 0;
  325. border-width: 12px 5px 5px 5px;
  326. border-style: solid;
  327. position: absolute;
  328. left: -5px;
  329. top: 100%;
  330. }
  331. }
  332. &.pre0 {
  333. height: 55px;
  334. background-color: rgb(99, 139, 176);
  335. transform: rotate(-62.614deg);
  336. span {
  337. &:nth-child(1) {
  338. background-color: rgb(99, 139, 176);
  339. }
  340. &:nth-child(2) {
  341. border-color: rgb(99, 139, 176) transparent transparent;
  342. }
  343. }
  344. }
  345. &.pre1 {
  346. height: 85px;
  347. background-color: rgb(180, 91, 111);
  348. transform: rotate(125.593deg);
  349. span {
  350. &:nth-child(1) {
  351. background-color: rgb(180, 91, 111);
  352. }
  353. &:nth-child(2) {
  354. border-color: rgb(180, 91, 111) transparent transparent;
  355. }
  356. }
  357. }
  358. &.pre2 {
  359. height: 109px;
  360. background-color: rgb(232, 138, 50);
  361. transform: rotate(86.2006deg);
  362. span {
  363. &:nth-child(1) {
  364. background-color: rgb(232, 138, 50);
  365. }
  366. &:nth-child(2) {
  367. border-color: rgb(232, 138, 50) transparent transparent;
  368. }
  369. }
  370. }
  371. &.pre3 {
  372. height: 131px;
  373. background-color: rgb(70, 179, 200);
  374. transform: rotate(-18.845deg);
  375. span {
  376. &:nth-child(1) {
  377. background-color: rgb(70, 179, 200);
  378. }
  379. &:nth-child(2) {
  380. border-color: rgb(70, 179, 200) transparent transparent;
  381. }
  382. }
  383. }
  384. &.pre4 {
  385. height: 158px;
  386. background-color: rgb(19, 98, 201);
  387. transform: rotate(149.666deg);
  388. span {
  389. &:nth-child(1) {
  390. background-color: rgb(19, 98, 201);
  391. }
  392. &:nth-child(2) {
  393. border-color: rgb(19, 98, 201) transparent transparent;
  394. }
  395. }
  396. }
  397. }
  398. }
  399. </style>

 6、动态柱状图

  1. <template>
  2. <div class="wrap-container sn-container">
  3. <div class="sn-content">
  4. <div class="sn-title">动态柱状图</div>
  5. <div class="sn-body">
  6. <div class="wrap-container">
  7. <div class="chartsdom" id='chart-dynamic-bar'></div>
  8. </div>
  9. </div>
  10. </div>
  11. </div>
  12. </template>
  13. <script>
  14. export default {
  15. name: 'dynamic-bar',
  16. data() {
  17. return {
  18. option: null,
  19. dataMap: {}
  20. }
  21. },
  22. mounted() {
  23. this.getEchart();
  24. },
  25. methods: {
  26. dataFormatter(obj) {
  27. let pList = ['长沙', '湘潭', '株洲', '岳阳', '邵阳', '衡阳', '益阳', '娄底', '怀化', '湘西', '张家界', '郴州', '常德', '永州'];
  28. let temp;
  29. for (let x = 0; x < 3; x++) {
  30. let max = 0;
  31. let sum = 0;
  32. temp = obj[x];
  33. for (let i = 0, l = temp.length; i < l; i++) {
  34. max = Math.max(max, temp[i]);
  35. sum += temp[i];
  36. obj[x][i] = {
  37. name: pList[i],
  38. value: temp[i]
  39. };
  40. }
  41. obj[x + 'max'] = Math.floor(max / 100) * 100;
  42. obj[x + 'sum'] = sum;
  43. }
  44. return obj;
  45. },
  46. getEchart() {
  47. let myChart = this.$echarts.init(document.getElementById('chart-dynamic-bar'));
  48. let itemStyle = {
  49. barBorderRadius: [15, 0],
  50. color: '#0084ff'
  51. }
  52. this.dataMap.dataType = this.dataFormatter({
  53. 2: [124, 145, 261, 54, 195, 131, 150, 39, 11, 40, 23, 51, 45, 88],
  54. 1: [136, 159, 205, 41, 306, 7, 77, 101, 24, 34, 8, 15, 14, 9],
  55. 0: [118, 128, 220, 47, 92, 14, 9, 11, 113, 61, 11, 22, 33, 5],
  56. });
  57. console.log("this.dataMap.dataType", this.dataMap.dataType)
  58. this.option = {
  59. baseOption: {
  60. timeline: {
  61. axisType: 'category',
  62. autoPlay: true,
  63. playInterval: 1000,
  64. data: ['一类', '二类', '三类'],
  65. left: 80,
  66. right: 80,
  67. bottom: 30,
  68. lineStyle: {
  69. color: '#179bf1'
  70. },
  71. label: {
  72. color: '#fff'
  73. },
  74. checkpointStyle: {
  75. color: '#01d8ff',
  76. symbolSize: 10,
  77. borderColor: 'rgba(1, 216, 255, 0.5)',
  78. borderWidth: 5,
  79. },
  80. controlStyle: {
  81. show: false,
  82. },
  83. itemStyle: {
  84. borderColor: '#004b85',
  85. borderWidth: 1,
  86. shadowColor: 'rgba(1, 216, 225, 0.5)',
  87. shadowBlur: 5
  88. },
  89. emphasis: {
  90. label: {
  91. color: '#01d8ff',
  92. show: false
  93. },
  94. checkpointStyle: {
  95. color: '#01d8ff',
  96. borderColor: 'rgba(1, 216, 255, 0.5)',
  97. borderWidth: 5,
  98. },
  99. itemStyle: {
  100. color: '#01d8ff',
  101. borderColor: 'rgba(1, 216, 225, 0.5)',
  102. borderWidth: 5
  103. }
  104. }
  105. },
  106. calculable: true,
  107. grid: {
  108. top: '10%',
  109. bottom: '35%'
  110. },
  111. xAxis: [{
  112. type: 'category',
  113. axisLabel: {
  114. interval: 0
  115. },
  116. data: ['长沙', '湘潭', '株洲', '岳阳', '邵阳', '衡阳', '益阳', '娄底', '怀化', '湘西', '张家界', '郴州',
  117. '常德', '永州'
  118. ],
  119. splitLine: {
  120. show: false
  121. },
  122. axisTick: {
  123. show: false
  124. },
  125. axisLine: {
  126. show: true,
  127. lineStyle: {
  128. color: '#2867a8',
  129. }
  130. },
  131. }],
  132. yAxis: [{
  133. type: 'value',
  134. name: '家',
  135. splitLine: {
  136. show: false
  137. },
  138. axisTick: {
  139. show: false
  140. },
  141. axisLine: {
  142. show: true,
  143. lineStyle: {
  144. color: '#2867a8'
  145. }
  146. }
  147. }],
  148. series: [{
  149. name: '一类',
  150. type: 'bar',
  151. barWidth: 15,
  152. legendHoverLink: true,
  153. label: {
  154. show: true,
  155. position: 'top',
  156. color: '#fff'
  157. },
  158. }]
  159. },
  160. options: [{
  161. series: [{
  162. data: this.dataMap.dataType['0'],
  163. itemStyle: itemStyle
  164. }]
  165. }, {
  166. series: [{
  167. data: this.dataMap.dataType['1'],
  168. itemStyle: itemStyle
  169. }]
  170. }, {
  171. series: [{
  172. data: this.dataMap.dataType['2'],
  173. itemStyle: itemStyle
  174. }]
  175. }]
  176. }
  177. myChart.setOption(this.option, true);
  178. window.addEventListener('resize', () => {
  179. myChart.resize();
  180. });
  181. }
  182. }
  183. }
  184. </script>
  185. <style lang='scss' scoped>
  186. .sn-title{
  187. text-align: center;
  188. color: white;
  189. }
  190. .sn-container{
  191. border: 5px solid aqua;
  192. border-radius: 20px;
  193. }
  194. .wrap-container{
  195. width: 586px;
  196. height: 400px;
  197. .chartsdom{
  198. width: 100%;
  199. height: 100%;
  200. }
  201. }
  202. </style>

7、仪表盘

  1. <template>
  2. <div class="wrap-container sn-container">
  3. <div class="sn-content">
  4. <div class="sn-title">仪表盘</div>
  5. <div class="sn-body">
  6. <div class="wrap-container">
  7. <div class="chartsdom" id='chart-gauge'></div>
  8. </div>
  9. </div>
  10. </div>
  11. </div>
  12. </template>
  13. <script>
  14. export default {
  15. name: 'gauge-chart',
  16. data() {
  17. return {
  18. option: null,
  19. timer: null
  20. }
  21. },
  22. mounted() {
  23. this.getEchart()
  24. },
  25. methods: {
  26. getEchart() {
  27. let myChart = this.$echarts.init(document.getElementById('chart-gauge'))
  28. this.option = {
  29. tooltip: {
  30. formatter: '{a} <br/>{c} {b}'
  31. },
  32. series: [{
  33. name: '速度',
  34. type: 'gauge',
  35. min: 0,
  36. max: 220,
  37. splitNumber: 11,
  38. // radius: '50%',
  39. axisLine: { // 坐标轴线
  40. lineStyle: { // 属性lineStyle控制线条样式
  41. color: [
  42. [0.09, 'lime'],
  43. [0.82, '#1e90ff'],
  44. [1, '#ff4500']
  45. ],
  46. width: 3,
  47. // shadowColor: '#fff', //默认透明
  48. shadowBlur: 10
  49. }
  50. },
  51. axisLabel: { // 坐标轴小标记
  52. fontWeight: 'bolder',
  53. color: '#fff',
  54. shadowColor: '#fff', //默认透明
  55. shadowBlur: 10
  56. },
  57. axisTick: { // 坐标轴小标记
  58. length: 15, // 属性length控制线长
  59. lineStyle: { // 属性lineStyle控制线条样式
  60. color: 'auto',
  61. // shadowColor: '#fff', //默认透明
  62. shadowBlur: 10
  63. }
  64. },
  65. splitLine: { // 分隔线
  66. length: 25, // 属性length控制线长
  67. lineStyle: { // 属性lineStyle(详见lineStyle)控制线条样式
  68. width: 3,
  69. color: '#fff',
  70. // shadowColor: '#fff', //默认透明
  71. shadowBlur: 10
  72. }
  73. },
  74. pointer: { // 分隔线
  75. // shadowColor: '#fff', //默认透明
  76. shadowBlur: 5
  77. },
  78. title: {
  79. textStyle: { // 其余属性默认使用全局文本样式,详见TEXTSTYLE
  80. fontWeight: 'bolder',
  81. fontSize: 20,
  82. fontStyle: 'italic',
  83. color: '#fff',
  84. shadowColor: '#fff', //默认透明
  85. shadowBlur: 10
  86. }
  87. },
  88. detail: {
  89. // backgroundColor: 'rgba(30,144,255,0.8)',
  90. // borderWidth: 1,
  91. // borderColor: '#fff',
  92. // shadowColor: '#fff', //默认透明
  93. // shadowBlur: 5,
  94. offsetCenter: [0, '50%'], // x, y,单位px
  95. textStyle: { // 其余属性默认使用全局文本样式,详见TEXTSTYLE
  96. fontWeight: 'bolder',
  97. fontSize: 25,
  98. color: '#fff'
  99. }
  100. },
  101. data: [{
  102. value: 40,
  103. name: 'km/h'
  104. }]
  105. }]
  106. }
  107. myChart.setOption(this.option, true);
  108. window.addEventListener('resize', () => {
  109. myChart.resize();
  110. });
  111. this.timer = setInterval(()=>{
  112. this.option.series[0].data[0].value = (Math.random()*200).toFixed(2) -0
  113. myChart.setOption(this.option, true)
  114. },1000)
  115. }
  116. },
  117. beforeDestroy() {
  118. clearInterval(this.timer);
  119. }
  120. }
  121. </script>
  122. <style lang="scss" scoped>
  123. .sn-title{
  124. text-align: center;
  125. color: white;
  126. }
  127. .wrap-container{
  128. width: 432px;
  129. height: 400px;
  130. .chartsdom{
  131. width: 100%;
  132. height: 100%;
  133. }
  134. }
  135. </style>

8、动态折线图

 

  1. <template>
  2. <div class="wrap-container sn-container">
  3. <div class="sn-content">
  4. <div class="sn-title">动态折线图</div>
  5. <div class="sn-body">
  6. <div class="wrap-container">
  7. <div class="chartsdom" id='chart-dynamic-line'></div>
  8. </div>
  9. </div>
  10. </div>
  11. </div>
  12. </template>
  13. <script>
  14. export default {
  15. name: 'dynamic-line',
  16. data() {
  17. return {
  18. option: null,
  19. timer: null,
  20. xData: [],
  21. now: new Date(2019, 1, 1),
  22. value: Math.random() * 1000,
  23. oneDay: 24 * 3600 * 1000
  24. }
  25. },
  26. mounted() {
  27. this.getEchart();
  28. },
  29. methods: {
  30. randomData() {
  31. this.now = new Date(+this.now + this.oneDay)
  32. this.value = this.value + Math.random() * 25 - 10
  33. return {
  34. name: this.now.toString(),
  35. value: [
  36. [this.now.getFullYear(), this.now.getMonth() , this.now.getDate()].join('/'),
  37. Math.round(this.value)
  38. ]
  39. }
  40. },
  41. getEchart() {
  42. let myChart = this.$echarts.init(document.getElementById('chart-dynamic-line'));
  43. for (let i = 0; i < 1000; i++) {
  44. this.xData.push(this.randomData());
  45. }
  46. this.option = {
  47. tooltip: {
  48. trigger: 'axis',
  49. axisPointer: {
  50. type: 'cross',
  51. axisPointer: {
  52. type: 'cross',
  53. label: {
  54. backgroundColor: '#283b56'
  55. }
  56. }
  57. }
  58. },
  59. grid: {
  60. top: '15%',
  61. left: '10%',
  62. right: '12%',
  63. bottom: '15%',
  64. containLabel: true
  65. },
  66. color: ['#b54c5d'],
  67. calculable: true,
  68. xAxis: {
  69. type: 'time',
  70. name: '年-月-日',
  71. boundaryGap: false,
  72. splitNumber: 5,
  73. axisLabel: {
  74. formatter(value) {
  75. let date = new Date(value);
  76. return date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate();
  77. }
  78. },
  79. axisTick: {
  80. show: false
  81. },
  82. axisLine: {
  83. show: true,
  84. lineStyle: {
  85. color: '#0084ff'
  86. }
  87. },
  88. splitLine: {
  89. show: false
  90. }
  91. },
  92. yAxis: {
  93. type: 'value',
  94. scale: true,
  95. name: '比特币(美元)',
  96. min: 0,
  97. boundaryGap: false,
  98. axisTick: {
  99. show: false
  100. },
  101. axisLine: {
  102. show: true,
  103. lineStyle: {
  104. color: '#0084ff'
  105. }
  106. },
  107. splitLine: {
  108. show: false
  109. },
  110. },
  111. series: [{
  112. name: '实时交易',
  113. type: 'line',
  114. xAxisIndex: 0,
  115. yAxisIndex: 0,
  116. itemStyle: {
  117. opacity: 0,
  118. },
  119. data: this.xData,
  120. smooth: true
  121. }]
  122. }
  123. myChart.setOption(this.option, true);
  124. window.addEventListener('resize', () => {
  125. myChart.resize();
  126. });
  127. this.timer = setInterval(() => {
  128. for (let i = 0; i < 5; i++){
  129. this.xData.shift();
  130. this.xData.push(this.randomData());
  131. }
  132. myChart.setOption(this.option, true);
  133. },200)
  134. }
  135. },
  136. beforeDestroy() {
  137. clearInterval(this.timer);
  138. }
  139. }
  140. </script>
  141. <style lang="scss" scoped>
  142. .sn-title{
  143. text-align: center;
  144. color: white;
  145. }
  146. .wrap-container{
  147. width: 586px;
  148. height: 400px;
  149. .chartsdom{
  150. width: 100%;
  151. height: 100%;
  152. }
  153. }
  154. </style>

9、雷达图

 

  1. <template>
  2. <div class="wrap-container sn-container">
  3. <div class="sn-content">
  4. <div class="sn-title">雷达图</div>
  5. <div class="sn-body">
  6. <div class="wrap-container">
  7. <div class="chartsdom" id='chart-radar'></div>
  8. </div>
  9. </div>
  10. </div>
  11. </div>
  12. </template>
  13. <script>
  14. export default {
  15. name: 'radar-chart',
  16. data() {
  17. return {
  18. Option: null,
  19. timer: null
  20. }
  21. },
  22. mounted() {
  23. this.getEchart()
  24. },
  25. methods: {
  26. getEchart() {
  27. let myChart = this.$echarts.init(document.getElementById('chart-radar'))
  28. this.option = {
  29. tooltip: {
  30. trigger: 'axis'
  31. },
  32. radar: [{
  33. indicator: [
  34. {
  35. text: '外观',
  36. max: 100
  37. },
  38. {
  39. text: '拍照',
  40. max: 100
  41. },
  42. {
  43. text: '系统',
  44. max: 100
  45. },
  46. {
  47. text: '性能',
  48. max: 100
  49. },
  50. {
  51. text: '屏幕',
  52. max: 100
  53. },
  54. {
  55. text: '折叠',
  56. max: 100
  57. },
  58. ],
  59. radius: '75%',
  60. center: ['50%', '50%'],
  61. name: {
  62. textStyle: {
  63. color: '#1883ff'
  64. }
  65. },
  66. axisTick: {
  67. show: false
  68. },
  69. axisLabel: {
  70. show: false
  71. },
  72. axisLine: {
  73. show: true,
  74. symbol: 'arrow',
  75. symbolSize: [5, 7.5],
  76. lineStyle: {
  77. color: '#1883ff',
  78. type: 'dashed'
  79. }
  80. },
  81. splitArea: {
  82. show: false
  83. },
  84. splitLine: {
  85. show: false
  86. }
  87. }],
  88. series: [{
  89. type: 'radar',
  90. areaStyle: {},
  91. symbol: 'none',
  92. itemStyle: {
  93. normal: {
  94. areaStyle: {
  95. type: 'default'
  96. }
  97. }
  98. },
  99. lineStyle: {
  100. opacity: 0,
  101. },
  102. data: [
  103. {
  104. value: [75, 50, 30, 90, 40, 45],
  105. name: '智能手机',
  106. itemStyle: {
  107. normal: {
  108. color: new this.$echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  109. offset: 0,
  110. color: '#9c6b4e'
  111. }, {
  112. offset: 1,
  113. color: '#2a59ac'
  114. }]),
  115. lineStyle: {
  116. color: '#2a59ac'
  117. }
  118. }
  119. }
  120. },
  121. // {
  122. // value: [70, 40, 55, 55, 30, 55],
  123. // name: '5G手机',
  124. // itemStyle: {
  125. // normal: {
  126. // color: new this.$echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  127. // offset: 0,
  128. // color: '#0855ca'
  129. // }, {
  130. // offset: 1,
  131. // color: '#36a6c7'
  132. // }]),
  133. // lineStyle: {
  134. // color: '#36a6c7'
  135. // }
  136. // }
  137. // }
  138. // }
  139. ]
  140. }]
  141. }
  142. myChart.setOption(this.option, true);
  143. window.addEventListener('resize', () => {
  144. myChart.resize();
  145. });
  146. this.timer = setInterval(()=>{
  147. let valueArr = this.option.series[0].data[0].value
  148. for (var i = 0; i < valueArr.length; i++) {
  149. valueArr[i] = parseInt((Math.random()*100))
  150. }
  151. this.option.series[0].data[0].value = valueArr
  152. myChart.setOption(this.option, true)
  153. },1000)
  154. }
  155. },
  156. beforeDestroy(){
  157. clearInterval(this.timer)
  158. }
  159. }
  160. </script>
  161. <style lang="scss" scoped>
  162. .sn-container{
  163. text-align: center;
  164. color: white;
  165. }
  166. .wrap-container {
  167. width: 432px;
  168. height: 400px;
  169. .chartsdom {
  170. width: 100%;
  171. height: 100%;
  172. }
  173. }
  174. </style>

10、柱状图和饼图联动

 

  1. <template>
  2. <div class="wrap-container sn-container">
  3. <div class="sn-content">
  4. <div class="sn-title">柱状和饼状图联动</div>
  5. <div class="sn-body">
  6. <div class="wrap-container">
  7. <div class="chartsdom" id='chart-bar-pie'></div>
  8. </div>
  9. </div>
  10. </div>
  11. </div>
  12. </template>
  13. <script>
  14. export default {
  15. name: 'union-bar-pie',
  16. data() {
  17. return {
  18. option: null,
  19. dataMap: {}
  20. }
  21. },
  22. mounted() {
  23. this.getEchart()
  24. },
  25. methods: {
  26. dataFormatter(obj) {
  27. let pList = ['金融类', '政务类', '医疗类', '互联网类']
  28. let temp
  29. for (let y = 2016; y <= 2020; y++) {
  30. let max = 0;
  31. let sum = 0;
  32. temp = obj[y];
  33. for (let i = 0, l = temp.length; i < l; i++) {
  34. max = Math.max(max, temp[i]);
  35. sum += temp[i];
  36. obj[y][i] = {
  37. name: pList[i],
  38. value: temp[i]
  39. };
  40. }
  41. obj[y + 'max'] = Math.floor(max / 100) * 100;
  42. obj[y + 'sum'] = sum;
  43. }
  44. return obj;
  45. },
  46. getEchart() {
  47. let myChart = this.$echarts.init(document.getElementById('chart-bar-pie'));
  48. let itemStyleJR = {
  49. color: '#d6d638'
  50. }
  51. let itemStyleZW = {
  52. color: '#00c86c'
  53. }
  54. let itemStyleYL = {
  55. color: '#07d8ff'
  56. }
  57. let itemStyleIT = {
  58. color: '#0c71cf'
  59. }
  60. this.dataMap.dataJR = this.dataFormatter({
  61. //max : 4000,
  62. 2020: [136, 159, 905, 305],
  63. 2019: [124, 145, 562, 285],
  64. 2018: [118, 128, 207, 265],
  65. 2017: [112, 122, 234, 245],
  66. 2016: [101, 110, 804, 225]
  67. });
  68. this.dataMap.dataZW = this.dataFormatter({
  69. //max : 26600,
  70. 2020: [752, 928, 126, 210],
  71. 2019: [388, 840, 707, 208],
  72. 2018: [855, 987, 959, 207],
  73. 2017: [626, 709, 701, 206],
  74. 2016: [509, 892, 201, 205]
  75. });
  76. this.dataMap.dataYL = this.dataFormatter({
  77. //max : 25000,
  78. 2020: [363, 219, 483, 505],
  79. 2019: [600, 438, 123, 405],
  80. 2018: [179, 405, 668, 305],
  81. 2017: [375, 2886, 276, 205],
  82. 2016: [236, 250, 408, 105]
  83. });
  84. this.dataMap.dataIT = this.dataFormatter({
  85. //max : 26600,
  86. 2020: [752, 928, 126, 255],
  87. 2019: [388, 840, 707, 245],
  88. 2018: [855, 987, 959, 235],
  89. 2017: [626, 709, 701, 225],
  90. 2016: [509, 892, 201, 215]
  91. });
  92. this.option = {
  93. baseOption: {
  94. timeline: {
  95. axisType: 'category',
  96. autoPlay: true,
  97. playInterval: 2000,
  98. data: ['2016-01-01', '2017-01-01', '2018-01-01', '2019-01-01', '2020-01-01'],
  99. lineStyle: {
  100. color: '#179bf1'
  101. },
  102. left: 30,
  103. right: 30,
  104. bottom: 30,
  105. label: {
  106. color: '#2867a8',
  107. formatter(s) {
  108. return (new Date(s)).getFullYear();
  109. }
  110. },
  111. checkpointStyle: {
  112. color: '#01d8ff',
  113. symbolSize: 10,
  114. borderColor: 'rgba(1, 216, 255, 0.5)',
  115. borderWidth: 5,
  116. },
  117. controlStyle: {
  118. showPlayBtn: false,
  119. borderColor: '#01bde6',
  120. itemGap: 20
  121. },
  122. itemStyle: {
  123. // color: '#004b85',
  124. borderColor: '#004b85',
  125. borderWidth: 1,
  126. shadowColor: 'rgba(1, 216, 225, 0.5)',
  127. shadowBlur: 5
  128. },
  129. emphasis: {
  130. label: {
  131. color: '#01d8ff',
  132. show: false
  133. },
  134. checkpointStyle: {
  135. color: '#01d8ff',
  136. borderColor: 'rgba(1, 216, 255, 0.5)',
  137. borderWidth: 5,
  138. },
  139. controlStyle: {
  140. borderColor: 'rgba(1, 216, 255, 0.5)'
  141. },
  142. itemStyle: {
  143. color: '#01d8ff',
  144. borderColor: 'rgba(1, 216, 225, 0.5)',
  145. borderWidth: 5
  146. }
  147. }
  148. },
  149. // tooltip: {
  150. // trigger: 'item'
  151. // },
  152. grid: {
  153. bottom: '30%',
  154. right: "42%"
  155. },
  156. calculable: true,
  157. xAxis: [{
  158. type: 'category',
  159. data: ['金融类', '政务类', '医疗类', '互联网类'],
  160. splitLine: {
  161. show: false
  162. },
  163. axisTick: {
  164. show: false
  165. },
  166. axisLine: {
  167. show: true,
  168. lineStyle: {
  169. color: '#0084ff',
  170. }
  171. },
  172. }],
  173. yAxis: [{
  174. type: 'value',
  175. name: '区块链应用(个)',
  176. splitLine: {
  177. show: false
  178. },
  179. axisTick: {
  180. show: false
  181. },
  182. axisLine: {
  183. show: true,
  184. lineStyle: {
  185. color: '#0084ff'
  186. }
  187. },
  188. }],
  189. series: [{
  190. name: '联盟链',
  191. type: 'bar',
  192. barMaxWidth: 15,
  193. center: ['20%', '65%'],
  194. seriesLayoutBy: 'row',
  195. markPoint: {
  196. symbol: 'pin',
  197. itemStyle: {
  198. normal: {
  199. color: '#eb9b44',
  200. shadowColor: '#eb9b44',
  201. shadowBlur: 15
  202. }
  203. },
  204. data: [{
  205. type: 'max',
  206. name: '最大值'
  207. },
  208. {
  209. type: 'min',
  210. name: '最小值'
  211. }
  212. ]
  213. }
  214. // label: {
  215. // show: true,
  216. // position: 'top'
  217. // },
  218. },
  219. {
  220. name: '应用占比',
  221. type: 'pie',
  222. center: ['76%', '20%'],
  223. radius: '28%',
  224. z: 100
  225. }
  226. ]
  227. },
  228. options: [{
  229. series: [{
  230. data: [{
  231. name: '金融类',
  232. value: this.dataMap.dataJR['2016sum'],
  233. itemStyle: itemStyleJR
  234. }, {
  235. name: '政务类',
  236. value: this.dataMap.dataZW['2016sum'],
  237. itemStyle: itemStyleZW
  238. }, {
  239. name: '医疗类',
  240. value: this.dataMap.dataYL['2016sum'],
  241. itemStyle: itemStyleYL
  242. }, {
  243. name: '互联网类',
  244. value: this.dataMap.dataIT['2016sum'],
  245. itemStyle: itemStyleIT
  246. }],
  247. },
  248. {
  249. data: [{
  250. name: '金融类',
  251. value: this.dataMap.dataJR['2016sum'],
  252. itemStyle: itemStyleJR
  253. }, {
  254. name: '政务类',
  255. value: this.dataMap.dataZW['2016sum'],
  256. itemStyle: itemStyleZW
  257. }, {
  258. name: '医疗类',
  259. value: this.dataMap.dataYL['2016sum'],
  260. itemStyle: itemStyleYL
  261. }, {
  262. name: '互联网类',
  263. value: this.dataMap.dataIT['2016sum'],
  264. itemStyle: itemStyleIT
  265. }]
  266. }
  267. ]
  268. },
  269. {
  270. series: [{
  271. data: [{
  272. name: '金融类',
  273. value: this.dataMap.dataJR['2017sum'],
  274. itemStyle: itemStyleJR
  275. }, {
  276. name: '政务类',
  277. value: this.dataMap.dataZW['2017sum'],
  278. itemStyle: itemStyleZW
  279. }, {
  280. name: '医疗类',
  281. value: this.dataMap.dataYL['2017sum'],
  282. itemStyle: itemStyleYL
  283. }, {
  284. name: '互联网类',
  285. value: this.dataMap.dataIT['2017sum'],
  286. itemStyle: itemStyleIT
  287. }],
  288. },
  289. {
  290. data: [{
  291. name: '金融类',
  292. value: this.dataMap.dataJR['2017sum'],
  293. itemStyle: itemStyleJR
  294. }, {
  295. name: '政务类',
  296. value: this.dataMap.dataZW['2017sum'],
  297. itemStyle: itemStyleZW
  298. }, {
  299. name: '医疗类',
  300. value: this.dataMap.dataYL['2017sum'],
  301. itemStyle: itemStyleYL
  302. }, {
  303. name: '互联网类',
  304. value: this.dataMap.dataIT['2017sum'],
  305. itemStyle: itemStyleIT
  306. }]
  307. }
  308. ]
  309. },
  310. {
  311. series: [{
  312. data: [{
  313. name: '金融类',
  314. value: this.dataMap.dataJR['2018sum'],
  315. itemStyle: itemStyleJR
  316. }, {
  317. name: '政务类',
  318. value: this.dataMap.dataZW['2018sum'],
  319. itemStyle: itemStyleZW
  320. }, {
  321. name: '医疗类',
  322. value: this.dataMap.dataYL['2018sum'],
  323. itemStyle: itemStyleYL
  324. }, {
  325. name: '互联网类',
  326. value: this.dataMap.dataIT['2018sum'],
  327. itemStyle: itemStyleIT
  328. }]
  329. },
  330. {
  331. data: [{
  332. name: '金融类',
  333. value: this.dataMap.dataJR['2018sum'],
  334. itemStyle: itemStyleJR
  335. }, {
  336. name: '政务类',
  337. value: this.dataMap.dataZW['2018sum'],
  338. itemStyle: itemStyleZW
  339. }, {
  340. name: '医疗类',
  341. value: this.dataMap.dataYL['2018sum'],
  342. itemStyle: itemStyleYL
  343. }, {
  344. name: '互联网类',
  345. value: this.dataMap.dataIT['2018sum'],
  346. itemStyle: itemStyleIT
  347. }]
  348. }
  349. ]
  350. },
  351. {
  352. series: [{
  353. data: [{
  354. name: '金融类',
  355. value: this.dataMap.dataJR['2019sum'],
  356. itemStyle: itemStyleJR
  357. }, {
  358. name: '政务类',
  359. value: this.dataMap.dataZW['2019sum'],
  360. itemStyle: itemStyleZW
  361. }, {
  362. name: '医疗类',
  363. value: this.dataMap.dataYL['2019sum'],
  364. itemStyle: itemStyleYL
  365. }, {
  366. name: '互联网类',
  367. value: this.dataMap.dataIT['2019sum'],
  368. itemStyle: itemStyleIT
  369. }]
  370. },
  371. {
  372. data: [{
  373. name: '金融类',
  374. value: this.dataMap.dataJR['2019sum'],
  375. itemStyle: itemStyleJR
  376. }, {
  377. name: '政务类',
  378. value: this.dataMap.dataZW['2019sum'],
  379. itemStyle: itemStyleZW
  380. }, {
  381. name: '医疗类',
  382. value: this.dataMap.dataYL['2019sum'],
  383. itemStyle: itemStyleYL
  384. }, {
  385. name: '互联网类',
  386. value: this.dataMap.dataIT['2019sum'],
  387. itemStyle: itemStyleIT
  388. }]
  389. }
  390. ]
  391. },
  392. {
  393. series: [{
  394. data: [{
  395. name: '金融类',
  396. value: this.dataMap.dataJR['2020sum'],
  397. itemStyle: itemStyleJR
  398. }, {
  399. name: '政务类',
  400. value: this.dataMap.dataZW['2020sum'],
  401. itemStyle: itemStyleZW
  402. }, {
  403. name: '医疗类',
  404. value: this.dataMap.dataYL['2020sum'],
  405. itemStyle: itemStyleYL
  406. }, {
  407. name: '互联网类',
  408. value: this.dataMap.dataIT['2020sum'],
  409. itemStyle: itemStyleIT
  410. }]
  411. },
  412. {
  413. data: [{
  414. name: '金融类',
  415. value: this.dataMap.dataJR['2020sum'],
  416. itemStyle: itemStyleJR
  417. }, {
  418. name: '政务类',
  419. value: this.dataMap.dataZW['2020sum'],
  420. itemStyle: itemStyleZW
  421. }, {
  422. name: '医疗类',
  423. value: this.dataMap.dataYL['2020sum'],
  424. itemStyle: itemStyleYL
  425. }, {
  426. name: '互联网类',
  427. value: this.dataMap.dataIT['2020sum'],
  428. itemStyle: itemStyleIT
  429. }]
  430. }
  431. ]
  432. }
  433. ]
  434. }
  435. myChart.setOption(this.option, true);
  436. window.addEventListener('resize', () => {
  437. myChart.resize();
  438. });
  439. }
  440. }
  441. }
  442. </script>
  443. <style lang="scss" scoped>
  444. .sn-title {
  445. text-align: center;
  446. color: white;
  447. }
  448. .wrap-container {
  449. width: 586px;
  450. height: 400px;
  451. .chartsdom {
  452. width: 100%;
  453. height: 100%;
  454. }
  455. }
  456. </style>

11、3D 柱状图

 

  1. <template>
  2. <div class="wrap-container trigle">
  3. <div class="sn-content">
  4. <div class="sn-title">3D柱状图</div>
  5. <div class="sn-body">
  6. <div class="wrap-container">
  7. <div class="bar bar-img"></div>
  8. <div class="bar bar-img1"></div>
  9. <div class="bar bar-img2"></div>
  10. <div class="chartsdom" id='chart-3d-bar'></div>
  11. </div>
  12. </div>
  13. </div>
  14. </div>
  15. </template>
  16. <script>
  17. import 'echarts-gl'
  18. export default {
  19. name: 'three-d-bar',
  20. data() {
  21. return {
  22. option: null
  23. }
  24. },
  25. mounted() {
  26. this.getEchart()
  27. },
  28. methods: {
  29. getEchart() {
  30. let myChart = this.$echarts.init(document.getElementById('chart-3d-bar'));
  31. let xData = ['20-25', '25-30', '30-35', '35-40', '40-45', '45-50'];
  32. let days = ['1', '2', '3', '4', '5', '6'];
  33. let sex = ['女', '男'];
  34. let data = [
  35. [0, 0, 3, sex[0], xData[0], 500, 25],
  36. [0, 1, 2.5, sex[0], xData[3], 1000, 35],
  37. [0, 2, 1.5, sex[1], xData[4], 3000, 5],
  38. [0, 3, 1, sex[1], xData[1], 300, 15],
  39. [0, 4, 2, sex[0], xData[2], 500, 55],
  40. [0, 5, 3, sex[0], xData[3], 1500, 45],
  41. [1, 5, 6, sex[1], xData[0], 300, 25],
  42. [1, 1, 4, sex[0], xData[1], 500, 22],
  43. [1, 2, 2, sex[0], xData[2], 1500, 38],
  44. [1, 3, 1.5, sex[1], xData[3], 2500, 25],
  45. [1, 4, 3, sex[0], xData[4], 3500, 49],
  46. [1, 0, 4, sex[1], xData[5], 5500, 15],
  47. [2, 2, 3, sex[1], xData[0], 300, 25],
  48. [2, 1, 2, sex[0], xData[4], 1300, 25],
  49. [2, 2, 5, sex[0], xData[2], 900, 25],
  50. [2, 5, 1, sex[1], xData[3], 2000, 25],
  51. [2, 0, 3, sex[1], xData[1], 2300, 25],
  52. [2, 0, 10, sex[1], xData[5], 3500, 25],
  53. [3, 2, 3, sex[0], xData[5], 500, 35],
  54. [3, 3, 2, sex[0], xData[4], 2300, 55],
  55. [3, 2, 1, sex[1], xData[3], 3300, 15],
  56. [3, 5, 5, sex[1], xData[2], 500, 10],
  57. [3, 1, 2, sex[1], xData[1], 1000, 35],
  58. [3, 0, 1, sex[0], xData[0], 300, 45],
  59. [4, 2, 3, sex[1], xData[1], 600, 25],
  60. [4, 0, 5, sex[0], xData[0], 500, 15],
  61. [4, 1, 3.5, sex[1], xData[3], 4000, 5],
  62. [4, 4, 7, sex[0], xData[0], 300, 75],
  63. [4, 1, 0, sex[1], xData[5], 3000, 85],
  64. [3, 1, 3, sex[0], xData[2], 2500, 65],
  65. [5, 2, 3, sex[0], xData[2], 500, 15],
  66. [5, 1, 2, sex[1], xData[3], 3300, 52],
  67. [5, 1, 5, sex[0], xData[4], 1000, 88],
  68. [5, 5, 8, sex[1], xData[0], 200, 12],
  69. [5, 2, 7, sex[0], xData[0], 300, 45],
  70. [3, 2, 2, sex[1], xData[1], 5000, 51]
  71. ];
  72. this.option = {
  73. tooltip: {
  74. borderColor: '#8a704e',
  75. borderWidth: 1,
  76. padding: 15,
  77. formatter: (params) => {
  78. let html =
  79. `${params.seriesName} <br><span style="color: #f00;"> 性别:${params.value[3]} <br> 年龄:${params.value[4]}岁<br> 贷款金额:${params.value[5]} <br> 总人数:${params.value[6]}</span>`;
  80. return html;
  81. },
  82. textStyle: {
  83. color: '#8a704e',
  84. fontSize: 16
  85. }
  86. },
  87. xAxis3D: {
  88. type: 'category',
  89. data: xData
  90. },
  91. yAxis3D: {
  92. type: 'category',
  93. data: days
  94. },
  95. zAxis3D: {
  96. type: 'value'
  97. },
  98. grid3D: {
  99. show: true,
  100. boxWidth: 160,
  101. boxDepth: 80,
  102. viewControl: {
  103. alpha: 10,
  104. beta: 15
  105. }
  106. },
  107. series: [{
  108. type: 'bar3D',
  109. name: '当前值',
  110. // data: data,
  111. data: data.map((item) => {
  112. return {
  113. value: [item[1], item[0], item[2], item[3], item[4], item[5], item[6]],
  114. }
  115. }),
  116. shading: 'lambert',
  117. label: {
  118. show: false
  119. },
  120. itemStyle: {
  121. color: '#0084ff',
  122. opacity: 0.8
  123. },
  124. emphasis: {
  125. label: {
  126. show: false
  127. },
  128. itemStyle: {
  129. color: '#00eeff'
  130. }
  131. }
  132. }]
  133. }
  134. myChart.setOption(this.option, true);
  135. window.addEventListener('resize', () => {
  136. myChart.resize();
  137. });
  138. }
  139. }
  140. }
  141. </script>
  142. <style lang="scss" scoped>
  143. .sn-title{
  144. text-align: center;
  145. color: white;
  146. }
  147. .wrap-container{
  148. position: relative;
  149. width: 620px;
  150. height: 400px;
  151. .chartsdom{
  152. width: 100%;
  153. height: 100%;
  154. }
  155. .bar{
  156. width: 100%;
  157. height: 100%;
  158. position: absolute;
  159. &.bar-img{
  160. bottom: 5%;
  161. background: url(../../assets/img/bk_circle.png) no-repeat center 97%;
  162. background-size: 100%;
  163. filter:hue-rotate(180deg)
  164. }
  165. &.bar-img1{
  166. bottom: 35%;
  167. background: url(../../assets/img/bk_circle1.png) no-repeat center 97%;
  168. background-size: 75%;
  169. filter: hue-rotate(180deg);
  170. }
  171. &.bar-img2 {
  172. bottom: 60%;
  173. background: url(../../assets/img/bk_circle2.png) no-repeat center 97%;
  174. background-size: 50%;
  175. filter: hue-rotate(180deg);
  176. }
  177. }
  178. }
  179. </style>

12、彩色饼状图组合

 

  1. <template>
  2. <div class="wrap-container sn-container">
  3. <div class="sn-content">
  4. <div class="sn-title">彩色饼状图组合</div>
  5. <div class="sn-body">
  6. <div class="wrap-container">
  7. <div class="chartsdom" id='chart-colorful-pies'></div>
  8. </div>
  9. </div>
  10. </div>
  11. </div>
  12. </template>
  13. <script>
  14. export default {
  15. name: 'colorful-pies',
  16. mounted() {
  17. this.getEchart()
  18. },
  19. methods: {
  20. getEchart() {
  21. let myChart = this.$echarts.init(document.getElementById('chart-colorful-pies'))
  22. let option = {
  23. color: ['#EAEA26', '#906BF9', '#FE5656', '#01E17E', '#3DD1F9', '#FFAD05', '#4465fc'],
  24. tooltip: {
  25. trigger: 'item',
  26. formatter: '{b} : {c} ({d}%)'
  27. },
  28. polar: {},
  29. angleAxis: {
  30. interval: 1,
  31. type: 'category',
  32. data: [],
  33. z: 10,
  34. axisLine: {
  35. show: false,
  36. lineStyle: {
  37. color: '#0B4A6B',
  38. width: 5,
  39. type: 'solid'
  40. },
  41. },
  42. axisLabel: {
  43. interval: 0,
  44. show: true,
  45. color: '#0B4A6B',
  46. margin: 8,
  47. fontSize: 16
  48. },
  49. },
  50. radiusAxis: {
  51. min: 40,
  52. max: 120,
  53. interval: 15,
  54. axisLine: {
  55. show: false,
  56. lineStyle: {
  57. color: '#0B3E5E',
  58. width: 1,
  59. type: 'solid'
  60. },
  61. },
  62. axisLabel: {
  63. formatter: '{value} %',
  64. show: false,
  65. padding: [0, 0, 20, 0],
  66. color: '#0B3E5E',
  67. fontSize: 16
  68. },
  69. splitLine: {
  70. lineStyle: {
  71. color: '#0B3E5E',
  72. width: 2,
  73. type: "solid"
  74. }
  75. }
  76. },
  77. calculable: true,
  78. series: [{
  79. type: 'pie',
  80. radius: ['6%', '10%'],
  81. hoverAnimation: false,
  82. labelLine: {
  83. normal: {
  84. show: false,
  85. length: 30,
  86. length2: 50
  87. },
  88. emphasis: {
  89. show: false
  90. }
  91. },
  92. tooltip: {
  93. show: false
  94. },
  95. data: [{
  96. name: '',
  97. value: 0,
  98. itemStyle: {
  99. normal: {
  100. color: '#004A6B'
  101. }
  102. }
  103. }]
  104. },
  105. {
  106. type: 'pie',
  107. radius: ['70%', '75%'],
  108. hoverAnimation: false,
  109. labelLine: {
  110. normal: {
  111. show: false,
  112. length: 30,
  113. length2: 50
  114. },
  115. emphasis: {
  116. show: false
  117. }
  118. },
  119. tooltip: {
  120. show: false
  121. },
  122. data: [{
  123. name: '',
  124. value: 0,
  125. itemStyle: {
  126. normal: {
  127. color: '#004A6B'
  128. }
  129. }
  130. }]
  131. },
  132. {
  133. stack: 'a',
  134. type: 'pie',
  135. radius: ['20%', '70%'],
  136. roseType: 'area',
  137. zlevel: 10,
  138. label: {
  139. normal: {
  140. show: true,
  141. formatter: '{b}',
  142. textStyle: {
  143. fontSize: 12,
  144. },
  145. position: 'outside'
  146. },
  147. emphasis: {
  148. show: true
  149. }
  150. },
  151. labelLine: {
  152. normal: {
  153. show: true,
  154. length: 15,
  155. length2: 50,
  156. lineStyle: {
  157. type: 'dotted'
  158. }
  159. },
  160. emphasis: {
  161. show: true
  162. }
  163. },
  164. data: [{
  165. value: 35,
  166. name: '湖南'
  167. }, {
  168. value: 28,
  169. name: '河北'
  170. }, {
  171. value: 23,
  172. name: '广东'
  173. }, {
  174. value: 18,
  175. name: '四川'
  176. }, {
  177. value: 13,
  178. name: '浙江'
  179. }, {
  180. value: 8,
  181. name: '江苏'
  182. }, {
  183. value: 5,
  184. name: '湖北'
  185. }]
  186. }
  187. ]
  188. }
  189. myChart.setOption(option, true);
  190. window.addEventListener('resize', () => {
  191. myChart.resize();
  192. });
  193. }
  194. }
  195. }
  196. </script>
  197. <style lang="scss" scoped>
  198. .sn-title{
  199. text-align: center;
  200. color: white;
  201. }
  202. .wrap-container{
  203. width: 532px;
  204. height: 400px;
  205. .chartsdom{
  206. width: 100%;
  207. height: 100%;
  208. }
  209. }
  210. </style>

13、多彩柱状图

  1. <template>
  2. <div class="wrap-container sn-container">
  3. <div class="sn-content">
  4. <div class="sn-title">多彩的柱状图</div>
  5. <div class="sn-body">
  6. <div class="wrap-container">
  7. <div class="chartsdom" id='chart-colorful-bar'></div>
  8. </div>
  9. </div>
  10. </div>
  11. </div>
  12. </template>
  13. <script>
  14. export default {
  15. name: 'colorful-bar',
  16. mounted() {
  17. this.getEchart()
  18. },
  19. methods: {
  20. getEchart() {
  21. let myChart = this.$echarts.init(document.getElementById('chart-colorful-bar'))
  22. let charts = { // 按顺序排列从大到小
  23. cityList: ['金融行业', '电子政务', '文创版权', '教育行业', '智慧停车', '医疗互联', '物流行业'],
  24. cityData: [1500, 1200, 900, 600, 400, 300, 100]
  25. }
  26. let top10CityList = charts.cityList;
  27. let top10CityData = charts.cityData;
  28. // bar 颜色rgba ,alpha 在后边 LinearGradient 补充
  29. let color = ['rgba(14,109,236', 'rgba(255,91,6', 'rgba(100,255,249', 'rgba(248,195,248', 'rgba(110,234,19',
  30. 'rgba(255,168,17', 'rgba(218,111,227'
  31. ];
  32. let lineY = [];
  33. for (let i = 0; i < charts.cityList.length; i++) {
  34. let x = i
  35. if (x > color.length - 1) {
  36. x = color.length - 1
  37. }
  38. let data = {
  39. name: charts.cityList[i],
  40. color: color[x] + ')',
  41. value: top10CityData[i],
  42. itemStyle: {
  43. normal: {
  44. show: true,
  45. color: new this.$echarts.graphic.LinearGradient(0, 0, 1, 0, [{
  46. offset: 0,
  47. color: color[x] + ', 0.3)'
  48. }, {
  49. offset: 1,
  50. color: color[x] + ', 1)'
  51. }], false),
  52. barBorderRadius: 10
  53. },
  54. emphasis: {
  55. shadowBlur: 15,
  56. shadowColor: 'rgba(0, 0, 0, 0.1)'
  57. }
  58. }
  59. }
  60. lineY.push(data)
  61. }
  62. // 指定配置和数据
  63. let option = {
  64. color: color,
  65. tooltip: {
  66. trigger: 'item',
  67. },
  68. // 图表网格相对html元素的上下左右边界距离
  69. grid: {
  70. borderWidth: 0,
  71. top: '15%',
  72. left: '12%',
  73. right: '12%',
  74. bottom: '10%',
  75. containLabel: true
  76. },
  77. xAxis: [{
  78. type: 'value',
  79. axisTick: {
  80. show: false
  81. },
  82. axisLine: {
  83. show: false
  84. },
  85. splitLine: {
  86. show: false
  87. },
  88. axisLabel: {
  89. show: false
  90. }
  91. }],
  92. yAxis: [{
  93. type: 'category',
  94. inverse: true,
  95. axisTick: {
  96. show: false
  97. },
  98. axisLine: {
  99. show: false
  100. },
  101. axisLabel: {
  102. show: true,
  103. inside: false,
  104. textStyle: {
  105. color: '#b3ccf8',
  106. fontSize: 13
  107. },
  108. },
  109. data: top10CityList
  110. }, {
  111. type: 'category',
  112. axisLine: {
  113. show: false
  114. },
  115. axisTick: {
  116. show: false
  117. },
  118. axisLabel: {
  119. show: true,
  120. inside: false,
  121. textStyle: {
  122. color: '#b3ccf8',
  123. fontSize: 13
  124. },
  125. formatter: (val) => {
  126. return `${val}`
  127. }
  128. },
  129. splitArea: {
  130. show: false
  131. },
  132. splitLine: {
  133. show: false
  134. },
  135. data: top10CityData.reverse()
  136. }],
  137. series: [{
  138. name: '',
  139. type: 'bar',
  140. zlevel: 2,
  141. barWidth: '10px',
  142. data: lineY,
  143. animationDuration: 1500,
  144. label: {
  145. normal: {
  146. color: '#b3ccf8',
  147. show: false,
  148. position: [0, '-15px'],
  149. textStyle: {
  150. fontSize: 13
  151. },
  152. formatter: (a) => {
  153. return a.name;
  154. }
  155. }
  156. }
  157. }]
  158. };
  159. // 把配置给实例对象
  160. myChart.setOption(option, true);
  161. // 添加窗口尺寸变化监听
  162. window.addEventListener('resize', () => {
  163. myChart.resize();
  164. });
  165. }
  166. }
  167. }
  168. </script>
  169. <style lang="scss" scoped>
  170. .sn-title{
  171. text-align: center;
  172. color: white;
  173. }
  174. .wrap-container {
  175. width: 432px;
  176. height: 400px;
  177. .chartsdom {
  178. width: 100%;
  179. height: 100%;
  180. }
  181. }
  182. </style>

五、工程代码

参考下载地址:

网站建设定制开发 软件系统开发定制 定制软件开发 软件开发定制 定制app开发 app开发定制 app开发定制公司 电商商城定制开发 定制小程序开发 定制开发小程序 客户管理系统开发定制 定制网站 定制开发 crm开发定制 开发公司 小程序开发定制 定制软件 收款定制开发 企业网站定制开发 定制化开发 android系统定制开发 定制小程序开发费用 定制设计 专注app软件定制开发 软件开发定制定制 知名网站建设定制 软件定制开发供应商 应用系统定制开发 软件系统定制开发 企业管理系统定制开发 系统定制开发