powerbi绘制地图_如何使用PowerBI绘制SQL Server 2017图形数据库

powerbi绘制地图

In the article How to plot a SQL Server 2017 graph database using SQL Server R, I highlighted the lack of built-in graph data visualisation as one major limitation of the SQL Server 2017 graph database feature. In the same article, I went on to suggest making use of SQL Server R as one workaround that could be utilised in order to successfully plot and visualise diagrams out of SQL Server 2017 graph database objects. However, whilst 3rd party graph database vendors such as Neo4j provide an interactive and hyperlinked graph diagrams that allows you to – amongst other things – easily drilldown and identify node-relationships as indicated in Figure 1, the graph plotted using SQL Server R is not very interactive in fact it is simply a static image file as shown in Figure 2.

如何使用SQL Server R绘制SQL Server 2017图形数据库一文中 ,我强调了缺少内置图形数据可视化是SQL Server 2017图形数据库功能的主要局限性。 在同一篇文章中,我继续建议使用SQL Server R作为一种变通办法,以便成功地绘制和可视化SQL Server 2017图形数据库对象中的图表。 然而,尽管第三方图形数据库厂商如Neo4j的提供,让您的互动性和超链接的图形图表-除其他事项外-轻松地钻到并确定节点的关系如图1所示,使用SQL Server R不是图形绘制实际上,它非常具有交互性,它只是一个静态图像文件, 如图2所示。

Although the perceived lack of animation in graphs plotted using SQL Server R might not be a deal breaker for data scientists and R developers alike, you may find it hard to convince business end-users to abandon an interactive data visualisation for a static image file. Fortunately, the Microsoft Power BI tool is designed to provide interactive data visualisations for business end-users and it just so happens that it also supports visualisations based off SQL Server 2017 graph database. Therefore, in this article, we take a look at the integration of Power BI and SQL Server 2017 graph database.

尽管使用SQL Server R绘制的图形中缺乏动画的感觉可能对数据科学家和R开发人员来说都不是一件容易的事,但您可能很难说服业务最终用户放弃对静态图像文件的交互式数据可视化。 幸运的是,Microsoft Power BI工具旨在为业务最终用户提供交互式数据可视化,而且恰好它还支持基于SQL Server 2017图形数据库的可视化。 因此,在本文中,我们将研究Power BI和SQL Server 2017图形数据库的集成。

获取数据:SQL Server 2017图形数据库 (Get Data: SQL Server 2017 Graph Database)

Continuing to use our sample SocialGraph graph database created in this article, we begin by importing our sample nodes and edges tables into Power BI Desktop client. The first thing that you will notice is that as you attempt to load these tables, you will run into an error message similar to the one shown in Figure 3.

继续使用本文创建的示例SocialGraph图形数据库,我们首先将示例节点和边表导入Power BI Desktop客户端。 您会注意到的第一件事是,当您尝试加载这些表时,您将遇到类似于图3所示的错误消息。

At first glance, one might assume that there is a software bug in the Power BI Desktop tool which causes internal graph columns to be inaccessible. However, regardless of the client tool you may be using, internal graph columns in SQL Server 2017 are not meant to be accessible by applications external to the SQL Server engine. For instance, Figure 4 shows the properties of node table dbo.Club.

乍一看,可能会认为Power BI Desktop工具中存在一个软件错误,该错误导致内部图形列无法访问。 但是,无论您可能使用的是哪种客户端工具,SQL Server 2017中的内部图形列都不意味着可由SQL Server引擎外部的应用程序访问。 例如, 图4显示了节点表dbo.Club的属性。

Using SQL Server Management Studio (SSMS) as my T-SQL client, I attempted to read the value of the graph_id_* column by executing the code shown in Script 1.

我使用SQL Server Management Studio(SSMS)作为T-SQL客户端,试图通过执行脚本1中显示的代码来读取graph_id_ *列的值。

SELECT 
graph_id_94FADC773CB2462DB180F6BCD8456123
FROM [SocialGraph].[dbo].[Club];

However, the execution of Script 1 led to the error message shown below – which is actually similar to the error message returned in Figure 3 by Power BI Desktop.

但是, 脚本1的执行导致了如下所示的错误消息–实际上类似于Power BI Desktop在图3中返回的错误消息。

Msg 13908, Level 16, State 1, Line 9
Cannot access internal graph column ‘graph_id_94FADC773CB2462DB180F6BCD8456123’.

消息13908,第16层,状态1,第9行
无法访问内部图形列'graph_id_94FADC773CB2462DB180F6BCD8456123'。

So how do we get around an error like this one?

那么,如何解决这种错误呢?

Well, it looks like the following steps do the trick:

好吧,看起来以下步骤可以解决问题:

  1. Write a SELECT statement against graph database table specifying a list of column names that you are looking for (excluding internal graph columns)

    针对图数据库表编写SELECT语句,以指定要查找的列名列表(内部图列除外)
  2. Wrap the above SELECT statement in a SQL Server view object

    将上面的SELECT语句包装在SQL Server视图对象中
  3. Point Power BI to the newly created SQL Server view object

    将Power BI指向新创建SQL Server视图对象

Figure 5 shows a SQL Server view (i.e. getgraph) created using the aforementioned steps being successfully imported into Power BI Desktop.

图5显示了使用上述步骤创建SQL Server视图(即getgraph ),该视图已成功导入Power BI Desktop。

Now that we have found a mechanism to extract a graph database table into Power BI without any errors, we next modify the definition of our sample getgraph view to include joins to dbo.Player, dbo.Club and dbo.playedFor graph database tables as shown in Script 2.

现在,我们已经找到了一种将图形数据库表提取到Power BI中而没有任何错误的机制,接下来我们修改示例getgraph视图的定义,以包括对dbo.Playerdbo.Clubdbo.playedFor图形数据库表的联接,如图所示。在脚本2中

ALTER VIEW getgraph
AS
     SELECT a.name,
            'playedFor' playedFor,
            b.name AS Club
     FROM player a,
          playedFor,
          Club b
     WHERE MATCH(a-(playedFor)->b);

导入自定义Power BI Visual (Import Custom Power BI Visual)

Whilst writing this article, I was using the December 2017 release of Microsoft Power BI Desktop and the release did not readily provide visualisations that supported effective plotting of graph databases. Thus, I had to download and import a Power BI custom visual to successfully plot an interactive graph database. One such custom visual, is the Force-Directed Graph which is an open source custom visual developed by Microsoft and designed for visualising connections between two or more entities. Although my demo is based off the desktop version of Power BI, the Force-Directed Graph visual also works with the web version of Power BI.

在撰写本文时,我正在使用Microsoft Power BI Desktop的2017年12月版,该版本无法轻松提供支持图形数据库有效绘图的可视化效果。 因此,我必须下载并导入Power BI自定义视觉对象才能成功绘制交互式图形数据库。 一种这样的自定义视觉是Force-Directed Graph ,它是Microsoft开发的一种开源自定义视觉,用于可视化两个或多个实体之间的连接。 尽管我的演示基于Power BI的桌面版本,但是Force-Directed Graph视觉效果也可以与Power BI的Web版本一起使用。

Regardless of the version of Power BI you may be using, the installation of the Force-Directed Graph is straightforward; simply click the ellipsis button under the Visualisation pane and choose the import type – in my case, I chose to Import from file. Once the import has been completed, the Force-Directed Graph visual will appear in the list of your visualisations as shown in Figure 6.

不管您使用的Power BI是什么版本, 强制导向图的安装都很简单。 只需单击“可视化”窗格下的省略号按钮,然后选择导入类型-就我而言,我选择了“ 从文件导入” 。 导入完成后, Force-Directed Graph视觉效果将出现在您的视觉效果列表中, 如图6所示。

使用Power BI生成图形数据库 (Generate Graph Database Using Power BI)

Having imported data off a SQL Server 2017 graph database and successfully installed a custom Force-Directed Graph visual, we are only left with the easiest yet interesting part and that is to plot and generate an interactive Power BI graph. Just like in most Power BI visuals, the Force-Directed Graph visual has several properties that can be configured according to user preference. In terms of configuring data fields, the custom visual is likely to auto-detect what dataset fields goes where but just to be certain, Figure 7 indicates the allocation of fields from the getgraph view according to Source, Target and Link Type properties.

从SQL Server 2017图形数据库导入数据并成功安装了自定义的Force-Directed Graph视觉效果后,我们只剩下最简单但有趣的部分,即绘制并生成交互式Power BI图。 就像大多数Power BI可视化一样, Force-directed Graph可视化具有多个属性,可以根据用户偏好进行配置。 在配置数据字段方面,自定义视图可能会自动检测哪些数据集字段将流向何处,但可以肯定的是, 图7根据SourceTargetLink Type属性指示了getgraph视图中字段的分配。

Figure 8 shows that the Force-Directed Graph visual further providers a Format option that can be used to configure properties such as the background appearance of the graph to be plotted, specify data labels and turn on/off graph animations. You can further represent your nodes in the graph using custom images.

图8显示了“ 力向图”视觉效果进一步提供了“格式”选项,该选项可用于配置属性,例如要绘制的图的背景外观,指定数据标签以及打开/关闭图动画。 您可以使用自定义图像进一步在图中表示节点。

Figure 9 shows a basic graph database that we have managed to plot using Power BI. However, the graph can further be improved by spending some time playing around with the “look and feel” properties displayed in Figure 8.

图9显示了我们已经使用Power BI设法绘制的基本图形数据库。 但是,可以通过花一些时间玩图8中显示的“外观”属性来进一步改善图形。

摘要 (Summary)

In addition to using SQL Server R for plotting SQL Server 2017 graph database as discussed in this article, I have used this article to demonstrate a Power BI mechanism for plotting and visualising graph databases. Although, it relies on custom visual, Power BI provides an interactive option for business end-users to utilise in order to visually make sense of their SQL Server 2017 graph database.

除了使用SQL Server R的密谋SQL Server作为讨论2017年图形数据库这篇文章中 ,我用这篇文章来证明用于绘图和可视化图形数据库进行双向电力机制。 尽管Power BI依赖于自定义视觉,但是Power BI提供了一个交互式选项,供业务最终用户使用,以直观地理解其SQL Server 2017图形数据库。

参考资料 (References)

翻译自: https://www.sqlshack.com/plot-sql-server-2017-graph-database-using-powerbi/

powerbi绘制地图

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值