We need to first combine the air quality data with the map data: Map data has the attribute name Our different cities' air quality also has a name attribute. These two attributes are the same, both called name, so we can associate them: var airData = [ { name: 'Beijing', value: 39.92 }, { name: 'Tianjin', value: 39.13 }, { name: 'Shanghai', value: 31.22 }, { name: 'Chongqing', value: 66 }, { name: 'Hebei', value: 147 }, { name: 'Henan', value: 113 }, { name: 'Yunnan', value: 25.04 }, { name: 'Liaoning', value: 50 }, { name: 'Heilongjiang', value: 114 }, { name: 'Hunan', value: 175 }, { name: 'Anhui', value: 117 }, { name: 'Shandong', value: 92 }, { name: 'Xinjiang', value: 84 }, { name: 'Jiangsu', value: 67 }, { name: 'Zhejiang', value: 84 }, { name: 'Jiangxi', value: 96 }, { name: 'Hubei', value: 273 }, { name: 'Guangxi', value: 59 }, { name: 'Gansu', value: 99 }, { name: 'Shanxi', value: 39 }, { name: 'Inner Mongolia', value: 58 }, { name: 'Shaanxi', value: 61 }, { name: 'Jilin', value: 51 }, { name: 'Fujian', value: 29 }, { name: 'Guizhou', value: 71 }, { name: 'Guangdong', value: 38 }, { name: 'Qinghai', value: 57 }, { name: 'Tibet', value: 24 }, { name: 'Sichuan', value: 58 }, { name: 'Ningxia', value: 52 }, { name: 'Hainan', value: 54 }, { name: 'Taiwan', value: 88 }, { name: 'Hong Kong', value: 66 }, { name: 'Macao', value: 77 }, { name: 'South China Sea Islands', value: 55 } ] Next we need to configure the air quality data into the series: Finally, do some effect configuration: Full code: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Map-Air Quality in Different Cities</title> <script src="./lib/echarts.js"></script> <script src="./lib/axios.js"></script> </head> <body> <div style="width: 600px; height: 400px;border: 1px solid lightblue;"></div> <script> var airData = [ { name: 'Beijing', value: 39.92 }, { name: 'Tianjin', value: 39.13 }, { name: 'Shanghai', value: 31.22 }, { name: 'Chongqing', value: 66 }, { name: 'Hebei', value: 147 }, { name: 'Henan', value: 113 }, { name: 'Yunnan', value: 25.04 }, { name: 'Liaoning', value: 50 }, { name: 'Heilongjiang', value: 114 }, { name: 'Hunan', value: 175 }, { name: 'Anhui', value: 117 }, { name: 'Shandong', value: 92 }, { name: 'Xinjiang', value: 84 }, { name: 'Jiangsu', value: 67 }, { name: 'Zhejiang', value: 84 }, { name: 'Jiangxi', value: 96 }, { name: 'Hubei', value: 273 }, { name: 'Guangxi', value: 59 }, { name: 'Gansu', value: 99 }, { name: 'Shanxi', value: 39 }, { name: 'Inner Mongolia', value: 58 }, { name: 'Shaanxi', value: 61 }, { name: 'Jilin', value: 51 }, { name: 'Fujian', value: 29 }, { name: 'Guizhou', value: 71 }, { name: 'Guangdong', value: 38 }, { name: 'Qinghai', value: 57 }, { name: 'Tibet', value: 24 }, { name: 'Sichuan', value: 58 }, { name: 'Ningxia', value: 52 }, { name: 'Hainan', value: 54 }, { name: 'Taiwan', value: 88 }, { name: 'Hong Kong', value: 66 }, { name: 'Macao', value: 77 }, { name: 'South China Sea Islands', value: 55 } ] var myCharts = echarts.init(document.querySelector('div')) axios.get('./json/map/china.json').then(res => { console.log(res.data) echarts.registerMap('china', res.data) var option = { geo: { type: 'map', map: 'china', roam: true, label: { show: true } }, series: [ { data: airData, // air quality data geoIndex: 0, // associate air quality data with the 0th geo configuration type: 'map' } ], visualMap: min: 0, // minimum value max: 300, // maximum value inRange: { color: ['pink', 'blue'] // Control the lower left corner and map gradient color}, calculable: true // Control the lower left slider} } myCharts.setOption(option) }) </script> </body> </html> SummarizeThis article ends here. I hope it can be helpful to you. I also hope that you can pay more attention to more content on 123WORDPRESS.COM! You may also be interested in:
|
<<: 21 MySQL standardization and optimization best practices!
>>: Docker image creation Dockerfile and commit operations
This article shares the specific code of Vue+ssh ...
1. Foreign key setting method 1. In MySQL, in ord...
This article mainly involves solutions to problem...
HTML style tag style tag - Use this tag when decl...
Songti: SimSun Bold: SimHei Microsoft YaHei: Micr...
By default, PHP on CentOS 7 runs as apache or nob...
After MySQL database optimization, not only can t...
Volume Label, Property Name, Description 002 <...
Table of contents 1. Overview 1.1 Definition 1.2 ...
1. Manually create and add my.ini file # CLIENT S...
Table of contents 1. Shallow cloning 2. Deep clon...
Table of contents First step installation Step 2:...
The main functions are as follows: Add product in...
Vue implements the palace grid rotation lottery (...
How to set a limit on the number of visits to a c...