123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337 |
- var randomDataLength = 10000;
- var randomData = (function (){
- var l = [];
- var len = randomDataLength;
- while(len--) {
- l.push(Math.round(Math.random()* 1000));
- }
- return l;
- })();
- function option(chartType, n) {
- var opt = {
- animation:false,
- title : {
- text: chartType + '性能测试',
- subtext: '自动生成' + n + '数据'
- },
- tooltip : {
- trigger: 'axis'
- },
- legend: {
- data:['性能测试']
- },
- toolbox: {
- show : true,
- feature : {
- mark : {show: true},
- //dataZoom : {show: true},
- dataView : {show: true, readOnly: false},
- magicType : {show: true, type: ['line', 'bar']},
- restore : {show: true},
- saveAsImage : {show: true}
- }
- },
- dataRange: {
- min: 0,
- max: 1000,
- calculable : true,
- color: ['orangered','yellow','lightskyblue']
- },
- series : [
- {
- name:'性能测试',
- type: chartType,
- mapType: 'world',
- roam: true,
- large:true,
- data: function (){
- switch(chartType) {
- case 'scatter' :
- return scatterData(n);
- case 'k' :
- return kData(n);
- case 'radar' :
- return radarData(n);
- case 'pie' :
- return pieData(n);
- case 'map' :
- return mapData(n);
- default :
- var list = [];
- for (var i = 1; i <= n; i++) {
- list.push({
- value : randomData[i % randomDataLength],
- name : i
- });
- }
- return list;
- }
- }()
- }
- ]
- };
- if (chartType == 'line'
- || chartType == 'bar'
- || chartType == 'k'
- ) {
- opt.xAxis = [
- {
- type : 'category',
- data : function (){
- var list = [];
- for (var i = 1; i <= n; i++) {
- list.push(i);
- }
- return list;
- }()
- }
- ];
- opt.yAxis = [
- {
- type : 'value'
- }
- ];
- }
- else if (chartType == 'scatter') {
- opt.xAxis = [
- {
- type : 'value'
- }
- ];
- opt.yAxis = [
- {
- type : 'value'
- }
- ];
- }
- else if (chartType == 'radar') {
- opt.polar = [
- {
- indicator : [
- { text: '1', max: 1000},
- { text: '2', max: 1000},
- { text: '3', max: 1000},
- { text: '4', max: 1000},
- { text: '3', max: 1000}
- ]
- }
- ];
- }
- else if (chartType == 'chord') {
- opt.series = chordSeries();
- }
- return opt;
- }
- function scatterData(n){
- var list = [];
- for (var i = 1; i <= n; i++) {
- list.push([
- i , randomData[i % randomDataLength]
- ]);
- }
- return list;
- }
- function kData(n){
- var list = [];
- for (var i = 1; i <= n; i++) {
- list.push([
- randomData[i % randomDataLength],
- randomData[(i+1) % randomDataLength],
- randomData[(i+2) % randomDataLength],
- randomData[(i+3) % randomDataLength]
- ]);
- }
- return list;
- }
- function radarData(n){
- var list = [];
- n = n > 200 ? 200 : n;
- for (var i = 1; i <= n; i++) {
- list.push({
- value : [
- randomData[i % randomDataLength],
- randomData[(i+1) % randomDataLength],
- randomData[(i+2) % randomDataLength],
- randomData[(i+3) % randomDataLength],
- randomData[(i+4) % randomDataLength]
- ],
- name : i
- });
- }
- return list;
- }
- function pieData(n){
- var list = [];
- n = n > 200 ? 200 : n;
- for (var i = 1; i <= n; i++) {
- list.push({
- value : randomData[i % randomDataLength],
- name : i
- });
- }
- return list;
- }
- function chordSeries() {
- return [
- {
- "name": "性能测试",
- "type": "chord",
- "showScaleText": false,
- "data": [
- {"name": "美国"},
- {"name": "叙利亚反对派"},
- {"name": "阿萨德"},
- {"name": "伊朗"},
- {"name": "塞西"},
- {"name": "哈马斯"},
- {"name": "以色列"},
- {"name": "穆斯林兄弟会"},
- {"name": "基地组织"},
- {"name": "俄罗斯"},
- {"name": "黎巴嫩什叶派"},
- {"name": "土耳其"},
- {"name": "卡塔尔"},
- {"name": "沙特"},
- {"name": "黎巴嫩逊尼派"}
- ],
- "matrix": [
- [0,100,0,0,0,0,100,0,0,0,0,0,0,0,0],
- [10,0,0,0,0,10,10,0,10,0,0,10,10,10,10],
- [0,0,0,10,0,0,0,0,0,10,10,0,0,0,0],
- [0,0,100,0,0,100,0,0,0,0,100,0,0,0,0],
- [0,0,0,0,0,0,0,0,0,0,0,0,0,10,0],
- [0,100,0,10,0,0,0,0,0,0,0,0,10,0,0],
- [10,100,0,0,0,0,0,0,0,0,0,0,0,0,0],
- [0,0,0,0,0,0,0,0,0,0,0,10,10,0,0],
- [0,100,0,0,0,0,0,0,0,0,0,0,0,0,0],
- [0,0,100,0,0,0,0,0,0,0,0,0,0,0,0],
- [0,0,100,10,0,0,0,0,0,0,0,0,0,0,0],
- [0,100,0,0,0,0,0,100,0,0,0,0,0,0,0],
- [0,100,0,0,0,100,0,100,0,0,0,0,0,0,0],
- [0,100,0,0,100,0,0,0,0,0,0,0,0,0,100],
- [0,100,0,0,0,0,0,0,0,0,0,0,0,10,0]
- ]
- },
- {
- "name": "反对",
- "type": "chord",
- "showScaleText": false,
- "data": [
- {"name": "美国"},
- {"name": "叙利亚反对派"},
- {"name": "阿萨德"},
- {"name": "伊朗"},
- {"name": "塞西"},
- {"name": "哈马斯"},
- {"name": "以色列"},
- {"name": "穆斯林兄弟会"},
- {"name": "基地组织"},
- {"name": "俄罗斯"},
- {"name": "黎巴嫩什叶派"},
- {"name": "土耳其"},
- {"name": "卡塔尔"},
- {"name": "沙特"},
- {"name": "黎巴嫩逊尼派"}
- ],
- "matrix": [
- [0,0,100,100,0,100,0,0,100,0,0,0,0,0,0],
- [0,0,0,10,0,0,0,0,0,10,10,0,0,0,0],
- [10,0,0,0,0,0,10,10,10,0,0,10,10,0,10],
- [10,100,0,0,0,0,0,0,0,0,0,0,0,0,0],
- [0,0,0,0,0,10,0,100,0,0,0,10,10,0,0],
- [10,0,0,0,100,0,10,0,0,0,0,0,0,0,0],
- [0,0,100,0,0,100,0,0,0,0,0,0,0,0,0],
- [0,0,100,0,10,0,0,0,0,0,0,0,0,10,0],
- [10,0,100,0,0,0,0,0,0,0,0,0,0,100,0],
- [0,100,0,0,0,0,0,0,0,0,0,0,0,0,0],
- [0,100,0,0,0,0,0,0,0,0,0,0,0,0,0],
- [0,0,100,0,100,0,0,0,0,0,0,0,0,0,0],
- [0,0,100,0,100,0,0,0,0,0,0,0,0,0,0],
- [0,0,0,0,0,0,0,100,10,0,0,0,0,0,0],
- [0,0,100,0,0,0,0,0,0,0,0,0,0,0,0]
- ]
- },
- {
- "name": "未表态",
- "type": "chord",
- "showScaleText": false,
- "data": [
- {"name": "美国"},
- {"name": "叙利亚反对派"},
- {"name": "阿萨德"},
- {"name": "伊朗"},
- {"name": "塞西"},
- {"name": "哈马斯"},
- {"name": "以色列"},
- {"name": "穆斯林兄弟会"},
- {"name": "基地组织"},
- {"name": "俄罗斯"},
- {"name": "黎巴嫩什叶派"},
- {"name": "土耳其"},
- {"name": "卡塔尔"},
- {"name": "沙特"},
- {"name": "黎巴嫩逊尼派"}
- ],
- "matrix": [
- [0,0,0,0,100,0,0,100,0,0,0,0,0,0,0],
- [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
- [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
- [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
- [10,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
- [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
- [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
- [10,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
- [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
- [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
- [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
- [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
- [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
- [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],
- [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
- ]
- }
- ];
- }
- function mapData(n) {
- var countryList = [
- 'Afghanistan','Angola','Albania','United Arab Emirates','Argentina','Armenia',
- 'French Southern and Antarctic Lands','Australia','Austria','Azerbaijan','Burundi',
- 'Belgium','Benin','Burkina Faso','Bangladesh','Bulgaria','The Bahamas',
- 'Bosnia and Herzegovina','Belarus','Belize','Bermuda','Bolivia','Brazil','Brunei',
- 'Bhutan','Botswana','Central African Republic','Canada','Switzerland','Chile','China',
- 'Ivory Coast','Cameroon','Democratic Republic of the Congo','Republic of the Congo',
- 'Colombia','Costa Rica','Cuba','Northern Cyprus','Cyprus','Czech Republic','Germany',
- 'Djibouti','Denmark','Dominican Republic','Algeria','Ecuador','Egypt','Eritrea','Spain',
- 'Estonia','Ethiopia','Finland','Fiji','Falkland Islands','France','Gabon','United Kingdom',
- 'Georgia','Ghana','Guinea','Gambia','Guinea Bissau','Equatorial Guinea','Greece',
- 'Greenland','Guatemala','French Guiana','Guyana','Honduras','Croatia','Haiti','Hungary',
- 'Indonesia','India','Ireland','Iran','Iraq','Iceland','Israel','Italy','Jamaica','Jordan',
- 'Japan','Kazakhstan','Kenya','Kyrgyzstan','Cambodia','South Korea','Kosovo','Kuwait',
- 'Laos','Lebanon','Liberia','Libya','Sri Lanka','Lesotho','Lithuania','Luxembourg','Latvia',
- 'Morocco','Moldova','Madagascar','Mexico','Macedonia','Mali','Myanmar','Montenegro',
- 'Mongolia','Mozambique','Mauritania','Malawi','Malaysia','Namibia','New Caledonia','Niger',
- 'Nigeria','Nicaragua','Netherlands','Norway','Nepal','New Zealand','Oman','Pakistan',
- 'Panama','Peru','Philippines','Papua New Guinea','Poland','Puerto Rico','North Korea',
- 'Portugal','Paraguay','Qatar','Romania','Russia','Rwanda','Western Sahara','Saudi Arabia',
- 'Sudan','South Sudan','Senegal','Solomon Islands','Sierra Leone','El Salvador','Somaliland',
- 'Somalia','Republic of Serbia','Suriname','Slovakia','Slovenia','Sweden','Swaziland',
- 'Syria','Chad','Togo','Thailand','Tajikistan','Turkmenistan','East Timor',
- 'Trinidad and Tobago','Tunisia','Turkey','United Republic of Tanzania','Uganda','Ukraine',
- 'Uruguay','United States of America','Uzbekistan','Venezuela','Vietnam','Vanuatu',
- 'West Bank','Yemen','South Africa','Zambia','Zimbabwe'
- ];
- var list = [];
- for (var i = 0, l = countryList.length; i < l; i ++) {
- list.push({
- name : countryList[i],
- value : randomData[(i + n) % randomDataLength]
- });
- }
- return list;
- }
|