123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360 |
- $(function() {
- "use strict";
- // ------------------------------
- // Basic bar chart
- // ------------------------------
- // based on prepared DOM, initialize echarts instance
- var myChart = echarts.init(document.getElementById('basic-bar'));
- // specify chart configuration item and data
- var option = {
- // Setup grid
- grid: {
- left: '1%',
- right: '2%',
- bottom: '3%',
- containLabel: true
- },
- // Add Tooltip
- tooltip : {
- trigger: 'axis'
- },
- legend: {
- data:['Site A','Site B']
- },
- toolbox: {
- show : true,
- feature : {
- magicType : {show: true, type: ['line', 'bar']},
- restore : {show: true},
- saveAsImage : {show: true}
- }
- },
- color: ["#38649f", "#389f99"],
- calculable : true,
- xAxis : [
- {
- type : 'category',
- data : ['Jan','Feb','Mar','Apr','May','Jun','July','Aug','Sept','Oct','Nov','Dec']
- }
- ],
- yAxis : [
- {
- type : 'value'
- }
- ],
- series : [
- {
- name:'Site A',
- type:'bar',
- data:[7.2, 5.3, 6.1, 32.1, 23.1, 89.2, 158.4, 178.1, 36.4, 22.7, 7.1, 9.4],
- markPoint : {
- data : [
- {type : 'max', name: 'Max'},
- {type : 'min', name: 'Min'}
- ]
- },
- markLine : {
- data : [
- {type : 'average', name: 'Average'}
- ]
- }
- },
- {
- name:'Site B',
- type:'bar',
- data:[19.4, 7.9, 8.9, 27.9, 24.8, 88.1, 167.8, 197.5, 47.1, 16.7, 7.1, 1.5],
- markPoint : {
- data : [
- {name : 'The highest year', value : 182.2, xAxis: 7, yAxis: 183, symbolSize:18},
- {name : 'Year minimum', value : 2.3, xAxis: 11, yAxis: 3}
- ]
- },
- markLine : {
- data : [
- {type : 'average', name : 'Average'}
- ]
- }
- }
- ]
- };
- // use configuration item and data specified to show chart
- myChart.setOption(option);
-
-
- // ------------------------------
- // Stacked bar chart
- // ------------------------------
- // based on prepared DOM, initialize echarts instance
- var stackedChart = echarts.init(document.getElementById('stacked-bar'));
- // specify chart configuration item and data
- var option = {
- // Setup grid
- grid: {
- x: 40,
- x2: 40,
- y: 45,
- y2: 25
- },
- // Add tooltip
- tooltip : {
- trigger: 'axis',
- axisPointer : { // Axis indicator axis trigger effective
- type : 'shadow' // The default is a straight line, optionally: 'line' | 'shadow'
- }
- },
- // Add legend
- legend: {
- data: ['Data1', 'Data2', 'Data3', 'Data4', 'Data5']
- },
- // Add custom colors
- color: ['#689f38', '#38649f', '#389f99', '#ff8f00', '#ee1044'],
- // Horizontal axis
- xAxis: [{
- type: 'value',
- }],
- // Vertical axis
- yAxis: [{
- type: 'category',
- data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
- }],
- // Add series
- series : [
- {
- name:'Data1',
- type:'bar',
- stack: 'Total',
- itemStyle : { normal: {label : {show: true, position: 'insideRight'}}},
- data:[321, 269, 358, 369, 348, 312, 299]
- },
- {
- name:'Data2',
- type:'bar',
- stack: 'Total',
- itemStyle : { normal: {label : {show: true, position: 'insideRight'}}},
- data:[159, 147, 123, 136, 87, 199, 248]
- },
- {
- name:'Data3',
- type:'bar',
- stack: 'Total',
- itemStyle : { normal: {label : {show: true, position: 'insideRight'}}},
- data:[269, 248, 158, 325, 248, 279, 357]
- },
- {
- name:'Data4',
- type:'bar',
- stack: 'Total',
- itemStyle : { normal: {label : {show: true, position: 'insideRight'}}},
- data:[101, 198, 247, 136, 178, 388, 499]
- },
- {
- name:'Data5',
- type:'bar',
- stack: 'Total',
- itemStyle : { normal: {label : {show: true, position: 'insideRight'}}},
- data:[869, 965, 975, 752, 1254, 1458, 875]
- }
- ]
- };
- // use configuration item and data specified to show chart
- stackedChart.setOption(option);
-
-
- //***************************
- // Stacked chart
- //***************************
-
-
- //***************************
- // Stacked Area chart
- //***************************
- var stackedbarcolumnChart = echarts.init(document.getElementById('stacked-column'));
- var option = {
-
- // Setup grid
- grid: {
- x: 40,
- x2: 40,
- y: 45,
- y2: 25
- },
- // Add tooltip
- tooltip : {
- trigger: 'axis',
- axisPointer : { // Axis indicator axis trigger effective
- type : 'shadow' // The default is a straight line, optionally: 'line' | 'shadow'
- }
- },
- // Add legend
- legend: {
- data: [ 'Data1', 'Data2', 'Data3', 'Data4', 'Data5', 'Data7']
- },
- // Add custom colors
- color: ['#689f38', '#38649f', '#389f99', '#ff8f00', '#ee1044'],
- // Enable drag recalculate
- calculable: true,
- // Horizontal axis
- xAxis: [{
- type: 'category',
- data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
- }],
- // Vertical axis
- yAxis: [{
- type: 'value',
- }],
- // Add series
- series : [
-
- {
- name:'Data1',
- type:'bar',
- stack: 'data1',
- data:[178, 241, 210, 147, 299, 358, 487]
- },
- {
- name:'Data2',
- type:'bar',
- data:[875, 845, 985, 1254, 1425, 1235, 1425],
- markLine : {
- itemStyle:{
- normal:{
- lineStyle:{
- type: 'dashed'
- }
- }
- },
- data : [
- [{type : 'min'}, {type : 'max'}]
- ]
- }
- },
- {
- name:'Data3',
- type:'bar',
- barWidth : 12,
- stack: 'data',
- data:[654, 758, 754, 854, 1245, 1100, 1140]
- },
- {
- name:'Data4',
- type:'bar',
- stack: 'data',
- data:[104, 134, 125, 158, 245, 236, 278]
- },
- {
- name:'Data5',
- type:'bar',
- stack: 'data',
- data:[54, 123, 147, 85, 165, 158, 123]
- },
- {
- name:'Data6',
- type:'bar',
- stack: 'data',
- data:[21, 84, 79, 86, 135, 158, 210]
- }
- ]
- // Add series
-
- };
- stackedbarcolumnChart.setOption(option);
-
- // ------------------------------
- // Basic line chart
- // ------------------------------
- // based on prepared DOM, initialize echarts instance
- var barbasicChart = echarts.init(document.getElementById('bar-basic'));
- var option = {
- // Setup grid
- grid: {
- x: 60,
- x2: 40,
- y: 45,
- y2: 25
- },
- // Add tooltip
- tooltip: {
- trigger: 'axis'
- },
- // Add legend
- legend: {
- data: ['2018', '2019']
- },
- // Add custom colors
- color: ['#ee1044', '#389f99'],
- // Horizontal axis
- xAxis: [{
- type: 'value',
- boundaryGap: [0, 0.01]
- }],
- // Vertical axis
- yAxis: [{
- type: 'category',
- data: ['Data1', 'Data2', 'Data3', 'Data4', 'Data5', 'Data6']
- }],
- // Add series
- series : [
- {
- name:'2018',
- type:'bar',
- data:[845, 542, 348, 298, 548, 398]
- },
- {
- name:'2019',
- type:'bar',
- data:[689, 754, 498, 123, 489, 598]
- }
- ]
- };
- // use configuration item and data specified to show chart
- barbasicChart.setOption(option);
-
-
- //------------------------------------------------------
- // Resize chart on menu width change and window resize
- //------------------------------------------------------
- $(function () {
- // Resize chart on menu width change and window resize
- $(window).on('resize', resize);
- $(".sidebartoggler").on('click', resize);
- // Resize function
- function resize() {
- setTimeout(function() {
- // Resize chart
- myChart.resize();
- stackedChart.resize();
- stackedbarcolumnChart.resize();
- barbasicChart.resize();
- }, 200);
- }
- });
- });
|