应无所住,而生其心
排名
1
文章
860
粉丝
112
评论
163
net core webapi post传递参数
庸人 : 确实坑哈,我也是下班好了好几次,发现后台传递对象是可以的,但...
百度编辑器自定义模板
庸人 : 我建议换个编辑器,因为现在百度富文本已经停止维护了,用tinymec...
ICP备案 :渝ICP备18016597号-1
网站信息:2018-2025TNBLOG.NET
技术交流:群号656732739
联系我们:contact@tnblog.net
公网安备:50010702506256
欢迎加群交流技术

echart常用折线图,带面积渐变的折线图

5893人阅读 2020/5/16 21:31 总访问:5197139 评论:0 收藏:0 手机
分类: 前端

效果如下:

html:

  1. <div class="labroom-trend">
  2. <div class="labroom-trend-title">
  3. 实验完成趋势图
  4. </div>
  5. <div class="labroom-trend-content">
  6. <div id="labroom-trend-chart" class="labroom-trend-chart">
  7. </div>
  8. </div>
  9. </div>

样式也贴一点吧

  1. .labroom-trend {
  2. //height: 200px;
  3. // background-color: #ffabcd;
  4. .labroom-trend-title {
  5. font-size: 16px;
  6. font-family: MicrosoftYaHei-, MicrosoftYaHei;
  7. font-weight: normal;
  8. color: #393939;
  9. margin-bottom: 10px;
  10. }
  11. .labroom-trend-chart {
  12. // background-color: #ffabcd;
  13. height: 255px;
  14. width: 100%;
  15. }
  16. }

js,vue.js

  1. mounted() {
  2. this.testChart()
  3. },
  4. // 组件方法
  5. methods: {
  6. testChart() {
  7. // 基于准备好的dom,初始化echarts实例
  8. let myChart = this.$echarts.init(document.getElementById('labroom-trend-chart'))
  9. let option = {
  10. // 图表颜色设置
  11. color: ['#409EFF', '#00DDFF', '#37A2FF', '#FF0087', '#FFBF00'],
  12. // title: {
  13. // text: '学习时长趋势(日时长)',
  14. // textAlign: 'left',
  15. // left: '27px',
  16. // top: 10,
  17. // textStyle: {
  18. // fontSize: '16px',
  19. // fontFamily: 'Microsoft YaHei'
  20. // }
  21. // },
  22. grid: {
  23. top: '10%',
  24. left: '3%',
  25. right: '3%',
  26. bottom: '6%',
  27. containLabel: true
  28. },
  29. xAxis: {
  30. type: 'category',
  31. data: ['Mon', 'Tue', 'Wed', 'Thu'],
  32. //****************不留白,从原点开始**************
  33. boundaryGap: false // 不留白,从原点开始
  34. //data: ['Mon', 'Tue', 'Wed', 'Thu',"1","3","5","7","8","9"]
  35. },
  36. yAxis: {
  37. type: 'value'
  38. },
  39. series: [
  40. {
  41. data: [32, 51, 41, 49],
  42. //data: [32, 51, 41, 49,55,60,30,39,50,22],
  43. type: 'line',
  44. //显示出来折线图的面积
  45. areaStyle: {
  46. normal: {
  47. // 颜色渐变函数 前四个参数分别表示四个位置依次为左、下、右、上
  48. color: new this.$echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  49. offset: 0,
  50. color: 'rgba(80,141,255,0.39)'
  51. }, {
  52. offset: 0.34,
  53. color: 'rgba(56,155,255,0.25)'
  54. }, {
  55. offset: 1,
  56. color: 'rgba(38,197,254,0.00)'
  57. }])
  58. }
  59. }
  60. }
  61. ]
  62. };
  63. myChart.setOption(option);
  64. }
  65. }

在贴几个渐变颜色组合

一:
折线的颜色:#409EFF

  1. // 图表颜色设置
  2. color: ['#409EFF']

渐变色值:

  1. // 显示出来折线图的面积
  2. areaStyle: {
  3. normal: {
  4. // 颜色渐变函数 前四个参数分别表示四个位置依次为左、下、右、上
  5. color: new this.$echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  6. offset: 0,
  7. color: 'rgba(64,159,255,0.25)'
  8. }, {
  9. offset: 0.34,
  10. color: 'rgba(56,155,255,0.22)'
  11. }, {
  12. offset: 1,
  13. color: 'rgba(38,197,254,0.00)'
  14. }])
  15. }
  16. }

二:
折线的颜色:#8AABFF

渐变色值:

  1. // 显示出来折线图的面积
  2. areaStyle: {
  3. normal: {
  4. // 颜色渐变函数 前四个参数分别表示四个位置依次为左、下、右、上
  5. color: new this.$echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  6. offset: 0,
  7. color: 'rgba(138, 171, 255,0.25)'
  8. }, {
  9. offset: 0.34,
  10. color: 'rgba(35,160,255,0.22)'
  11. }, {
  12. offset: 1,
  13. color: 'rgba(32,126,255,0.00)'
  14. }])
  15. }
  16. }

三:
折线的颜色:#31C3F5

渐变色值:

  1. // 显示出来折线图的面积
  2. areaStyle: {
  3. normal: {
  4. // 颜色渐变函数 前四个参数分别表示四个位置依次为左、下、右、上
  5. color: new this.$echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  6. offset: 0,
  7. color: 'rgba(40, 205, 255,0.25)'
  8. }, {
  9. offset: 0.34,
  10. color: 'rgba(35,215,255,0.22)'
  11. }, {
  12. offset: 1,
  13. color: 'rgba(32,197,254,0.00)'
  14. }])
  15. }
  16. }

欢迎加群讨论技术,1群:677373950(满了,可以加,但通过不了),2群:656732739。有需要软件开发,或者学习软件技术的朋友可以和我联系~(Q:815170684)

评价