123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724 |
- $(function() {
- "use strict";
- // ------------------------------
- // Basic pie chart
- // ------------------------------
- // based on prepared DOM, initialize echarts instance
- var basicpieChart = echarts.init(document.getElementById('basic-pie'));
- var option = {
- // Add title
- title: {
- text: 'A site user access source',
- subtext: 'Purely Fictitious',
- x: 'center'
- },
- // Add tooltip
- tooltip: {
- trigger: 'item',
- formatter: "{a} <br/>{b}: {c} ({d}%)"
- },
- // Add legend
- legend: {
- orient: 'vertical',
- x: 'left',
- data: ['Direct Access', 'Mail Marketing', 'Union ad', 'Video ad', 'Search Engine']
- },
- // Add custom colors
- color: ['#689f38', '#38649f', '#389f99', '#ee1044', '#ff8f00'],
- // Display toolbox
- toolbox: {
- show: true,
- orient: 'vertical',
- feature: {
- mark: {
- show: true,
- title: {
- mark: 'Markline switch',
- markUndo: 'Undo markline',
- markClear: 'Clear markline'
- }
- },
- dataView: {
- show: true,
- readOnly: false,
- title: 'View data',
- lang: ['View chart data', 'Close', 'Update']
- },
- magicType: {
- show: true,
- title: {
- pie: 'Switch to pies',
- funnel: 'Switch to funnel',
- },
- type: ['pie', 'funnel'],
- option: {
- funnel: {
- x: '25%',
- y: '20%',
- width: '50%',
- height: '70%',
- funnelAlign: 'left',
- max: 1548
- }
- }
- },
- restore: {
- show: true,
- title: 'Restore'
- },
- saveAsImage: {
- show: true,
- title: 'Same as image',
- lang: ['Save']
- }
- }
- },
- // Enable drag recalculate
- calculable: true,
- // Add series
- series: [{
- name: 'Marketing',
- type: 'pie',
- radius: '70%',
- center: ['50%', '57.5%'],
- data: [
- {value: 335, name: 'Direct Access'},
- {value: 310, name: 'Mail Marketing'},
- {value: 234, name: 'Union ad'},
- {value: 135, name: 'Video ad'},
- {value: 1548, name: 'Search Engine'}
- ]
- }]
- };
-
- basicpieChart.setOption(option);
- // ------------------------------
- // Basic pie chart
- // ------------------------------
- // based on prepared DOM, initialize echarts instance
- var basicdoughnutChart = echarts.init(document.getElementById('basic-doughnut'));
- var option = {
- // Add title
- title: {
- text: 'A site user access source',
- subtext: 'Purely Fictitious',
- x: 'center'
- },
- // Add legend
- legend: {
- orient: 'vertical',
- x: 'left',
- data: ['Direct Access', 'Mail Marketing', 'Union ad', 'Video ad', 'Search Engine']
- },
- // Add custom colors
- color: ['#689f38', '#38649f', '#389f99', '#ee1044', '#ff8f00'],
- // Display toolbox
- toolbox: {
- show: true,
- orient: 'vertical',
- feature: {
- mark: {
- show: true,
- title: {
- mark: 'Markline switch',
- markUndo: 'Undo markline',
- markClear: 'Clear markline'
- }
- },
- dataView: {
- show: true,
- readOnly: false,
- title: 'View data',
- lang: ['View chart data', 'Close', 'Update']
- },
- magicType: {
- show: true,
- title: {
- pie: 'Switch to pies',
- funnel: 'Switch to funnel',
- },
- type: ['pie', 'funnel'],
- option: {
- funnel: {
- x: '25%',
- y: '20%',
- width: '50%',
- height: '70%',
- funnelAlign: 'left',
- max: 1548
- }
- }
- },
- restore: {
- show: true,
- title: 'Restore'
- },
- saveAsImage: {
- show: true,
- title: 'Same as image',
- lang: ['Save']
- }
- }
- },
- // Enable drag recalculate
- calculable: true,
- // Add series
- series: [
- {
- name: 'Marketing',
- type: 'pie',
- radius: ['50%', '70%'],
- center: ['50%', '57.5%'],
- itemStyle: {
- normal: {
- label: {
- show: true
- },
- labelLine: {
- show: true
- }
- },
- emphasis: {
- label: {
- show: true,
- formatter: '{b}' + '\n\n' + '{c} ({d}%)',
- position: 'center',
- textStyle: {
- fontSize: '17',
- fontWeight: '500'
- }
- }
- }
- },
- data: [
- {value: 335, name: 'Direct Access'},
- {value: 310, name: 'Mail Marketing'},
- {value: 234, name: 'Union ad'},
- {value: 135, name: 'Video ad'},
- {value: 1548, name: 'Search Engine'}
- ]
- }
- ]
- };
-
- basicdoughnutChart.setOption(option);
- // ------------------------------
- // customized chart
- // ------------------------------
- // based on prepared DOM, initialize echarts instance
- var customizedChart = echarts.init(document.getElementById('customized-chart'));
- var option = {
-
- backgroundColor: '#fff',
- title: {
- text: 'Customized Pie',
- left: 'center',
- top: 20,
- textStyle: {
- color: '#ccc'
- }
- },
- tooltip : {
- trigger: 'item',
- formatter: "{a} <br/>{b} : {c} ({d}%)"
- },
- visualMap: {
- show: false,
- min: 80,
- max: 600,
- inRange: {
- colorLightness: [0, 1]
- }
- },
- series : [
- {
- name:'Marketing',
- type:'pie',
- radius : '55%',
- center: ['50%', '50%'],
- data:[
- {value:335, name:'Direct Access'},
- {value:310, name:'Mail Marketing'},
- {value:274, name:'Union ad'},
- {value:235, name:'Video ad'},
- {value:400, name:'Search Engine'}
- ].sort(function (a, b) { return a.value - b.value; }),
- roseType: 'radius',
- label: {
- normal: {
- textStyle: {
- color: 'rgba(0, 0, 0, 0.3)'
- }
- }
- },
- labelLine: {
- normal: {
- lineStyle: {
- color: 'rgba(0, 0, 0, 0.3)'
- },
- smooth: 0.2,
- length: 10,
- length2: 20
- }
- },
- itemStyle: {
- normal: {
- color: '#38649f',
- shadowBlur: 200,
- shadowColor: 'rgba(0, 0, 0, 0.5)'
- }
- },
- animationType: 'scale',
- animationEasing: 'elasticOut',
- animationDelay: function (idx) {
- return Math.random() * 200;
- }
- }
- ]
- };
-
-
- customizedChart.setOption(option);
- // ------------------------------
- // Nested chart
- // ------------------------------
- // based on prepared DOM, initialize echarts instance
- var nestedChart = echarts.init(document.getElementById('nested-pie'));
- var option = {
-
- tooltip: {
- trigger: 'item',
- formatter: "{a} <br/>{b}: {c} ({d}%)"
- },
- // Add legend
- legend: {
- orient: 'vertical',
- x: 'left',
- data: ['Direct','Marketing Advertising','Search Engine','Mail Marketing','Union ad','Video ad','Baidu','Google','Bing','Other']
- },
- // Add custom colors
- color: ['#689f38', '#38649f', '#389f99', '#ee1044', '#ff8f00'],
- // Display toolbox
- toolbox: {
- show: true,
- orient: 'vertical',
- feature: {
- mark: {
- show: true,
- title: {
- mark: 'Markline switch',
- markUndo: 'Undo markline',
- markClear: 'Clear markline'
- }
- },
- dataView: {
- show: true,
- readOnly: false,
- title: 'View data',
- lang: ['View chart data', 'Close', 'Update']
- },
- magicType: {
- show: true,
- title: {
- pie: 'Switch to pies',
- funnel: 'Switch to funnel',
- },
- type: ['pie', 'funnel']
- },
- restore: {
- show: true,
- title: 'Restore'
- },
- saveAsImage: {
- show: true,
- title: 'Same as image',
- lang: ['Save']
- }
- }
- },
- // Enable drag recalculate
- calculable: false,
- // Add series
- series: [
- // Inner
- {
- name: 'Countries',
- type: 'pie',
- selectedMode: 'single',
- radius: [0, '40%'],
- // for funnel
- x: '15%',
- y: '7.5%',
- width: '40%',
- height: '85%',
- funnelAlign: 'right',
- max: 1548,
- itemStyle: {
- normal: {
- label: {
- position: 'inner'
- },
- labelLine: {
- show: false
- }
- },
- emphasis: {
- label: {
- show: true
- }
- }
- },
- data: [
- {value: 535, name: 'Direct'},
- {value: 679, name: 'Marketing ad'},
- {value: 1548, name: 'Search Engine'}
- ]
- },
- // Outer
- {
- name: 'Countries',
- type: 'pie',
- radius: ['60%', '85%'],
- // for funnel
- x: '55%',
- y: '7.5%',
- width: '35%',
- height: '85%',
- funnelAlign: 'left',
- max: 1048,
- data: [
- {value:335, name: 'Direct'},
- {value:310, name: 'Mail Marketing'},
- {value:234, name: 'Union ad'},
- {value:135, name: 'Video ad'},
- {value:1048, name: 'Baidu'},
- {value:251, name:'Google'},
- {value:147, name: 'Bing'},
- {value:102, name:'Other'}
- ]
- }
- ]
- };
-
-
- nestedChart.setOption(option);
- // ------------------------------
- // pole chart
- // ------------------------------
- // based on prepared DOM, initialize echarts instance
- var poleChart = echarts.init(document.getElementById('pole-chart'));
- // Data style
- var dataStyle = {
- normal: {
- label: {show: false},
- labelLine: {show: false}
- }
- };
- // Placeholder style
- var placeHolderStyle = {
- normal: {
- color: 'rgba(0,0,0,0)',
- label: {show: false},
- labelLine: {show: false}
- },
- emphasis: {
- color: 'rgba(0,0,0,0)'
- }
- };
- var option = {
- title: {
- text: 'Stacked histogram',
- subtext: 'Weekly Data',
- x: 'center',
- y: 'center',
- itemGap: 10,
- textStyle: {
- color: 'rgba(30,144,255,0.8)',
- fontSize: 19,
- fontWeight: '500'
- }
- },
- // Add tooltip
- tooltip: {
- show: true,
- formatter: "{a} <br/>{b}: {c} ({d}%)"
- },
- // Add legend
- legend: {
- orient: 'vertical',
- x: document.getElementById('pole-chart').offsetWidth / 2,
- y: 30,
- x: '55%',
- itemGap: 15,
- data: ['Monday','Tuesday','Wednesday']
- },
- // Add custom colors
- color: ['#689f38', '#38649f', '#ff8f00'],
-
- // Add series
- series: [
- {
- name: '1',
- type: 'pie',
- clockWise: false,
- radius: ['75%', '90%'],
- itemStyle: dataStyle,
- data: [
- {
- value: 60,
- name: 'Monday'
- },
- {
- value: 40,
- name: 'invisible',
- itemStyle: placeHolderStyle
- }
- ]
- },
- {
- name: '2',
- type:'pie',
- clockWise: false,
- radius: ['60%', '75%'],
- itemStyle: dataStyle,
- data: [
- {
- value: 30,
- name: 'Tuesday'
- },
- {
- value: 70,
- name: 'invisible',
- itemStyle: placeHolderStyle
- }
- ]
- },
- {
- name: '3',
- type: 'pie',
- clockWise: false,
- radius: ['45%', '60%'],
- itemStyle: dataStyle,
- data: [
- {
- value: 10,
- name: 'Wednesday'
- },
- {
- value: 90,
- name: 'invisible',
- itemStyle: placeHolderStyle
- }
- ]
- }
- ]
- };
- poleChart.setOption(option);
- // ------------------------------
- // nightingale chart
- // ------------------------------
- // based on prepared DOM, initialize echarts instance
- var nightingaleChart = echarts.init(document.getElementById('nightingale-chart'));
- var option = {
- title: {
- text: 'Ningdinger Rose Map',
- subtext: 'Purely fictitious',
- x: 'center'
- },
- // Add tooltip
- tooltip: {
- trigger: 'item',
- formatter: "{a} <br/>{b}: +{c}$ ({d}%)"
- },
- // Add legend
- legend: {
- x: 'left',
- y: 'top',
- orient: 'vertical',
- data:['rose1','rose2','rose3','rose4','rose5','rose6','rose7','rose8']
- },
- color: ['#689f38', '#e4eaec', '#38649f', '#389f99', '#ee1044', '#ff8f00', '#673ab7', '#4974e0'],
- // Display toolbox
- toolbox: {
- show: true,
- orient: 'vertical',
- feature: {
- mark: {
- show: true,
- title: {
- mark: 'Markline switch',
- markUndo: 'Undo markline',
- markClear: 'Clear markline'
- }
- },
- dataView: {
- show: true,
- readOnly: false,
- title: 'View data',
- lang: ['View chart data', 'Close', 'Update']
- },
- magicType: {
- show: true,
- title: {
- pie: 'Switch to pies',
- funnel: 'Switch to funnel',
- },
- type: ['pie', 'funnel']
- },
- restore: {
- show: true,
- title: 'Restore'
- },
- saveAsImage: {
- show: true,
- title: 'Same as image',
- lang: ['Save']
- }
- }
- },
- // Enable drag recalculate
- calculable: true,
- // Add series
- series: [
- {
- name: 'Area Mode',
- type: 'pie',
- radius: ['15%', '73%'],
- center: ['50%', '57%'],
- roseType: 'area',
- // Funnel
- width: '40%',
- height: '78%',
- x: '30%',
- y: '17.5%',
- max: 450,
- sort: 'ascending',
- data: [
- {value: 440, name: 'rose1'},
- {value: 260, name: 'rose2'},
- {value: 350, name: 'rose3'},
- {value: 250, name: 'rose4'},
- {value: 210, name: 'rose5'},
- {value: 350, name: 'rose6'},
- {value: 300, name: 'rose7'},
- {value: 450, name: 'rose8'}
- ]
- }
- ]
- };
- nightingaleChart.setOption(option);
-
-
- // ------------------------------
- // bar-polar-stack-radial
- // ------------------------------
-
- var dom = document.getElementById("bar-polar-stack-radial");
- var myChart = echarts.init(dom);
- var app = {};
- option = null;
- app.title = 'Stacked bar chart in polar coordinate system';
- option = {
- color: ['#689f38', '#38649f', '#389f99'],
- angleAxis: {
- type: 'category',
- data: ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'],
- z: 10
- },
- radiusAxis: {
- },
- polar: {
- },
- series: [{
- type: 'bar',
- data: [1, 2, 3, 4, 3, 5, 1],
- coordinateSystem: 'polar',
- name: 'A',
- stack: 'a'
- }, {
- type: 'bar',
- data: [2, 4, 6, 1, 3, 2, 1],
- coordinateSystem: 'polar',
- name: 'B',
- stack: 'a'
- }, {
- type: 'bar',
- data: [1, 2, 3, 4, 1, 2, 5],
- coordinateSystem: 'polar',
- name: 'C',
- stack: 'a'
- }],
- legend: {
- show: true,
- data: ['A', 'B', 'C']
- }
- };
- if (option && typeof option === "object") {
- myChart.setOption(option, true);
- }
- //------------------------------------------------------
- // 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
- basicpieChart.resize();
- basicdoughnutChart.resize();
- customizedChart.resize();
- nestedChart.resize();
- poleChart.resize();
- }, 200);
- }
- });
- });
|