1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118
| <script src="https://npm.elemecdn.com/jquery@latest/dist/jquery.min.js"></script> {% 图表 '100%','600',"null",'svg' %} myChart.showLoading(); $.get('https://cdn.cbd.int/naokuo-blog@1.1.6/json/confidence-band.json', function (data) { myChart.hideLoading(); var base = -data.reduce(function (min, val) { return Math.floor(Math.min(min, val.l)); }, Infinity); myChart.setOption( (option = { title: { text: 'Confidence Band', subtext: 'Example in MetricsGraphics.js', left: 'center' }, tooltip: { trigger: 'axis', axisPointer: { type: 'cross', animation: false, label: { backgroundColor: '#ccc', borderColor: '#aaa', borderWidth: 1, shadowBlur: 0, shadowOffsetX: 0, shadowOffsetY: 0, color: '#222' } }, formatter: function (params) { return ( params[2].name + '<br />' + ((params[2].value - base) * 100).toFixed(1) + '%' ); } }, grid: { left: '3%', right: '4%', bottom: '3%', containLabel: true }, xAxis: { type: 'category', data: data.map(function (item) { return item.date; }), axisLabel: { formatter: function (value, idx) { var date = new Date(value); return idx === 0 ? value : [date.getMonth() + 1, date.getDate()].join('-'); } }, boundaryGap: false }, yAxis: { axisLabel: { formatter: function (val) { return (val - base) * 100 + '%'; } }, axisPointer: { label: { formatter: function (params) { return ((params.value - base) * 100).toFixed(1) + '%'; } } }, splitNumber: 3 }, series: [ { name: 'L', type: 'line', data: data.map(function (item) { return item.l + base; }), lineStyle: { opacity: 0 }, stack: 'confidence-band', symbol: 'none' }, { name: 'U', type: 'line', data: data.map(function (item) { return item.u - item.l; }), lineStyle: { opacity: 0 }, areaStyle: { color: '#ccc' }, stack: 'confidence-band', symbol: 'none' }, { type: 'line', data: data.map(function (item) { return item.value + base; }), itemStyle: { color: '#333' }, showSymbol: false } ] }) ); }); {% end图表 %}
|