echarts散点图使用(转:http://www.suchso.com/UIweb/echarts-sandiantu.html)

本文主要是介绍echarts散点图使用(转:http://www.suchso.com/UIweb/echarts-sandiantu.html),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

1.散点图中找最优记录

IT分享

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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
<!DOCTYPE html>
<html>
<head>
<meta http-equiv= "Content-Type"  content= "text/html; charset=utf-8" />
     <title></title>
     <meta charset= "utf-8"  />
     <link rel= "stylesheet"  href= "style/style.css" >
     <script src= "js/echarts.common.min.js" ></script>
</head>
<body>
     <!-- 为ECharts准备一个具备大小(宽高)的Dom -->
     <div id= "main"  style= "width: 620px;height:400px;" ></div>
     <script type= "text/javascript" >
         // 基于准备好的dom,初始化echarts实例
         var  myChart = echarts.init(document.getElementById( 'main' ));
         var  data = [[],[]];
         var  showVal = [[3, 200099,  "中天博日" ], [2, 500039,  "腾讯" ], [5, 188669,  "中科" ], [4, 900009,  "华为" ], [3, 333339,  "阿里" ], [4, 233339,  "万达" ], [2, 433339,  "中信" ], [7, 388889,  "中科" ], [6, 388889,  "kkk" ], [4, 233359,  'lekd' ]];
         showVal = showVal.sort(function (a, b) {
             if  (a[0] == b[0]) {
                 return  a[1]>b[1]
             }
             return  a[0] < b[0]
         });
         var  schema = [
             { name:  'money' , index: 0, text:  '金额'  },
             { name:  'selUser' , index: 1, text:  '选择中标人'  }
         ];
         for  ( var  i = 0; i < showVal.length; i++) {
             var  a= [];
             if  (showVal[0][1] == showVal[i][1]) {
                 if  (showVal[0][0] == showVal[i][0]) {
                     data[0].push(showVal[i]);
                 else  {
                     data[1].push(showVal[i]);
                 }
             else 
                 data[1].push(showVal[i]);
             }
         }
         option = {
             backgroundColor:  new  echarts.graphic.RadialGradient(0.3, 0.3, 0.8, [{
                 offset: 0,
                 color:  '#fff'
             }, {
                 offset: 1,
                 color:  '#fff'
             }]),
             title: {
                 left : '35%' ,
                 text:  '寻找纸板插入物, 纸板供应商' ,
                 textStyle:{
                     color:  '#354052' ,
                     fontSize:16
                     }
             },
             //系列标记
             legend: {
                 y:  'bottom' ,
                 data: [ '投标' '最佳出价' ],
                 itemGap:40,
             },
             //提示框的事例
             tooltip: {
                 padding: 10,
                 backgroundColor:  '#222' ,
                 borderColor:  '#777' ,
                 borderWidth: 1,
                 formatter: function (obj) {
                     var  value = obj.value;
                     return  '<div style="border-bottom: 1px solid rgba(255,255,255,.3); font-size: 18px;padding-bottom: 7px;margin-bottom: 7px">'
                         + value[2]
                         '</div>'
                         + schema[0].text +  ':'  + value[1] +  '<br>'
                         '选择中标人<br>'
                 }
             },
             //x坐标的设置
             xAxis: {
                 name:  '供应商评分' ,
                 nameTextStyle: {
                     color:  '#7F8FA4' ,
                     fontSize: 12
                 },
                 axisLine: {
                     lineStyle: {
                         color:  '#979797'
                     }
                 },
                 splitLine: {
                     lineStyle: {
                         color:  '#D8D8D8' ,
                         type:  'dashed' ,
                     }
                 }
             },
             //y坐标的设置
             yAxis: {
                 name:  '投标金额' ,
                 //坐标轴名称
                 nameTextStyle: {
                     color:  '#7F8FA4' ,
                     fontSize: 12
                 },
                //坐标轴的设置
                 axisLine: {
                     lineStyle: {
                         color:  '#979797'
                     }
                 },
                 //坐标轴的分割线
                 splitLine: {
                     lineStyle: {
                         color:  '#D8D8D8' ,
                         type:  'dashed' ,
                     }
                 },
                 scale:  true
             },
             series: [{
                 name:  '最佳出价' ,
                 data: data[0],
                 type:  'scatter' ,
                 symbolSize: function (data) {
                     return  Math.sqrt(data[1]) / 5e2 * 10;
                 },
                 itemStyle: {
                     normal: {
                         shadowBlur: 10,
                         shadowColor:  'rgba(255,128,5,0.5)' ,
                         shadowOffsetY: 5,
                         color:  new  echarts.graphic.RadialGradient(0.4, 0.3, 1, [{
                             offset: 0,
                             color:  '#FF8005 '
                         }, {
                             offset: 1,
                             color:  '#FF8005'
                         }])
                     }
                 }, markLine: {
                     silent:  true ,
                     lineStyle: {
                         normal: {
                             type:  'solid' ,
                         }
                     },
                     data: [{
                         yAxis: data[1][7][1]
                     }],
                     label: {
                         normal: {
                             formatter: '机会金额'
                         }
                     }
                         
                 }
             }, {
                 name:  '投标' ,
                 data: data[1],
                 type:  'scatter' ,
                 symbolSize: function (data) {
                     return  Math.sqrt(data[1]) / 5e2 * 10;
                 },
                 itemStyle: {
                     normal: {
                         shadowBlur: 10,
                         shadowColor:  'rgba(55,178,72,0.5)' ,
                         shadowOffsetY: 5,
                         color:  new  echarts.graphic.RadialGradient(0.4, 0.3, 1, [{
                             offset: 0,
                             color:  '#37B248'
                         }, {
                             offset: 1,
                             color:  '#37B248'
                         }])
                     }
                 },
                 
             }]
         };
         // 使用刚指定的配置项和数据显示图表。
         myChart.setOption(option);
     </script>
</body>
</html>

2地图中的特殊标记

IT分享

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
119
120
121
122
123
124
125
126
127
128
<!DOCTYPE html>
<html>
<head>
<meta http-equiv= "Content-Type"  content= "text/html; charset=utf-8" />
     <title></title>
     <meta charset= "utf-8"  />
     <link rel= "stylesheet"  href= "style/style.css" >
     <script src= "js/echarts.common.min.js" ></script>   
     <script type= "text/javascript"  src= "http://echarts.baidu.com/gallery/vendors/echarts/echarts-all-3.js" ></script>
     <script type= "text/javascript"  src= "http://echarts.baidu.com/gallery/vendors/echarts/map/js/china.js" ></script>
</head>
<body>
     <!-- 为ECharts准备一个具备大小(宽高)的Dom -->
     <div id= "main"  style= "width: 600px;height:400px;" ></div>
     <script type= "text/javascript" >
         // 基于准备好的dom,初始化echarts实例
         var  myChart = echarts.init(document.getElementById( 'main' ));
         function randomData() {
             return  Math.round(Math.random() * 1000);
         }
         var  pricePoint = [[121.15, 31.89], [109.781327, 39.608266], [120.38, 37.35], [122.207216, 29.985295], [123.97, 47.33], [120.13, 33.38], [118.87, 42.28], [102.188043, 38.520089]];
         var  geoCoordMap = {
             '海门' : [121.15, 31.89],
             '鄂尔多斯' : [109.781327, 39.608266],
             '招远' : [120.38, 37.35],
             '舟山' : [122.207216, 29.985295],
             '齐齐哈尔' : [123.97, 47.33],
             '盐城' : [120.13, 33.38],
             '赤峰' : [118.87, 42.28],
             "金昌" : [102.188043, 38.520089],
         };
         var  geoData = [
             { name:  "海门" , value: 9 },
             { name:  "鄂尔多斯" , value: 12 },
             { name:  "招远" , value: 12 },
             { name:  "舟山" , value: 12 },
             { name:  "齐齐哈尔" , value: 14 },
             { name:  "盐城" , value: 15 },
             { name:  "赤峰" , value: 16 },
             { name:  "金昌" , value: 19 }
         ]
         //获取唯一识别的值
         var  selName = geoCoordMap.金昌.toString();
         var  convertData = function (data, geoCoord1) {
             var  res = [];
             for  ( var  i = 0; i < data.length; i++) {
                 var  geoCoord = geoCoord1[data[i].name];
                 if  (geoCoord) {
                     res.push({
                         name: data[i].name,
                         value: geoCoord.concat(data[i].value)
                     });
                 }
             }
             return  res;
         };
         var  setTip = function (data) {
             var  res = [];
             if (data&&data.length>0){
                 for ( var  i=0;i<data.length;i++){
                     res.push({
                         coord: data[i],
                         label: {
                             normal: { show:  false  }
                         },
                         symbol: data[i].toString() != selName ?  'image://image/page.png'  'image://image/page1.png' ,
                     })
                 }
             }
             return  res
         }
         option = {
             backgroundColor:  '#fff' ,
             title: {
                 text:  '全国主要城市空气质量' ,
                 x:  'center' ,
                 textStyle: {
                     color:  '#fff'
                 }
             },
             tooltip: {
                 trigger:  'item' ,
                 formatter: function ( params ) {
                     return  params .name +  ' : '  params .value[2];
                 }
             },
             geo: {
                 map:  'china' ,
                 label: {
                     emphasis: {
                         show:  false
                     }
                 },
                 itemStyle: {
                     normal: {
                         areaColor:  '#E7E7E7' ,
                         borderColor:  '#fff'
                     },
                     emphasis: {
                         //鼠标移上去的属性
                         areaColor:  '#E7E7E7'
                     }
                 }
             },
             series: [
                 {
                     name:  'pm2.5' ,
                     type:  'scatter' ,
                     coordinateSystem:  'geo' ,
                     data: convertData(geoData, geoCoordMap),
                     //将默认的显示隐藏掉
                     symbolSize: 0,
                     //自定义标示点
                     markPoint: {
                         data: setTip(pricePoint),
                         //设置图片的偏移
                        // symbolOffset: ['-5%', '-5%'],
                         //设置图片的宽高
                         symbolSize: [15,20],
                     },
                 }
             ]
         }
         // 使用刚指定的配置项和数据显示图表。
         myChart.setOption(option);
     </script>
</body>
</html>

这篇关于echarts散点图使用(转:http://www.suchso.com/UIweb/echarts-sandiantu.html)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/918287

相关文章

python使用库爬取m3u8文件的示例

《python使用库爬取m3u8文件的示例》本文主要介绍了python使用库爬取m3u8文件的示例,可以使用requests、m3u8、ffmpeg等库,实现获取、解析、下载视频片段并合并等步骤,具有... 目录一、准备工作二、获取m3u8文件内容三、解析m3u8文件四、下载视频片段五、合并视频片段六、错误

CSS place-items: center解析与用法详解

《CSSplace-items:center解析与用法详解》place-items:center;是一个强大的CSS简写属性,用于同时控制网格(Grid)和弹性盒(Flexbox)... place-items: center; 是一个强大的 css 简写属性,用于同时控制 网格(Grid) 和 弹性盒(F

CSS实现元素撑满剩余空间的五种方法

《CSS实现元素撑满剩余空间的五种方法》在日常开发中,我们经常需要让某个元素占据容器的剩余空间,本文将介绍5种不同的方法来实现这个需求,并分析各种方法的优缺点,感兴趣的朋友一起看看吧... css实现元素撑满剩余空间的5种方法 在日常开发中,我们经常需要让某个元素占据容器的剩余空间。这是一个常见的布局需求

CSS Anchor Positioning重新定义锚点定位的时代来临(最新推荐)

《CSSAnchorPositioning重新定义锚点定位的时代来临(最新推荐)》CSSAnchorPositioning是一项仍在草案中的新特性,由Chrome125开始提供原生支持需... 目录 css Anchor Positioning:重新定义「锚定定位」的时代来了! 什么是 Anchor Pos

CSS中的Static、Relative、Absolute、Fixed、Sticky的应用与详细对比

《CSS中的Static、Relative、Absolute、Fixed、Sticky的应用与详细对比》CSS中的position属性用于控制元素的定位方式,不同的定位方式会影响元素在页面中的布... css 中的 position 属性用于控制元素的定位方式,不同的定位方式会影响元素在页面中的布局和层叠关

HTML5 getUserMedia API网页录音实现指南示例小结

《HTML5getUserMediaAPI网页录音实现指南示例小结》本教程将指导你如何利用这一API,结合WebAudioAPI,实现网页录音功能,从获取音频流到处理和保存录音,整个过程将逐步... 目录1. html5 getUserMedia API简介1.1 API概念与历史1.2 功能与优势1.3

gitlab安装及邮箱配置和常用使用方式

《gitlab安装及邮箱配置和常用使用方式》:本文主要介绍gitlab安装及邮箱配置和常用使用方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录1.安装GitLab2.配置GitLab邮件服务3.GitLab的账号注册邮箱验证及其分组4.gitlab分支和标签的

SpringBoot3应用中集成和使用Spring Retry的实践记录

《SpringBoot3应用中集成和使用SpringRetry的实践记录》SpringRetry为SpringBoot3提供重试机制,支持注解和编程式两种方式,可配置重试策略与监听器,适用于临时性故... 目录1. 简介2. 环境准备3. 使用方式3.1 注解方式 基础使用自定义重试策略失败恢复机制注意事项

nginx启动命令和默认配置文件的使用

《nginx启动命令和默认配置文件的使用》:本文主要介绍nginx启动命令和默认配置文件的使用,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录常见命令nginx.conf配置文件location匹配规则图片服务器总结常见命令# 默认配置文件启动./nginx

在Windows上使用qemu安装ubuntu24.04服务器的详细指南

《在Windows上使用qemu安装ubuntu24.04服务器的详细指南》本文介绍了在Windows上使用QEMU安装Ubuntu24.04的全流程:安装QEMU、准备ISO镜像、创建虚拟磁盘、配置... 目录1. 安装QEMU环境2. 准备Ubuntu 24.04镜像3. 启动QEMU安装Ubuntu4