深圳全飞鸿

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 539|回复: 0
打印 上一主题 下一主题

echart 之line的一种案例

[复制链接]

800

主题

1379

帖子

7704

积分

版主

Rank: 7Rank: 7Rank: 7

积分
7704
跳转到指定楼层
楼主
发表于 2021-12-18 17:31:38 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式


function echarts_4() {

  1. // 基于准备好的dom,初始化echarts实例
  2. var myChart = echarts.init(document.getElementById('echart4'));

  3. option = {
  4.         tooltip: {
  5.                 trigger: 'axis',
  6.                 axisPointer: {
  7.                         lineStyle: {
  8.                                 color: '#dddc6b'
  9.                         }
  10.                 }
  11.         },
  12.         
  13.         legend: {
  14.                 top:'0%',
  15.         data:['沙井','越南'],
  16.                 textStyle: {
  17.                         color: 'rgba(255,255,255,.5)',
  18.                         fontSize:'12',
  19.         }
  20.     },
  21.         
  22.     grid: {
  23.         left: '10',
  24.                 top: '30',
  25.         right: '10',
  26.         bottom: '10',
  27.         containLabel: true
  28.     },

  29.     xAxis: [{
  30.         type: 'category',
  31.         boundaryGap: false,
  32.                 axisLabel:  {
  33.                 textStyle: {
  34.                                          color: "rgba(255,255,255,.6)",
  35.                                         fontSize:12,
  36.                 },
  37.             },
  38.         axisLine: {
  39.                         lineStyle: {
  40.                                 color: 'rgba(255,255,255,.2)'
  41.                         }

  42.         },
  43.                 data: ['01', '02', '03', '04', '05', '06', '07', '08', '09', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24']

  44.                 }, {

  45.         axisPointer: {show: false},
  46.         axisLine: {  show: false},
  47.         position: 'bottom',
  48.         offset: 20,

  49.       

  50.     }],

  51.     yAxis: [{
  52.         type: 'value',
  53.         axisTick: {show: false},
  54.         axisLine: {
  55.             lineStyle: {
  56.                 color: 'rgba(255,255,255,.1)'
  57.             }
  58.         },
  59.        axisLabel:  {
  60.                 textStyle: {
  61.                                          color: "rgba(255,255,255,.6)",
  62.                                         fontSize:12,
  63.                 },
  64.             },

  65.         splitLine: {
  66.             lineStyle: {
  67.                  color: 'rgba(255,255,255,.1)'
  68.             }
  69.         }
  70.     }],
  71.         
  72.     series: [
  73.                 {
  74.         name: '沙井',
  75.         type: 'line',
  76.         smooth: true,
  77.         symbol: 'circle',
  78.         symbolSize: 5,
  79.         showSymbol: false,
  80.         lineStyle: {
  81.                         
  82.             normal: {
  83.                                 color: '#0184d5',
  84.                 width: 2
  85.             }
  86.         },
  87.         areaStyle: {
  88.             normal: {
  89.                 color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  90.                     offset: 0,
  91.                     color: 'rgba(1, 132, 213, 0.4)'
  92.                 }, {
  93.                     offset: 0.8,
  94.                     color: 'rgba(1, 132, 213, 0.1)'
  95.                 }], false),
  96.                 shadowColor: 'rgba(0, 0, 0, 0.1)',
  97.             }
  98.         },
  99.                         itemStyle: {
  100.                         normal: {
  101.                                 color: '#0184d5',
  102.                                 borderColor: 'rgba(221, 220, 107, .1)',
  103.                                 borderWidth: 12
  104.                         }
  105.                 },
  106.          data: [527000, 437000, 545000, 456000, 488000, 291000, 533000, 677000, 668000, 543000, 599000, 420000, 450000, 567000, 535000, 418000, 399000, 387000, 498003, 577700, 500000, 417000, 399000, 388000]

  107.                 },
  108.                 {
  109.         name: '越南',
  110.         type: 'line',
  111.         smooth: true,
  112.         symbol: 'circle',
  113.         symbolSize: 5,
  114.         showSymbol: false,
  115.         lineStyle: {
  116.                         
  117.             normal: {
  118.                                 color: '#00d8d7',
  119.                 width: 2
  120.             }
  121.         },
  122.         areaStyle: {
  123.             normal: {
  124.                 color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  125.                     offset: 0,
  126.                     color: 'rgba(0, 216, 135, 0.4)'
  127.                 }, {
  128.                     offset: 0.8,
  129.                     color: 'rgba(0, 216, 135, 0.1)'
  130.                 }], false),
  131.                 shadowColor: 'rgba(0, 0, 0, 0.1)',
  132.             }
  133.         },
  134.                 itemStyle: {
  135.                         normal: {
  136.                                 color: '#00d8d7',
  137.                                 borderColor: 'rgba(221, 220, 107, .1)',
  138.                                 borderWidth: 12
  139.                         }
  140.                 },
  141.         data: [127000, 237000, 145000, 156000, 188000, 99000, 133000, 177000, 168000, 143000, 199000, 220000, 250000, 267000, 235000, 218000, 199000, 187000, 198003, 177700, 200000, 217000, 199000, 188000]

  142.                 },
  143.         ]

  144. };
  145.       
  146. // 使用刚指定的配置项和数据显示图表。
  147. myChart.setOption(option);
  148. window.addEventListener("resize",function(){
  149.         myChart.resize();
  150. });
  151.    
复制代码

}

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|nagomes  

GMT+8, 2025-5-5 00:32 , Processed in 0.028722 second(s), 24 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表