你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

Bar chart

Applies to: ✅Microsoft FabricAzure Data ExplorerAzure MonitorMicrosoft Sentinel

条形图视觉对象至少需要查询结果中的两列。 默认情况下,第一列用作 y 轴。 此列可以包含文本、日期时间或数值数据类型。 其他列用作 x 轴,包含要显示为水平线的数值数据类型。 条形图主要用于比较数值和标称离散值,其中每条线的长度表示其值。

Note

This visualization can only be used in the context of the render operator.

Syntax

T|renderbarchart [with(propertyName=propertyValue [, ...])]

Learn more about syntax conventions.

Parameters

Name 类型 Required Description
T string ✔️ 输入表名称。
propertyName, propertyValue string 键值属性对的逗号分隔列表。 See supported properties.

Supported properties

所有属性都是可选的。

PropertyName PropertyValue
accumulate 是否将每个度量的值加到其所有前导度量中(truefalse)。
kind 可视化效果种类的进一步细化。 有关详细信息,请参阅 kind property
legend 是否显示图例(visiblehidden)。
series 以逗号分隔的列列表,其中的每记录值组合定义了记录所属的系列。
ymin 要在 Y 轴上显示的最小值。
ymax 要在 Y 轴上显示的最大值。
title 可视化效果的标题(string 类型)。
xaxis 如何缩放 x 轴(linearlog)。
xcolumn 结果中的哪一列用于 x 轴。
xtitle x 轴的标题(string 类型)。
yaxis 如何缩放 y 轴(linearlog)。
ycolumns 由逗号分隔的列列表,其中包含根据 x 列的值提供的值。
ytitle y 轴的标题(string 类型)。
ysplit 如何将可视化效果拆分为多个 y 轴值。 有关详细信息,请参阅 ysplit property

ysplit 属性

此可视化效果支持拆分为多个 y 轴值:

ysplit Description
none 为所有系列数据显示单个 y 轴。 这是默认值。
axes 单个图表将显示多个 y 轴(每个系列一个)。
panels 对于每个 ycolumn 值,均会呈现一个图表。 最多五个面板。

Supported properties

所有属性都是可选的。

PropertyName PropertyValue
kind 可视化效果种类的进一步细化。 有关详细信息,请参阅 kind property
series 以逗号分隔的列列表,其中的每记录值组合定义了记录所属的系列。
title 可视化效果的标题(string 类型)。

kind 属性

可以通过提供 kind 属性来进一步详细阐述此可视化效果。 此属性支持的值为:

kind Description
default 每个“条形”都独立存在。
unstacked default 相同。
stacked Stack "bars".
stacked100 对“条形”进行堆叠,并将每个条形拉伸到与其他条形相同的宽度。

Examples

本节中的示例演示如何使用语法帮助你入门。

The examples in this article use publicly available tables in the help cluster, such as the StormEvents table in the Samples database.

The examples in this article use publicly available tables, such as the Weather table in the Weather analytics sample gallery. 可能需要修改示例查询中的表名称以匹配工作区中的表。

呈现条形图

以下查询创建一个条形图,显示每个州的风暴事件数,并仅筛选事件数超过 10 个的州。 该图表直观地显示了跨不同州的事件分布情况。

StormEvents
| summarize event_count=count() by State
| project State, event_count
| render barchart
    with (
    title="Storm count by state",
    ytitle="Storm count",
    xtitle="State",
    legend=hidden
    )

带标记的条形图屏幕截图。

呈现 stacked 条形图

以下查询将创建一个 stacked 条形图,按类型显示德克萨斯州、加利福尼亚州和佛罗里达州选定州的风暴事件总数。 每个条形表示一种风暴事件类型,堆叠条形图显示每种类型中按州划分的风暴事件细分。

StormEvents
| where State in ("TEXAS", "CALIFORNIA", "FLORIDA")
| summarize EventCount = count() by EventType, State
| order by EventType asc, State desc
| render barchart with (kind=stacked)

堆叠条形图可视化效果的屏幕截图。

呈现 stacked100 条形图

以下查询将创建一个 stacked100 条形图,按类型显示德克萨斯州、加利福尼亚州和佛罗里达州选定州的风暴事件总数。 该图表显示每种类型中各州风暴事件的分布情况。 尽管堆叠的总和在视觉上为 100,但这些值实际上表示事件数,而不是百分比。 此可视化效果有助于理解百分比和实际事件计数。

StormEvents
| where State in ("TEXAS", "CALIFORNIA", "FLORIDA")
| summarize EventCount = count() by EventType, State
| order by EventType asc, State desc
| render barchart with (kind=stacked100)

堆叠 100 条形图可视化效果的屏幕截图。

使用 ysplit 属性

以下查询提供风暴相关的伤亡和死亡的每日摘要,可视化为具有拆分轴/面板的条形图,以便进行更好的比较。

StormEvents
| summarize
    TotalInjuries = sum(InjuriesDirect) + sum(InjuriesIndirect),
    TotalDeaths = sum(DeathsDirect) + sum(DeathsIndirect)
    by bin(StartTime, 1d)
| project StartTime, TotalInjuries, TotalDeaths
| render barchart with (ysplit=axes)

使用 ysplit axes 属性的柱形图屏幕截图。

若要将视图拆分为单独的面板,请指定 panels 而不是 axes

StormEvents
| summarize
    TotalInjuries = sum(InjuriesDirect) + sum(InjuriesIndirect),
    TotalDeaths = sum(DeathsDirect) + sum(DeathsIndirect)
    by bin(StartTime, 1d)
| project StartTime, TotalInjuries, TotalDeaths
| render barchart with (ysplit=panels)

使用 ysplit panels 属性的柱形图屏幕截图。