浅谈Echarts 使用配置

古城微笑少年丶 2022-08-20 12:19 286阅读 0赞

官方文档

一、Echarts折线图的配置

(1)去掉折线图的边框线及其加入阴影效果
  1. lineStyle: {
  2. normal: {
  3. type: 'solid',
  4. /*color:"#28a5fc",*/
  5. color:"red",
  6. opacity :"0.5"
  7. }
  8. }

如下图所示:
这里写图片描述


(2)设置移动折线图的 “上下左右” 的位置

代码片段:

  1. grid:{
  2. x:40,
  3. y:20,
  4. x2:20,
  5. y2:60,
  6. show:true, //表示开启
  7. borderColor:"#e4e4e4",//折线图的边宽颜色
  8. shadowBlur:50,
  9. containLabel:50,
  10. }

(3)设置折线图的 “x轴的、y轴” 数值区域
  1. {
  2. type: 'value',
  3. max: 80,//区域最大值,同时还可设置[0,'100%'],来自适应最大值
  4. interval:20,//每隔区域20
  5. axisLabel:{
  6. textStyle:{
  7. color:"#a7aab3"//x轴,y轴的数字颜色,如图1
  8. }
  9. },
  10. axisLine:{
  11. //x轴、y轴的深色轴线,如图2
  12. show: true,
  13. lineStyle:{
  14. color:"red",
  15. }
  16. },axisTick:{
  17. //图3所示
  18. show: false,
  19. }
  20. }

图1:
这里写图片描述

图2:
这里写图片描述

图3:
这里写图片描述


(4)网格边框线(y轴内绘边框线)
  1. splitLine: {
  2. //终于找到了,背景图的内置表格中“边框”的颜色线条 这个是x跟y轴轴的线
  3. show: true,
  4. lineStyle:{
  5. color:"#e4e4e4",
  6. type:"solid"
  7. }
  8. }

如下图所示:

y轴内绘边框线

网格边框线(x轴内绘边框线)

X轴内绘边框线


(5)x轴跟y轴的颜色及其字体
  1. axisLabel:{
  2. show:true,
  3. textStyle:{
  4. fontSize:"8px",
  5. color:"red",
  6. align:"center"
  7. },formatter:function(e){
  8. return e;
  9. }
  10. }

如图所示:
这里写图片描述

(6)轴体颜色渐变效果
  1. normal: {
  2. color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{ offset: 0, color: 'rgba(40, 182, 252, 0.85)' }, { offset: 1, color: 'rgba(28, 159, 255, 0.2)' }]) }

效果图:

这里写图片描述

这里写图片描述

最后效果代码附上:
  1. option = {
  2. tooltip : {
  3. trigger: 'axis'
  4. },
  5. title: {
  6. x: 'center',
  7. text: '',
  8. }
  9. ,legend: {
  10. top: 'bottom',
  11. data:['意向'],
  12. },grid:{
  13. x:10,
  14. y:20,
  15. x2:30,
  16. y2:20,
  17. show:true,
  18. borderColor:"#e4e4e4",//网格边框线
  19. shadowColor:"#e4e4e4",
  20. borderWidth:"0.2",
  21. containLabel:true,
  22. },toolbox: {
  23. show: true,
  24. feature: {
  25. mark: {show: true},
  26. dataView: {show: true, readOnly: false},
  27. magicType: {show: true, type: ['line', 'bar', 'stack', 'tiled']},
  28. restore: {show: true},
  29. saveAsImage: {show: true}
  30. }
  31. },xAxis: [
  32. {
  33. type: 'category',
  34. splitNumber:6,
  35. boundaryGap: false,
  36. data: date,
  37. axisLabel:{
  38. textStyle:{
  39. color:"#a7aab3"
  40. }
  41. },
  42. axisLine:{
  43. //x轴的横坐标边框线
  44. show: false
  45. },axisTick:{
  46. show: false,
  47. },axisLabel:{
  48. show:true,
  49. textStyle:{
  50. fontSize:"8px",
  51. color:"#a7aab3",
  52. align:"center"
  53. },formatter:function(e){
  54. return e;
  55. }
  56. },
  57. splitLine: {
  58. //终于找到了,背景图的内置表格中“边框”的颜色线条 这个是x轴的竖线
  59. show: true,
  60. lineStyle:{
  61. color:"#e4e4e4",
  62. type:"solid"
  63. }
  64. }
  65. }
  66. ],yAxis: [
  67. {
  68. type: 'value',
  69. max: yAxisMax,
  70. splitNumber:5,
  71. interval:interval,
  72. axisLabel:{
  73. textStyle:{
  74. color:"#a7aab3"
  75. },
  76. },
  77. axisLine:{
  78. show: true,
  79. lineStyle:{
  80. color:"#e4e4e4"
  81. }
  82. },axisTick:{
  83. show: false,
  84. },axisLabel:{
  85. show:true,
  86. textStyle:{
  87. fontSize:"8px",
  88. color:"#a7aab3"
  89. }
  90. },splitLine: {
  91. //终于找到了,背景图的内置表格中“边框”的颜色线条 这个是y轴的横线
  92. show: true,
  93. lineStyle:{
  94. color:"#e4e4e4",
  95. type:"solid",
  96. }
  97. }
  98. }
  99. ],dataZoom: {
  100. type: 'inside',
  101. start: 23,
  102. end: 100,
  103. },lineStyle: {
  104. normal: {
  105. type: 'solid',
  106. color:"#28a5fc",
  107. opacity :"0.5"
  108. }
  109. },
  110. backgroundColor:"#FFFFFF",//背景颜色
  111. borderWidth:0.1,
  112. series: [
  113. {
  114. name:'成交',
  115. type:'line',
  116. /*smooth:true,//true,表示曲线,false,表示折线 symbol: 'none',//是否显示折线图气泡*/
  117. stack: 'a',
  118. show :false,
  119. lineStyle:{
  120. //折线的颜色
  121. normal: {
  122. color:"#1ba0fc",
  123. width:1.5,
  124. //shadowBlur:80
  125. },
  126. },
  127. areaStyle: {
  128. normal: {
  129. color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  130. offset: 0,
  131. color: 'rgba(40, 182, 252, 0.85)'
  132. }, {
  133. offset: 1,
  134. color: 'rgba(28, 159, 255, 0.2)'
  135. }])
  136. }
  137. },itemStyle:{
  138. normal:{
  139. color:"#e4e4e4",
  140. barBorderColor:"#e4e4e4",
  141. }
  142. },
  143. data: data
  144. }
  145. ]
  146. };

这里写图片描述


(7)文案与轴线的距离
  1. xAxis: [{
  2. axisLabel: {
  3. textStyle: {
  4. color: "#a7aab3",
  5. fontSize: "18",
  6. },
  7. margin: 16,//刻度标签与轴线之间的距离。
  8. }
  9. }],

文案与轴线间的距离


(8)文案与轴线的距离
  1. markPoint: {
  2. symbolSize:60,//标记的大小
  3. label:{
  4. normal:{
  5. textStyle:{
  6. fontSize: 19,//文字的大小
  7. }
  8. }
  9. }
  10. }

文案与轴线的距离


二、饼图的配置

(9)饼图字体大小修改 fontSize
  1. series: [{
  2. name: '比例',
  3. type: 'pie',
  4. radius: '55%',
  5. center: ['50%', '60%'],
  6. label: {
  7. normal: {
  8. formatter: '{b}:{c}: ({d}%)',
  9. textStyle: {
  10. fontWeight: 'normal',
  11. fontSize: 15
  12. }
  13. }
  14. }
  15. }]

发表评论

表情:
评论列表 (有 0 条评论,286人围观)

还没有评论,来说两句吧...

相关阅读

    相关 ActiveMQ与使用

    一、什么是消息中间件 消息中间件顾名思义实现的就是在两个系统或两个客户端之间进行消息传送 ![1468250-20190720125917002-1679869251.pn