ECharts Version 3.0 - Waterfall Chart #2

In this example below you will see how to do a ECharts Version 3.0 - Waterfall Chart #2 with some HTML / CSS and Javascript

Example of ECharts 3.0 waterfall chart. ECharts is a really cool open source charting and visualization library from the team of Baidu EFE - http://efe.baidu.com/.

Thumbnail
This awesome code was written by WebCodePro, you can see more from this user in the personal repository.
You can find the original code on Codepen.io
Copyright WebCodePro ©
  • HTML
  • CSS
  • JavaScript
<!DOCTYPE html>
<html lang="en" >

<head>
  <meta charset="UTF-8">
  <title>ECharts Version 3.0 - Waterfall Chart #2</title>
  <!--[if lt IE 9]><script async src="https://cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js"></script><![endif]-->
  
  
      <link rel="stylesheet" href="css/style.css">

  
</head>

<body>

  <!-- Must specify width and height of DOM, ref CSS -->
<div id="main"></div>
  <script src='https://s3-us-west-2.amazonaws.com/s.cdpn.io/95368/echarts.english.min.js'></script>

  

    <script  src="js/index.js"></script>




</body>

</html>

/*Downloaded from https://www.codeseek.co/WebCodePro/echarts-version-30-waterfall-chart-2-eJXYzz */
body {
	background-color: #fff;
	font-family: Arial, Helvetica, sans-serif;
	font-size: 16px; 
	color: #000;
}

a:link, a:visited {
	color: #4682b4;
}

a:hover {
	color: #4169e1;
}

#main	{
	width: 1000px;
	height: 800px;
}

/*Downloaded from https://www.codeseek.co/WebCodePro/echarts-version-30-waterfall-chart-2-eJXYzz */
        // based ready dom, initialize echarts instance 
		var myChart = echarts.init(document.getElementById('main'));

        // Specify configurations and data graphs 
        var option = {
    title: {
        text: 'Ladder Waterfall',
        subtext: 'From ExcelHome',
        sublink: 'http://e.weibo.com/1341556070/Aj1J2x5a5'
    },
    tooltip : {
        trigger: 'axis',
        axisPointer : {            // 坐标轴指示器,坐标轴触发有效
            type : 'shadow'        // 默认为直线,可选为:'line' | 'shadow'
        },
        formatter: function (params) {
            var tar;
            if (params[1].value != '-') {
                tar = params[1];
            }
            else {
                tar = params[0];
            }
            return tar.name + '<br/>' + tar.seriesName + ' : ' + tar.value;
        }
    },
    legend: {
        data:['Expenditure','Income']
    },
    grid: {
        left: '3%',
        right: '4%',
        bottom: '3%',
        containLabel: true
    },
    xAxis : [
        {
            type : 'category',
            splitLine: {show:false},
            data :  function (){
                var list = [];
                for (var i = 1; i <= 11; i++) {
                    list.push('11 Month ' + i + ' Day');
                }
                return list;
            }()
        }
    ],
    yAxis : [
        {
            type : 'value'
        }
    ],
    series : [
        {
            name:'Aid',
            type:'bar',
            stack: 'Total',
            itemStyle:{
                normal:{
                    barBorderColor:'rgba(0,0,0,0)',
                    color:'rgba(0,0,0,0)'
                },
                emphasis:{
                    barBorderColor:'rgba(0,0,0,0)',
                    color:'rgba(0,0,0,0)'
                }
            },
            data:[0, 900, 1245, 1530, 1376, 1376, 1511, 1689, 1856, 1495, 1292]
        },
        {
            name:'Income',
            type:'bar',
            stack: 'Total',
            itemStyle : { normal: {label : {show: true, position: 'top'}}},
            data:[900, 345, 393, '-', '-', 135, 178, 286, '-', '-', '-']
        },
        {
            name:'Expenditure',
            type:'bar',
            stack: 'Total',
            itemStyle : { normal: {label : {show: true, position: 'bottom'}}},
            data:['-', '-', '-', 108, 154, '-', '-', '-', 119, 361, 203]
        }
    ]
};

		// Use just the specified configurations and data charts. 
		myChart.setOption(option);

Comments