共用方式為


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 屬性
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 屬性

ysplit 屬性

此視覺效果支援分割成多個 Y 軸值:

ysplit Description
none 所有數列數據都會顯示單一 Y 軸。 這是預設值。
axes 單一圖表會以多個 Y 軸顯示(每個數列一個)。
panels 每個 ycolumn 值都會轉譯一張圖表。 最多五個面板。

Supported properties

所有屬性都是選擇性的。

PropertyName PropertyValue
kind 進一步闡述視覺效果種類。 如需詳細資訊,請參閱 kind 屬性
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. 您可能需要修改範例查詢中的資料表名稱,以符合工作區中的資料表。

轉譯條形圖

下列查詢會建立條形圖,其中顯示每個狀態的 storm 事件數目,只篩選超過 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 建立條形圖,依所選德克薩斯州、加州和佛羅里達州的類型顯示風暴事件總數。 每個橫條都代表 storm 事件類型,而堆疊橫條會顯示每個類型內狀態的暴風雨事件分解。

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

堆疊條形圖視覺效果的 Scrrenshot。

轉譯 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 軸屬性的柱形圖螢幕快照。

若要將檢視分割成不同的面板,請指定 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 面板屬性的柱形圖螢幕快照。