123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- function option2 (idx, selected) {
- var option = {
- tooltip : {
- trigger: 'item'
- },
- toolbox: {
- //orient: 'vertical',
- x: 'center',
- y: 'top',
- show : true,
- feature : {
- mark : {show: true},
- dataZoom : {show: true},
- dataView : {show: true, readOnly: false},
- restore : {show: true},
- saveAsImage : {show: true}
- }
- },
- legend : {
- data: ['城市'],
- selectedMode: false,
- orient: 'vertical',
- x: 'right'
- },
- grid: {
- x : 45,
- y : 30,
- x2 : 35,
- y2 : 30,
- },
- xAxis : [
- {
- name: idx != 0 ? 'PM25' : '亿元',
- type : 'value',
- //power: 1,
- scale: false
- }
- ],
- yAxis : [
- {
- name: idx != 1 ? '万人' : '亿元',
- type : 'value',
- //power: 1,
- scale: false,
- splitArea : {show : true}
- }
- ],
- animation:false,
- series : [
- {
- name:'城市',
- type:'scatter',
-
- symbolSize: function (value){
- return Math.round(value[2] / sizeCtrl);
- }
- }
- ]
- };
-
- var scatterData = [];
- var sizeCtrl;
- var tipFormatter;
- switch(idx+'') {
- case '0':
- sizeCtrl = 10;
- tipFormatter = function (v) {
- return v[1] + '<br>'
- + 'GDP : ' + v[2][0] + '(亿元)<br/>'
- + '人口 : ' + v[2][1] + '(万人)<br/>'
- + 'PM2.5 : ' + v[2][2];
- }
- for (var city in selected) {
- if (selected[city]) {
- scatterData.push({
- name: city,
- value: [
- PG[city].gdp,
- PG[city].pop,
- data.cityToData[city].pm2_5
- ],
- itemStyle:{normal:{color:PG[city].color}}
- });
- }
- }
- break;
- case '1':
- sizeCtrl = 80;
- tipFormatter = function (v) {
- return v[1] + '<br>'
- + 'PM2.5 : ' + v[2][0] + '<br/>'
- + 'GDP : ' + v[2][1] + '(亿元)<br/>'
- + '人口 : ' + v[2][2] + '(万人)';
- }
- for (var city in selected) {
- if (selected[city]) {
- scatterData.push({
- name: city,
- value: [
- data.cityToData[city].pm2_5,
- PG[city].gdp,
- PG[city].pop
- ],
- itemStyle:{normal:{color:PG[city].color}}
- });
- }
- }
- break;
- case '2':
- sizeCtrl = 500;
- tipFormatter = function (v) {
- return v[1] + '<br>'
- + 'PM2.5 : ' + v[2][0] + '<br/>'
- + '人口 : ' + v[2][1] + '(万人)<br/>'
- + 'GDP : ' + v[2][2] + '(亿元)';
- }
- for (var city in selected) {
- if (selected[city]) {
- scatterData.push({
- name: city,
- value: [
- data.cityToData[city].pm2_5,
- PG[city].pop,
- PG[city].gdp
- ],
- itemStyle:{normal:{color:PG[city].color}}
- });
- }
- }
- }
- option.tooltip.formatter = tipFormatter;
- option.series[0].data = scatterData;
-
- return option;
- }
|