深圳全飞鸿

标题: echart 之bar的一种案例 [打印本页]

作者: zhgc    时间: 2021-12-18 17:41
标题: echart 之bar的一种案例


  1.         function char2() {

  2.                         var myChart = echarts.init($("#echart5")[0]);

  3.                         option = {
  4.                                   //backgroundColor: '#00265f',
  5.                                         tooltip : {
  6.                                                         trigger: 'axis',
  7.                                                         axisPointer : {            // 坐标轴指示器,坐标轴触发有效
  8.                                                                         type : 'shadow'        // 默认为直线,可选为:'line' | 'shadow'
  9.                                                         }
  10.                                         },
  11.                                         grid: {show:'true',borderWidth:'0'},
  12.                                         legend: {
  13.                                                         data:['缺勤','在岗','上班未上岗'],
  14.                                                         textStyle : {
  15.                                                                 fontSize: 12,
  16.                                                                 color : '#ffffff'
  17.                                                         },
  18.                                                         icon:"rect",
  19.                                                         itemWidth:10,
  20.                                                         itemHeight:10,
  21.                                                         bottom:"0%"
  22.                                         },

  23.                                         calculable :false,
  24.                                         xAxis : [
  25.                                                         {
  26.                                                                         type : 'value',
  27.                                                                         show:false,
  28.                                                                         axisLabel: {
  29.                                                                                         show: true,
  30.                                                                                         textStyle: {
  31.                                                                                                         color: '#fff'
  32.                                                                                         }
  33.                                                                         },
  34.                                                                         splitLine:{
  35.                                                                                 "show": false,
  36.                                                                                         lineStyle:{
  37.                                                                                                         color:['#f2f2f2'],
  38.                                                                                                         width:0,
  39.                                                                                                         type:'solid'
  40.                                                                                         }
  41.                                                                         }

  42.                                                         }
  43.                                         ],
  44.                                         yAxis : [
  45.                                                         {
  46.                                                                         type : 'category',
  47.                                                                         data : ['组装一课','组装二课','组装三课','组装四课','组装五课'],
  48.                                                                         axisLabel: {
  49.                                                                                         show: true,
  50.                                                                                         textStyle: {
  51.                                                                                                                  color: 'rgba(255,255,255,.5)',
  52.                                                                                                 fontSize:'12',
  53.                                                                                                         }
  54.                                                                         },
  55.                                                                         splitLine:{
  56.                                                                                         lineStyle:{
  57.                                                                                                         width:0,
  58.                                                                                                         type:'solid'
  59.                                                                                         }
  60.                                                                         }
  61.                                                         }
  62.                                         ],
  63.                                         series : [
  64.                                                         {
  65.                                                                         name:'缺勤',
  66.                                                                         type:'bar',
  67.                                                                         stack: '总量',
  68.                                                                         itemStyle : {
  69.                                                                                 normal: {
  70.                                                                                         label : {show: true, position: 'insideRight'},
  71.                                                                                         color:'#623AD1',
  72.                                                                                         opacity: 1,
  73.                                                                                         barBorderRadius: 6,
  74.                                                                         }},
  75.                                                                         data:[21, 17, 13,8,13]
  76.                                                         },
  77.                                                         {
  78.                                                                         name:'在岗',
  79.                                                                         type:'bar',
  80.                                                                         stack: '总量',
  81.                                                                         itemStyle : {
  82.                                                                                 normal: {
  83.                                                                                         label : {show: true, position: 'insideRight'},
  84.                                                                                         color:'#2f89cf',
  85.                                                                                         opacity: 1,
  86.                                                                                         barBorderRadius: 6,
  87.                                                                         }},
  88.                                                                         data:[122, 93, 117,100,98]
  89.                                                         },
  90.                                                         {
  91.                                                                         name:'上班未上岗',
  92.                                                                         type:'bar',
  93.                                                                         stack: '总量',
  94.                                                                         itemStyle : {
  95.                                                                                 normal: {
  96.                                                                                         label : {show: true, position: 'insideRight'},
  97.                                                                                         color:'#c23531',
  98.                                                                                         opacity: 1,
  99.                                                                                         barBorderRadius: 6,
  100.                                                                         }},
  101.                                                                         data:[21,8,13,25,17]
  102.                                                         },

  103.                                         ]
  104.                         };

  105.                         myChart.setOption(option);
  106.                         window.addEventListener('resize', function () {myChart.resize();})

  107.         }
复制代码





欢迎光临 深圳全飞鸿 (http://www.nagomes.com/disc/) Powered by Discuz! X3.2