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

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

6322人阅读 2020/5/16 21:31 总访问:5406113 评论: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)

评价

echarts中tooltip 基本样式问题处理

在echarts中遇到几个样式问题,现总结如下:1、tooltip中样式中 值换行在tooltip中修改加上一句代码formatter:&#39;{b0}:{c...

ionic3实战使用echarts图表(柱状图)

在公司有些东西需要投到大屏幕上去显示,也就是电视显示屏(安卓版的),但是我没普通的html代码并不能打包到上去安装使用...

echats 边距间距。echart设置图表边距间距

echart设置边距是使用grid //设置图标边距 grid: { top: &#39;10%&#39;, left: &#39;3%&#39;, right: &#3...

echats设置x坐标从0开始设置x坐标从原点开始。echart文档中的搜索

在x坐标设置boundaryGap: false即可. 官方文档:https://echarts.apache.org/zh/option.html#xAxis.boundaryGap 可以直接...

echarts 显示坐标点。echarts 自定义显示坐标点。echarts 个性化坐标提升显示

最简单的显示出来,直接在series中对应的数据项里边设置一下label即可label: { show: true, position: &#39;top&...

echarts自定义图表提示框。鼠标指上去显示。echarts tooltip的使用

官方文档:https://echarts.apache.org/zh/option.html#tooltip 使用的是tooltip,如果只是要显示出来,直接设置trigger: ...

echarts修改横纵坐标颜色。修改折线图线的宽度

echarts修改横坐标颜色代码主要是这样的 axisLine:{ lineStyle:{ ...

echarts图例legend颜色各不相同图例legend空心圆

代码如下:legend: { // x:&#39;right&#39;, //可设定图例在左、右、居中 // padding:[0,50,0,0], //...

echarts折线图使用示例。包含颜色渐变节点样式图例legend样式等

设计图如下 代码如下&lt;!-- 学习趋势图 --&gt; &lt;template&gt; &lt;div class=&quot;learnTrendChartContainer&q...

echarts提示框tooltip属性

tooltip: { show: true, // 是否显示提示框组件 trigger: &#39;axis&#39;, // 触发类型(&#39;item&#39;,...

echarts 仪表盘gauge颜色渐变。echarts圆环进度条。echarts圆环进度条弧形

效果如下: 配置项代码如下// 基于准备好的dom,初始化echarts实例 const myChart = this.$echarts.init(document.getEl...

echarts 设置x坐标刻度的颜色

是使用axisLabel下面的颜色设置,不是nameTextStyle不要搞混了。nameTextStyle官方解释是坐标轴名称的文字样式,要和坐标轴...

echarts setoption 不重新渲染

Echarts渲染的逻辑如果 echarts 未实例化则进⾏实例化过程,⼀旦实例化,便会在div容器⽣成⼀个 echarts_instance属性,该...

echarts 图表颜色设置饼图颜色渐变

[TOC]echarts 图表颜色设置在外层加一个color数组就行了 color:[&quot;#1890FF&quot;,&quot;#91CB74&quot;,&quot;#FAC858&...

echarts饼图通过grid设置位置不生效。饼图设置位置

grid 记得是平面直角坐标系的意思,而仪表盘、饼图这种,是通过设置中心点位置的方式定位的。所以仪表盘、饼图这种应该这样...