$(function () { echarts_1(); echarts_2(); echarts_4(); echarts_31(); echarts_32(); echarts_33(); echarts_5(); echarts_6(); function echarts_1() { // 基于准备好的dom,初始化echarts实例 var myChart = echarts.init(document.getElementById('echart1')); option = { // backgroundColor: '#00265f', tooltip: { trigger: 'axis', axisPointer: { type: 'shadow' } }, grid: { left: '0%', top:'10px', right: '0%', bottom: '4%', containLabel: true }, xAxis: [{ type: 'category', data: ['魏晋', '南北朝', '隋代', '唐代', '五代', '宋代', '金朝'], axisLine: { show: true, lineStyle: { color: "rgba(255,255,255,.1)", width: 1, type: "solid" }, }, axisTick: { show: false, }, axisLabel: { interval: 0, // rotate:50, show: true, splitNumber: 15, textStyle: { color: "rgba(255,255,255,.6)", fontSize: '12', }, }, }], yAxis: [{ type: 'value', axisLabel: { //formatter: '{value} %' show:true, textStyle: { color: "rgba(255,255,255,.6)", fontSize: '12', }, }, axisTick: { show: false, }, axisLine: { show: true, lineStyle: { color: "rgba(255,255,255,.1 )", width: 1, type: "solid" }, }, splitLine: { lineStyle: { color: "rgba(255,255,255,.1)", } } }], series: [ { type: 'bar', data: [263, 456, 1263, 2300, 1756, 1564, 865], barWidth:'35%', //柱子宽度 // barGap: 1, //柱子之间间距 itemStyle: { normal: { color:'#2f89cf', opacity: 1, barBorderRadius: 5, } } } ] }; // 使用刚指定的配置项和数据显示图表。 myChart.setOption(option); window.addEventListener("resize",function(){ myChart.resize(); }); } function echarts_2() { // 基于准备好的dom,初始化echarts实例 var myChart = echarts.init(document.getElementById('echart2')); option = { // backgroundColor: '#00265f', tooltip: { trigger: 'axis', axisPointer: { type: 'shadow'} }, grid: { left: '0%', top:'10px', right: '0%', bottom: '4%', containLabel: true }, xAxis: [{ type: 'category', data: ['河南', '陕西', '河北', '江苏', '浙江', '山西', '山东'], axisLine: { show: true, lineStyle: { color: "rgba(255,255,255,.1)", width: 1, type: "solid" }, }, axisTick: { show: false, }, axisLabel: { interval: 0, // rotate:50, show: true, splitNumber: 15, textStyle: { color: "rgba(255,255,255,.6)", fontSize: '12', }, }, }], yAxis: [{ type: 'value', axisLabel: { //formatter: '{value} %' show:true, textStyle: { color: "rgba(255,255,255,.6)", fontSize: '12', }, }, axisTick: { show: false, }, axisLine: { show: true, lineStyle: { color: "rgba(255,255,255,.1 )", width: 1, type: "solid" }, }, splitLine: { lineStyle: { color: "rgba(255,255,255,.1)", } } }], series: [ { type: 'bar', data: [275, 217, 196, 170, 145, 139, 85], barWidth:'35%', //柱子宽度 // barGap: 1, //柱子之间间距 itemStyle: { normal: { color:'#27d08a', opacity: 1, barBorderRadius: 5, } } } ] }; // 使用刚指定的配置项和数据显示图表。 myChart.setOption(option); window.addEventListener("resize",function(){ myChart.resize(); }); } function echarts_5() { // 基于准备好的dom,初始化echarts实例 // var myChart = echarts.init(document.getElementById('echart5')); var myChart = echarts.init(document.getElementById('echart5'), null, {height: 220}); const data = []; for (let i = 0; i < 5; ++i) { data.push(Math.round(Math.random() * 200)); } option = { xAxis: { max: 'dataMax' }, yAxis: { type: 'category', data:['白居易','杜甫','李白','元稹','刘禹锡'], inverse: true, animationDuration: 300, animationDurationUpdate: 300, max: 4 // only the largest 3 bars will be displayed }, series: [ { realtimeSort: true, name: 'X', type: 'bar', data: data, label: { show: true, position: 'right', valueAnimation: true } } ], // legend: { // show: false // }, animationDuration: 0, animationDurationUpdate: 3000, animationEasing: 'linear', animationEasingUpdate: 'linear' }; function run() { for (var i = 0; i < data.length; ++i) { if (Math.random() > 0.9) { data[i] += Math.round(Math.random() * 10); } else { data[i] += Math.round(Math.random() * 20); } } myChart.setOption({ series: [ { type: 'bar', data } ] }); } setTimeout(function () { run(); }, 0); setInterval(function () { run(); }, 3000); // 使用刚指定的配置项和数据显示图表。 myChart.setOption(option); window.addEventListener("resize",function(){ myChart.resize(); }); } function echarts_4() { // 基于准备好的dom,初始化echarts实例 var myChart = echarts.init(document.getElementById('echart4')); option = { tooltip: { trigger: 'axis', axisPointer: { lineStyle: { color: '#dddc6b' } } }, legend: { top:'0%', data:['宋词','唐诗'], textStyle: { color: 'rgba(255,255,255,.5)', fontSize:'12', } }, grid: { left: '10', top: '30', right: '10', bottom: '10', containLabel: true }, xAxis: [{ type: 'category', boundaryGap: false, axisLabel: { textStyle: { color: "rgba(255,255,255,.6)", fontSize:12, }, }, axisLine: { lineStyle: { color: 'rgba(255,255,255,.2)' } }, }, { axisPointer: {show: false}, axisLine: { show: false}, position: 'bottom', offset: 20, }], yAxis: [{ type: 'value', axisTick: {show: false}, axisLine: { lineStyle: { color: 'rgba(255,255,255,.1)' } }, axisLabel: { textStyle: { color: "rgba(255,255,255,.6)", fontSize:12, }, show: false, }, splitLine: { lineStyle: { color: 'rgba(255,255,255,.1)' } } }], series: [ { name: '宋词', type: 'line', smooth: true, symbol: 'circle', symbolSize: 5, showSymbol: false, lineStyle: { normal: { color: '#0184d5', width: 2 } }, areaStyle: { normal: { color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{ offset: 0, color: 'rgba(1, 132, 213, 0.4)' }, { offset: 0.8, color: 'rgba(1, 132, 213, 0.1)' }], false), shadowColor: 'rgba(0, 0, 0, 0.1)', } }, itemStyle: { normal: { color: '#0184d5', borderColor: 'rgba(221, 220, 107, .1)', borderWidth: 12 } }, data: [3, 4, 3, 4, 3, 4, 3, 6, 2, 4, 2, 4,3, 4, 3, 4, 3, 4, 3, 6, 2, 4, 2, 4] }, { name: '唐诗', type: 'line', smooth: true, symbol: 'circle', symbolSize: 5, showSymbol: false, lineStyle: { normal: { color: '#00d887', width: 2 } }, areaStyle: { normal: { color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{ offset: 0, color: 'rgba(0, 216, 135, 0.4)' }, { offset: 0.8, color: 'rgba(0, 216, 135, 0.1)' }], false), shadowColor: 'rgba(0, 0, 0, 0.1)', } }, itemStyle: { normal: { color: '#00d887', borderColor: 'rgba(221, 220, 107, .1)', borderWidth: 12 } }, data: [5, 3, 5, 6, 1, 5, 3, 5, 6, 4, 6, 4, 8, 3, 5, 6, 1, 5, 3, 7, 2, 5, 1, 4] }, ] }; // 使用刚指定的配置项和数据显示图表。 myChart.setOption(option); window.addEventListener("resize",function(){ myChart.resize(); }); } function echarts_6() { // 基于准备好的dom,初始化echarts实例 var myChart = echarts.init(document.getElementById('echart6')); var dataStyle = { normal: { label: { show: false }, labelLine: { show: false }, //shadowBlur: 40, //shadowColor: 'rgba(40, 40, 40, 1)', } }; var placeHolderStyle = { normal: { color: 'rgba(255,255,255,.05)', label: {show: false,}, labelLine: {show: false} }, emphasis: { color: 'rgba(0,0,0,0)' } }; option = { series: [ { name: 'Nightingale Chart', type: 'pie', radius: [8, 60], center: ['50%', '50%'], roseType: 'area', itemStyle: { borderRadius: 8 }, data: [ { value: 40, name: '杜甫' }, { value: 38, name: '李白' }, { value: 32, name: '王维' }, { value: 30, name: '李商隐' }, { value: 28, name: '白居易' }, { value: 26, name: '孟浩然' }, { value: 22, name: '刘禹锡' }, { value: 18, name: '杜牧' } ] } ] }; // 使用刚指定的配置项和数据显示图表。 myChart.setOption(option); window.addEventListener("resize",function(){ myChart.resize(); }); } function echarts_31() { // 基于准备好的dom,初始化echarts实例 var myChart = echarts.init(document.getElementById('fb1')); option = { title: [{ text: '唐朝诗人从政分布', left: 'center', textStyle: { color: '#fff', fontSize:'16' } }], tooltip: { trigger: 'item', formatter: "{a}
{b}: {c} ({d}%)", position:function(p){ //其中p为当前鼠标的位置 return [p[0] + 10, p[1] - 10]; } }, legend: { top:'70%', itemWidth: 10, itemHeight: 10, data:['从政','未从政'], textStyle: { color: 'rgba(255,255,255,.5)', fontSize:'12', } }, series: [ { name:'从政分布', type:'pie', center: ['50%', '42%'], radius: ['40%', '60%'], color: ['#065aab', '#066eab', '#0682ab', '#0696ab', '#06a0ab','#06b4ab','#06c8ab','#06dcab','#06f0ab'], label: {show:false}, labelLine: {show:false}, data:[ {value:75, name:'从政'}, {value:25, name:'未从政'}, ] } ] }; // 使用刚指定的配置项和数据显示图表。 myChart.setOption(option); window.addEventListener("resize",function(){ myChart.resize(); }); } function echarts_32() { // 基于准备好的dom,初始化echarts实例 var myChart = echarts.init(document.getElementById('fb2')); option = { title: [{ text: '流派分布', left: 'center', textStyle: { color: '#fff', fontSize:'16' } }], tooltip: { trigger: 'item', formatter: "{a}
{b}: {c} ({d}%)", position:function(p){ //其中p为当前鼠标的位置 return [p[0] + 10, p[1] - 10]; } }, legend: { top:'70%', itemWidth: 10, itemHeight: 10, data:['山水田园诗','盛唐边塞诗','新乐府运动','韩孟派','咏史诗'], textStyle: { color: 'rgba(255,255,255,.5)', fontSize:'12', } }, series: [ { name:'人数占比', type:'pie', center: ['50%', '42%'], radius: ['40%', '60%'], color: ['#065aab', '#066eab', '#0682ab', '#0696ab', '#06a0ab','#06b4ab','#06c8ab','#06dcab','#06f0ab'], label: {show:false}, labelLine: {show:false}, data:[ {value:3, name:'山水田园诗'}, {value:3, name:'盛唐边塞诗'}, {value:1, name:'新乐府运动'}, {value:1, name:'韩孟派'}, {value:2, name:'咏史诗'}, ] } ] }; // 使用刚指定的配置项和数据显示图表。 myChart.setOption(option); window.addEventListener("resize",function(){ myChart.resize(); }); } function echarts_33() { // 基于准备好的dom,初始化echarts实例 var myChart = echarts.init(document.getElementById('fb3')); option = { title: [{ text: '作诗数量分布', left: 'center', textStyle: { color: '#fff', fontSize:'16' } }], tooltip: { trigger: 'item', formatter: "{a}
{b}: {c} ({d}%)", position:function(p){ //其中p为当前鼠标的位置 return [p[0] + 10, p[1] - 10]; } }, legend: { top:'70%', itemWidth: 10, itemHeight: 10, data:['白居易','杜甫','李白','元稹','刘禹锡'], textStyle: { color: 'rgba(255,255,255,.5)', fontSize:'12', } }, series: [ { name:'数量占比', type:'pie', center: ['50%', '42%'], radius: ['40%', '60%'], color: ['#065aab', '#066eab', '#0682ab', '#0696ab', '#06a0ab','#06b4ab','#06c8ab','#06dcab','#06f0ab'], label: {show:false}, labelLine: {show:false}, data:[ {value:3075, name:'白居易'}, {value:1371, name:'杜甫'}, {value:1178, name:'李白'}, {value:719, name:'元稹'}, {value:816, name:'刘禹锡'}, ] } ] }; // 使用刚指定的配置项和数据显示图表。 myChart.setOption(option); window.addEventListener("resize",function(){ myChart.resize(); }); } })