当前位置:网站首页>DataGear 使用坐标映射表制作地理坐标数据可视化看板
DataGear 使用坐标映射表制作地理坐标数据可视化看板
2022-06-21 18:10:00 【DataGear】
DataGear 的数据集结构是由数据集属性表示的,数据集属性并不要求与实际的数据结构一致,可以自由新增、编辑、删除。利用这一特性,可以为数据集添加占位属性(没有对应实际数据),然后在看板展示其关联的图表时,通过dg-chart-listener的onUpdate函数补全数据,从而实现数据扩展功能。
本文以地图飞线图为例,介绍如何利用上述特性,为仅包含地区名称信息的数据集,制作数据可视化看板。
假设有如下地区名称数据集:
名称:
源点地区名/终点地区名
数据:
源点地区名, 终点地区名
新疆, 北京
四川, 北京
广东, 北京
浙江, 北京
执行预览后,它的属性列表为:
名称 类型
源点地区名 字符串
终点地区名 字符串
地图飞线图需要数据集具有如下属性:源点经度、源点纬度、终点经度、终点纬度,因此,这里为上述数据集手动添加这四个占位属性:
名称 类型
源点地区名 字符串
终点地区名 字符串
源地区经度 数值
源地区纬度 数值
终地区经度 数值
终地区纬度 数值
然后,新建地图飞线图,如下所示:
名称:地图飞线图
图表类型:地图飞线图
数据集:
源地区经度 -> 源点经度
源地区纬度 -> 源点纬度
终地区经度 -> 终点经度
终地区纬度 -> 终点纬度
此时展示图表将是空白飞线图,因为并没有实际的地理坐标数据。
然后,新建看板,添加上述图表,为其添加dg-chart-listener图表监听器,并通过它的onUpdate函数补全地理坐标数据,如下所示:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style type="text/css"> .chart{
display: inline-block; width: 100%; height: 500px; } </style>
<script> //地区名->地理坐标映射表 var coordMap= {
"新疆": [85.523256,41.094106], "四川": [103.037483,30.450264], "广东": [113.560737,23.669933], "浙江": [119.962996,29.037435], "北京": [116.651482,40.253657], }; var chartListener= {
onUpdate: function(chart, results) {
var result = chart.resultFirst(results); var datas = chart.resultDatas(result); for(var i=0; i<datas.length; i++) {
var di = datas[i]; var srcCoord = (coordMap[di['源点地区名']] || {
}); var targetCoord = (coordMap[di['终点地区名']] || {
}); di['源地区经度'] = srcCoord[0]; di['源地区纬度'] = srcCoord[1]; di['终地区经度'] = targetCoord[0]; di['终地区纬度'] = targetCoord[1]; } chart.resultData(result, datas); } }; </script>
</head>
<body>
<div class="chart" dg-chart-listener="chartListener" dg-chart-widget="上述图表ID"></div>
</body>
</html>
点击[保存并展示]按钮,打开看板展示页面,完成!!!
效果图如下所示:

源码地址:
Gitee:https://gitee.com/datagear/datagear
边栏推荐
- homeassistant addons
- 【区间和专题の前缀和】前缀和 + 哈希表 运用题
- R语言使用plyr包的rbind.fill函数纵向合并两个数据列不同的dataframe数据
- 将图片背景设置为透明的方法介绍
- MFC界面库BCGControlBar v33.0 - 桌面警报窗口、网格控件升级
- [interval and topic prefix and] prefix and + hash table application questions
- MFC interface library bcgcontrolbar v33.0 - Desktop alert window, grid control upgrade
- Ogg-21.3 error reporting ogg-00768 failed to map database character to ulibcharaset
- TensorFlow 2:使用神经网络对Fashion MNIST分类并进行比较分析
- EasyCVR智能边缘网关硬件如何设置通电自启动?
猜你喜欢

企评家全面解读:【国家电网】中国电力财务有限公司企业成长性

将图片背景设置为透明的方法介绍
![Dynamic programming [II] (linear DP)](/img/c9/f4fbc78d24320e3bd915d99de5837b.jpg)
Dynamic programming [II] (linear DP)

W10添加系统环境变量Path

11 introduction and installation of beautiful soup parsing library

品牌、产品和服务齐发力,东风日产接下来有什么新动作?

WMS仓库仓储管理系统源码

Flink 系例 之 TableAPI & SQL 与 示例模块

Gartner 网络研讨会 “九问数字化转型” 会后感

An accident caused by a MySQL misoperation, and the "high availability" cannot withstand it!
随机推荐
动态规划【二】(线性dp)
11 Beautiful Soup 解析庫的簡介及安裝
508. Most Frequent Subtree Sum
Use the uniapp framework to build the zheliban micro application (single sign on, embedded point, aging adaptation, RPC gateway)
Nebula Graph入驻阿里云计算巢,助力企业打造云上超大规模图数据库
Is it safe to open futures accounts online? Can I open an account without going offline?
机器学习之线性模型与决策树
【综合笔试题】难度 2.5/5 :「树状数组」与「双树状数组优化」
线上开期货户是否安全啊?不去线下可以开户吗?
根据数据中的key获取value值
Tableapi & SQL and example module of Flink
C# Mapster 对象映射器学习
R language uses neuralnet package to build neural network regression model (feedforward neural network regression model), visualize the scatter diagram between the actual target value and the predicte
谷歌浏览器80版本以后,如何处理出现的问题SameSite跨域问题
Forwarding to remind metamask how to deal with the potential private key disclosure of the expansion program
Easy introduction to naturallanguageprocessing series topic 6 code practice -- spelling correction based on language model
ThreadLocal与线程池在使用中可能会出现的两个问题
The R language uses the DOTPLOT function of epidisplay package to visualize the frequency of data points in different intervals in the form of point graph, uses the by parameter to specify the groupin
The GLM function of R language is used to build a binary logistic regression model (the family parameter is binomial), and the coef function is used to obtain the model coefficients and analyze the me
GetEmptyBlcoksPre Info