LookML 資訊主頁的表格圖表參數

本頁說明如何使用 dashboard.lkml 檔案中的 LookML 資訊主頁參數,新增及自訂 type: looker_grid 的 LookML 資訊主頁元素。

如要瞭解如何透過 Looker UI 建立表格圖表,請參閱「表格圖表選項」說明文件頁面。

應用實例


## BASIC PARAMETERS
name: element_name
title: 'Element Title'
type: looker_grid
height: N
width: N
top: N
left: N
row: N
col: N
refresh: N (seconds | minutes | hours | days)
note_state: collapsed | expanded
note_display: above | below | hover
note_text: 'note text'

## QUERY PARAMETERS
model: model_name
explore: explore_name
fields: [view_name.field_name, view_name.field_name, …]
dimensions: [view_name.field_name, view_name.field_name, …]
measures: [view_name.field_name, view_name.field_name, …]
sorts: [view_name.field_name asc | desc, view_name.field_name, …]
pivots: [view_name.field_name, view_name.field_name, …]
fill_fields: [view_name.field_name, view_name.field_name, …]
subtotals: [view_name.field_name, view_name.field_name, …]
total: true | false
row_total: right | left | false
limit: N
column_limit: N
filters:
  view_name.field_name: 'Looker filter expression' | 'filter value'
filter_expression:  'Looker custom filter expression'
listen:
  dashboard_filter_name: view_name.field_name
query_timezone: 'specific timezone' | user_timezone
analysis_config: # can only be used when the Forecasting Labs feature is enabled
  forecasting:
  - confidence_interval: N
    field_name: view_name.field_name
    forecast_n: N
    forecast_interval: day | month | a time frame with dimension fill
    seasonality: N
merged_queries:
- 'primary query definition'
- 'next source query definition'
  join_fields:
  - field_name: view_name.field_name
    source_field_name: view_name.field_name

## COLUMN PARAMETERS
auto_size_all_columns: true | false
column_order: [view_name.field_name, view_name.field_name, …]
pinned_columns:
    view_name.field_name: left

## PLOT PARAMETERS
table_theme: editable | white | gray | transparent | unstyled
show_row_numbers: true | false
hide_totals: true | false
hide_row_totals: true | false
transpose: true | false
hidden_fields: [view_name.field_name, view_name.field_name, …]
limit_displayed_rows: true | false
limit_displayed_rows_values:
  show_hide: show | hide
  first_last: first | last
  num_rows: 'N'

## SERIES PARAMETERS
truncate_text: true | false
show_view_names: true | false
size_to_fit: true | false
dynamic_fields:
- table_calculation: {'table calculation definition'}
- measure: {'custom measure or custom filtered measure definition'}
- dimension: {'custom dimension definition'}
series_labels:
    view_name.field_name: 'Series Label'
series_column_widths:
    view_name.field_name: N
series_cell_visualizations:
    view_name.field_name:
        is_active: true | false
        palette:
            palette_id: 'palette ID'
            collection_id: 'collection ID'
            custom_colors:
            - 'color value'
        value_display: true | false
series_text_format:
    view_name.field_name:
        fg_color: 'color value'
        bg_color: 'color value'
        bold: true | false
        italic: true | false
        align: left | center | right
series_collapsed:
    view_name.field_name: true | false
series_value_format:
    view_name.field_name:
        format_string: 'value formatting string'

## FORMATTING PARAMETERS
color_application:
    collection_id: 'collection ID'
    palette_id: 'palette ID'
header_font_color: 'color value'
header_background_color: 'color value'
header_text_alignment: left | center | right
header_font_size: N
rows_font_size: N
enable_conditional_formatting: true | false
conditional_formatting_include_totals: true | false
conditional_formatting_include_nulls: true | false
conditional_formatting:
  {'desired conditional formatting'}

參數定義

參數名稱 說明
基本參數
name (用於元素) 建立元素
title (用於元素) 變更元素名稱向使用者顯示的方式
type (用於元素) 決定要在元素中使用的圖表類型
height (用於元素) 定義 layout: tile 和 layout: static 資訊主頁中元素的高度,單位為 tile_size
width (用於元素) 定義 layout: tile 和 layout: static 資訊主頁中元素的寬度,單位為 tile_size
top 定義 layout: static 資訊主頁中元素的由上至下位置,單位為 tile_size
left 定義 layout: static 資訊主頁中元素的左右位置,單位為 tile_size
row 定義 layout: newspaper 資訊主頁中元素的由上至下位置 (以列為單位)
col 定義 layout: newspaper 資訊主頁中元素的左右位置 (以欄為單位)
refresh (用於元素) 設定元素自動重新整理的間隔時間
note_state 定義附註是否要收合或展開 (如果附註過大,無法在元素寬度內以單行顯示)
note_display 定義附註在元素上的顯示位置
note_text 指定記事中顯示的文字
查詢參數
model 定義用於元素查詢的模型
explore (用於元素) 定義要用於元素查詢的探索
fields 定義要用於元素查詢的欄位。這項功能可取代 dimensions 和 measures。
dimensions 定義元素查詢要使用的維度
measures 定義要用於元素查詢的測量指標
sorts 定義元素查詢要使用的排序
pivots 定義應透視並用於元素查詢的維度
fill_fields 定義使用維度填補選項的維度
subtotals 定義要計算小計的欄位
total 指定是否顯示表格圖表的資料欄總計
row_total 指定是否顯示表格圖表的資料列總數
limit 定義元素查詢的資料列數上限
column_limit 定義元素查詢的資料欄限制
filters (用於元素) 定義元素查詢無法變更的篩選器
filter_expression 定義無法變更的自訂篩選器,用於元素查詢
listen 如果已建立 filters (用於資訊主頁),則定義「可以」變更元素查詢的篩選器
query_timezone 定義執行查詢時應使用的時區
analysis_config 21.14 版新增 定義執行查詢時應執行的預測分析。必須啟用預測研究室功能。
merged_queries 定義合併結果查詢
資料欄參數
auto_size_all_columns 自動調整每個表格欄的大小,使其寬度與欄標題或最長資料值相同 (以較寬者為準)
column_order 排序表格圖表中的資料欄
pinned_columns 定義要固定在表格圖表左側的資料欄
圖表參數
table_theme 將五種表格著色選項之一套用至表格圖表
show_row_numbers 設定是否在每個表格列的開頭顯示列號
hide_totals 設定表格圖表是否顯示資料欄總計
hide_row_totals 設定表格圖表是否顯示資料列總數
transpose 設定是否要將表格列轉置為欄
hidden_fields 指定要在查詢中使用,但不在圖表中顯示的欄位
limit_displayed_rows 根據資料列在結果中的位置,顯示或隱藏圖表中的資料列
系列參數
truncate_text 使用刪節號 (...) 縮短欄標題和資料儲存格中的文字
show_view_names 顯示檢視表名稱,以及每個資料欄標頭的欄位名稱
size_to_fit 自動調整所有資料欄的寬度,讓表格完美符合檢視元素的寬度
dynamic_fields 在表格圖表中加入資料表計算或自訂欄位
series_labels 為圖表中的每個資料欄指定自訂標籤
series_column_widths 指定圖表中資料欄的特定寬度
series_cell_visualizations 指定資料欄是否使用「儲存格圖表」圖表選項。這個參數有 is_active、palette 和 value_display 子參數。
series_text_format 指定各欄的儲存格文字版面配置。這個參數有 fg_color、bg_color、bold、italic 和 align 子參數。
series_collapsed 指定含有小計的資料欄是否要收合
series_value_format 使用自訂格式定義資料欄的值格式
格式設定參數
color_application 將顏色套用至儲存格圖表和條件式格式設定
header_font_color 將字型顏色套用至欄標題
header_background_color 將顏色套用至欄標頭的背景
header_text_alignment 將欄標題靠左、靠右或置中對齊
header_font_size 將字型大小套用至欄標題
rows_font_size 將字型大小套用至資料儲存格內的文字
enable_conditional_formatting 設為 true,定義表格圖表的顏色編碼規則
conditional_formatting_include_totals 指定是否將總計納入顏色編碼配置
conditional_formatting_include_nulls 指定是否應將空值表示為零
conditional_formatting 使用 conditional_formatting 及其子參數,定義表格圖表的顏色編碼規則

基本參數

定義 LookML 資訊主頁元素時,您必須至少指定 name 和 type 參數的值。其他基本參數 (例如 title、height 和 width) 會影響元素在資訊主頁中的位置和外觀。

name

本節說明資訊主頁元素中的 name 參數。

name 也可以做為資訊主頁篩選器的一部分,詳情請參閱「資訊主頁參數」說明文件頁面。

每個 name 宣告都會建立新的資訊主頁元素,並指派名稱。元素名稱不得重複。使用 layout: grid 資訊主頁時,名稱有時會出現在 elements 參數中;將元素整理成圖塊群組 (type: group) 時,名稱則會出現在子元素的 group 參數中。

- name: orders_by_date

title

本節說明資訊主頁元素中的 title 參數。

title 也可以做為資訊主頁的一部分,詳情請參閱「資訊主頁參數」說明文件頁面。

title 也可以做為資訊主頁篩選器的一部分,詳情請參閱「資訊主頁參數」說明文件頁面。

title 參數可讓您變更元素名稱向使用者顯示的方式。如未指定,標題會預設為 name 元素。

請參閱以下範例:

- name: sales_overview
  title: '1) Sales Overview'

如果使用這種格式,元素就不會顯示為「銷售總覽」,而是「1) 銷售總覽」。

type

本節說明資訊主頁元素中的 type 參數。

type 也可以做為資訊主頁篩選器的一部分,詳情請參閱「資訊主頁參數」說明文件頁面。

type 也可以做為彙整的一部分,詳情請參閱 type (用於彙整) 參數說明文件頁面。

type 也可以做為維度的一部分,詳情請參閱「維度、篩選器和參數類型」說明文件頁面。

type 也可以做為測量指標的一部分,詳情請參閱「測量指標類型」說明文件頁面。

type 參數會決定元素中使用的圖表類型。

- name: element_name
  type: text | looker_grid | table | single_value | looker_single_record |
        looker_column | looker_bar | looker_scatter | looker_line | looker_area |
        looker_pie | looker_donut_multiples | looker_funnel | looker_timeline |
        looker_map | looker_google_map | looker_geo_coordinates | looker_geo_choropleth |
        looker_waterfall | looker_wordcloud | looker_boxplot | button | group

如要概略瞭解不同類型的 LookML 資訊主頁元素,請參閱 type (適用於 LookML 資訊主頁) 說明文件頁面。

height

本節說明資訊主頁元素中的 height 參數。

height 也可以做為資訊主頁資料列的一部分,詳情請參閱資訊主頁參數說明文件頁面。

適用於採用 tile 或 static 版面配置的資訊主頁

height 參數定義元素的高度,單位為 tile_size (以像素定義),適用於 layout: tile 和 layout: static 資訊主頁。

舉例來說,下列程式碼指定 tile_size: 100 和 height: 4,將 orders_by_date 元素的高度設為 400 像素。

- dashboard: sales_overview
  tile_size: 100
  ...

  elements:
  - name: orders_by_date
    height: 4
    ...

適用於採用newspaper版面配置的資訊主頁

height 參數定義 layout: newspaper 資訊主頁中元素的高度,單位為列。

採用新聞版面配置的資訊主頁,預設元素高度為 6 列,約 300 像素。如果資訊主頁的 preferred viewer 參數設為 dashboards-next,則高度下限為 1 列。如果資訊主頁的 preferred viewer 參數設為 dashboards,則高度下限為 2 列。

舉例來說,下列程式碼會將元素設為 12 列高,或設為預設值的其他元素高度的兩倍:

- dashboard: sales_overview
  layout: newspaper
  ...

  elements:
  - name: orders_by_date
    height: 12
    ...

width

本節說明資訊主頁元素中的 width 參數。

width 也可以做為資訊主頁的一部分,詳情請參閱「資訊主頁參數」說明文件頁面。

width 參數定義元素的寬度,單位為 tile_size,適用於 layout: tile 和 layout: static 資訊主頁。

舉例來說,下列程式碼指定 tile_size: 100 和 width: 4,讓 orders_by_date 元素的寬度為 400 像素。

- dashboard: sales_overview
  tile_size: 100
  ...

  elements:
  - name: orders_by_date
    width: 4
    ...

width 參數定義 layout: newspaper 資訊主頁中元素的寬度,單位為欄。

採用報紙版面配置的資訊主頁預設寬度為 24 欄。

舉例來說,下列程式碼會將元素設為資訊主頁寬度的一半:

- dashboard: sales_overview
  layout: newspaper
  ...

  elements:
  - name: orders_by_date
    width: 12
    ...

top

top 參數定義元素由上至下的位置,單位為 tile_size,適用於 layout: static 資訊主頁。

舉例來說,下列程式碼指定 tile_size: 100 和 top: 4,將 orders_by_date 元素的頂端邊緣定位在距離資訊主頁頂端 400 像素的位置。

- dashboard: sales_overview
  tile_size: 100
  ...

  elements:
  - name: orders_by_date
    top: 4
    ...

left

left 參數定義元素由左至右的位置,單位為 tile_size,適用於 layout: static 資訊主頁。

舉例來說,下列程式碼指定 tile_size: 100 和 left: 4,將 orders_by_date 元素的左側邊緣定位在距離資訊主頁左側 400 像素的位置。

- dashboard: sales_overview
  tile_size: 100
  ...

  elements:
  - name: orders_by_date
    left: 4
    ...

row

如果是 layout: newspaper 資訊主頁,row 參數會定義元素頂端邊緣所在的列。如果使用 group 參數將元素放置在圖塊群組中,row 會定義元素相對於群組容器頂端 (row: 0) 的列位置。

資訊主頁頂端為第 0 列。新聞版面配置資訊主頁的預設元素高度為 6 列,也就是說,資訊主頁頂端的資訊主頁元素 (row: 0) 預設會占用第 0 到 5 列。

每列高 50 像素,因此預設元素高度為 6 列,即 300 像素。

舉例來說,假設元素設為預設高度,下列程式碼會將元素設在資訊主頁的第二列元素:

- dashboard: sales_overview
  layout: newspaper
  ...

  elements:
  - name: orders_by_date
    row: 6
    ...

col

如果是 layout: newspaper 資訊主頁,col 參數會定義元素左側邊緣所在的資料欄。如果使用 group 參數將元素放在圖塊群組中,col 會定義元素相對於群組容器左側邊緣 (col: 0) 的欄位置。

資訊主頁分為 24 欄。資訊主頁從左側的第 0 欄開始。報紙版面配置的資訊主頁預設元素寬度為 8 欄,也就是說,資訊主頁左側的資訊主頁元素 (col: 0) 預設會占用第 0 到 7 欄。

舉例來說,下列程式碼會將元素設為資訊主頁中第三欄的元素:

- dashboard: sales_overview
  layout: newspaper
  ...

  elements:
  - name: orders_by_date
    col: 16
    ...

refresh

本節說明資訊主頁元素中的 refresh 參數。

refresh 也可以做為資訊主頁的一部分,詳情請參閱「資訊主頁參數」說明文件頁面。

refresh 參數可讓元素定期自動重新載入,藉此擷取最新資料。如果資訊主頁會持續顯示 (例如在辦公室電視上),這項功能通常很有幫助。請注意,您必須在瀏覽器視窗中開啟資訊主頁,這個參數才會生效。這項設定不會在背景執行,以「預熱」資訊主頁快取。

重新整理頻率可以設為任何數字 (不含小數),單位為秒、分、時或天。例如:

- name: orders_by_date
  refresh: 2 hours

設定較短的重新整理間隔時,請務必謹慎。如果元素背後的查詢需要大量資源,某些元素可能會對資料庫造成過大負擔。

note_state

note_state 參數定義了附註是否會收合或展開,如果附註太大,無法在元素寬度內單行顯示。如果選擇「collapsed」,且附註過長,附註結尾會顯示可點選的刪節號 (...),點選後即可閱讀完整附註。如果選擇「expanded」,且附註內容較長,附註會延伸到其他行。

note_display

note_display 參數定義附註在元素上的顯示位置。above 會將附註放在元素頂端,below 會將附註放在元素底部,hover 則需要使用者將滑鼠游標懸停在 ? 圖示上,才能看到附註。

note_text

note_text 參數會指定元素附註中顯示的文字。

查詢參數

定義 LookML 資訊主頁元素時,您必須至少指定 model 和 explore 查詢參數的值,且至少須使用 dimensions 參數、measures 參數或 fields 參數指定一個欄位。您也可以使用本節所述的其他查詢參數,控制資訊主頁元素中資料的顯示方式。

model

model 參數定義了元素查詢要使用的模型。如未指定,則預設為資訊主頁所在的模型。

- name: orders_by_date
  model: ecommerce

model 參數接受 LookML 常數。您可以在專案的資訊清單檔案中定義常數,然後使用 "@{constant_name}" 語法將常數設為 model 的值。使用常數可讓您在一個地方定義模型名稱,如果有多個資訊主頁元素使用同一個模型,而您要更新模型名稱,這個方法特別實用。

如需更多資訊和 LookML 資訊主頁使用常數的範例,請參閱 constant 參數說明文件頁面。

explore

本節說明資訊主頁元素中的 explore 參數。

explore 也可以做為模型的一部分,詳情請參閱 explore 參數說明文件頁面。

explore 也可以做為資訊主頁篩選器的一部分,詳情請參閱「資訊主頁參數」說明文件頁面。

explore 參數定義了要用於元素查詢的探索。

- name: orders_by_date
  explore: order

explore 參數接受 LookML 常數。您可以在專案的資訊清單檔案中定義常數,然後使用 "@{constant_name}" 語法將常數設為 explore 的值。使用常數可讓您在一個位置定義探索名稱,如果有多個資訊主頁元素使用同一個探索,而您要更新該探索的名稱,這個方法就特別實用。

如需更多資訊和 LookML 資訊主頁使用常數的範例,請參閱 constant 參數說明文件頁面。

fields

fields 參數定義了用於元素查詢的欄位。使用語法 view_name.dimension_name 指定欄位。

## single field example
- name: orders_by_date
  fields: order.order_date

## multiple fields example
- name: orders_by_date
  fields: [order.order_date, order.order_count]

如果使用 fields 參數,就不需要使用 dimensions 和 measures 參數。

dimensions

dimensions 參數定義了元素查詢要使用的維度。使用 view_name.dimension_name 語法指定維度。如果查詢沒有任何 dimensions,請勿加入。

## single dimension example
- name: orders_by_date
  dimensions: order.order_date

## multiple dimension example
- name: orders_by_date
  dimensions: [order.order_date, customer.name]

measures

measures 參數定義了元素查詢要使用的測量指標。請使用 view_name.measure_name 語法指定測量指標。如果查詢沒有任何 measures,請勿加入。

## single measure example
- name: orders_by_date
  measures: order.count

## multiple measure example
- name: orders_by_date
  measures: [order.count, order_item.count]

sorts

sorts 參數會定義元素查詢的排序行為。請先列出主要排序欄位,再列出次要排序欄位。使用 view_name.field_name 語法指定要排序的維度或測量指標。

如果省略 sorts 參數,元素會使用 Looker 的預設排列順序。遞增排序不需要後置字串,遞減排序則需要 desc 後置字串。

以下範例定義了單一排序:

- name: orders_by_date
  sorts: order.order_date desc

以下範例定義了多個排序:

- name: orders_by_date
  sorts: [order.order_date desc, customer.name]

如果透視維度,您可以指定指標名稱、排序方向,以及資料表中目標資料欄的 0 索引編號,藉此排序查詢結果。舉例來說,下列元素會使用索引 0,依第一個資料透視欄排序:

- name: orders_by_category
  sorts: [orders.count desc 0]

如要依資料列總計排序,請指定總計欄的索引。舉例來說,下列元素會使用索引 2 依資料列總數排序,代表含有兩個資料透視欄的查詢總數欄:

- name: orders_by_cohort
  sorts: [users.count desc 2]

pivots

pivots 參數定義了應為元素查詢透視的維度。使用 view_name.dimension_name 語法指定維度。如果查詢沒有任何 pivots,請勿加入。

## single pivot example
- name: orders_by_date
  pivots: customer.gender

## multiple pivot example
- name: orders_by_date
  pivots: [customer.gender, customer.age_tier]

fill_fields

fill_fields 參數定義了使用維度填補選項的維度。使用 view_name.dimension_name 語法指定維度。

- name: orders_by_date
  fill_fields: [orders.created_date, orders.shipped_date]

subtotals

subtotals 參數會定義使用 subtotals 選項的維度。使用 view_name.dimension_name 語法指定維度。

subtotals: [products.department, distribution_centers.name]

total

total 參數會設定是否在表格底部顯示總計列。詳情請參閱「顯示總計」。

total: true | false

## default value: false

row_total

row_total 參數可設定總計欄要顯示在表格右側或左側。只有在有資料透視表時才能運作。詳情請參閱「顯示總計」。

row_total: right | left | false

## default value: false

limit

limit 參數定義了元素查詢應使用的資料列限制。這項限制適用於套用任何資料透視之前的資料列數量。

- name: orders_by_date
  limit: 100

column_limit

column_limit 參數定義了元素查詢應使用的資料欄限制。這項限制適用於套用任何資料透視後的資料欄數量。

- name: orders_by_date
  column_limit: 100

filters

本節說明資訊主頁元素中的 filters 參數。

filters 也可以做為資訊主頁的一部分,詳情請參閱「資訊主頁參數」說明文件頁面。

filters 也可以做為測量指標的一部分,詳情請參閱 filters 參數說明文件頁面。

filters 參數定義了元素查詢應使用的不可變更篩選條件。如要讓使用者可以在資訊主頁中變更篩選器,請使用資訊主頁的 filters 設定篩選器,然後使用 listen 將篩選器套用至元素。

filters 的語法如下:

- name: element_name
  filters:
    orders.created_date: 2020/01/10 for 3 days
    orders.status: Shipped
    # You can create multiple filter statements

每個篩選器都能接受 Looker 篩選運算式或值常數。您也可以在篩選運算式中使用 _localization 或 _user_attributes Liquid 變數,彈性設定篩選值。

filter_expression

filter_expression 參數會為元素的查詢定義不可變更的自訂篩選器。如要讓使用者可以在資訊主頁中變更篩選器,請使用資訊主頁的 filters 設定篩選器,然後使用 listen 將篩選器套用至元素。

- name: element_name
  filter_expression:
  - diff_days(${users.created_date},${user_order_facts.first_order_date}) > 60

Looker 篩選運算式說明文件頁面列出了 Looker 篩選運算式。

listen

檢視者可透過資訊主頁篩選器,以互動方式調整資訊主頁元素中顯示的資料。使用 LookML 資訊主頁的 filters 參數定義資訊主頁篩選器。接著,使用 listen 參數將資訊主頁元素連結至資訊主頁篩選器。

listen 的語法如下:

- name: element_name
  listen:
    filter_name_goes_here: dimension or measure on which to apply
                           the filter using view_name.field_name syntax
    # You can add more than one listen statement

請在元素中加入 listen 參數,然後提供篩選器名稱,後面加上冒號,並使用 view_name.field_name 語法參照要套用篩選器的欄位。舉例來說,您可以建立名為「日期」的篩選器,要求使用者在 UI 的篩選器欄位中輸入日期。接著,您可以將使用者輸入的值套用至 orders_by_date 元素,如下所示:

- dashboard: sales_overview
  ...

  filters:
  - name: date
    type: date_filter

  elements:
 - name: orders_by_date
    listen:
      date: order.order_date
    ...

如果監聽的篩選器已設定 vis_filter: true 參數,篩選器控制項會直接顯示在圖表圖塊頂端的篩選器列中,而非資訊主頁頂端的篩選器列。

如需更多範例,瞭解如何使用 filters 參數和 listen 參數,將資訊主頁篩選器套用至個別資訊主頁元素,請參閱「建構 LookML 資訊主頁」。

query_timezone

query_timezone 參數會指定執行查詢的時區。時區選項會顯示在「timezone 的值」說明文件頁面。如要使用檢視者的時區執行查詢,可以將值指派為 user_timezone。

- name: orders_by_date
  query_timezone: America/Los Angeles
- name: orders_by_customer
  query_timezone: user_timezone

analysis_config

您可以使用下列子參數定義分析:

您可以使用類似以下的語法建立預測:


  analysis_config:
    - forecasting:
      confidence_interval: 0.95
      field_name: orders.count
      forecast_n: 14
      forecast_interval: day
      seasonality: 7

forecasting

forecasting是一種分析類型,可將預測套用至圖表。分析師可透過預測功能,快速將資料預測結果新增至新或現有的「探索」查詢,協助使用者預測及監控特定資料點。

詳情請參閱「在圖表中預測」說明文件頁面。

如要在圖表中加入預測資料,必須啟用預測研究室功能。

confidence_interval

confidence_interval 會設定預測資料值的界限,這些值會以百分比的小數運算式輸入。confidence_interval 為選用項目,預設為空白。


confidence_interval: 0.99 | 0.98 | 0.95 | 0.90 | 0.80

請參閱「在圖表中預測」說明文件頁面的「預測區間」一節。

如要在圖表中加入預測資料,必須啟用預測研究室功能。

field_name

field_name 指定要納入預測的測量指標名稱,最多五個。


field_name: view_name.field_name

forecast_n

forecast_n 指定預測長度。


forecast_n: N # An integer that represents the length of the forecast

請參閱「在圖表中預測」說明文件頁面的「長度」一節。

如要在圖表中加入預測資料,必須啟用預測研究室功能。

forecast_interval

forecast_interval 會設定預測資料值的時間長度間隔。系統會根據「探索」查詢中的時間範圍維度,自動填入forecast_interval。


forecast_interval: day | month # a timeframe with dimension fill

請參閱「Length」說明文件頁面。

如要在圖表中加入預測資料,必須啟用預測研究室功能。

seasonality

seasonality 可讓分析師在預測中考量已知的週期或重複資料趨勢。seasonality 為選用項目,預設為空白。


seasonality: N # An integer that represents the number of rows over which a cycle or pattern repeats

自動季節性設定會以空白 seasonality 值表示。

請參閱「在圖表中預測」說明文件頁面的「季節性」一節。

如要在圖表中加入預測資料,必須啟用預測研究室功能。

merged_queries

merged_queries 參數可讓您將多個查詢的結果合併為單一資訊主頁元素。在元素的 merged_queries 參數中定義每個來源查詢,並使用 join_fields 子參數指定結果合併方式。

以下 LookML 程式碼範例會建立type: looker_grid 的合併結果元素。在這個範例中,merged_queries 參數用於建立資訊主頁元素,將兩項獨立查詢的資料合併為單一表格圖表:

- name: merged_results_element
  title: Merged Results Tile
  type: looker_grid
  merged_queries:
  - model: ecommerce
    explore: users
    type: table
    fields: [users.state, users.count, users.city]
    sorts: [users.count desc 0]
    limit: 5000
    column_limit: 50
    query_timezone: UTC
    listen:
    - State: users.state
  - model: ecommerce
    explore: users
    type: table
    fields: [users.state, users.city]
    sorts: [users.state]
    limit: 500
    column_limit: 50
    query_timezone: UTC
    join_fields:
    - field_name: users.state
      source_field_name: users.state
    - field_name: users.city
      source_field_name: users.city
    listen:
    - State: users.state

在這個範例中,資訊主頁元素會合併兩個來源查詢的資料,這些查詢是以 ecommerce 模型中的 users 探索為基礎。主要查詢包含 users.state、users.count 和 users.city 欄位,並依 users.count 欄位排序結果。第二個來源查詢包含 users.state 和 users.city 欄位,並依 users.state 欄位排序結果。

join_field 參數會根據 users.state 和 users.city 欄位中的相符值,合併來源查詢。

listen 參數會將 State 篩選器套用至兩項查詢,讓資訊主頁檢視者選取特定州別,精細調整資訊主頁圖塊中顯示的查詢結果。

範例:合併公司資料

假設您想建立合併查詢,整合來自兩個不同探索 (company_info 和 companies) 的公司資訊。您想在每個探索的 ipo.stock_symbol、companies.name 和 companies.contact_email 欄位上彙整查詢,建立可傳回公司名稱、公司聯絡電子郵件、IPO 年份、股票代號、員工數量和職缺數量的查詢。您可以在 LookML 中定義合併查詢元素,如下所示:

- name: merged_results_element
  title: Merged Results Tile
  merged_queries:
  - model: market_research
    explore: company_info
    fields: [companies.name, companies.contact_email, ipo.public_year, ipo.stock_symbol]
    filters:
      companies.contact_email: "-NULL"
      ipo.valuation_amount: NOT NULL
    sorts: [ipo.public_year desc]
  - model: company_data
    explore: companies
    fields: [companies.name, ipo.stock_symbol, companies.contact_email,
      companies.number_of_employees, jobs.job_count]
    filters:
      companies.number_of_employees: NOT NULL
      ipo.stock_symbol: "-NULL"
      companies.contact_email: "-NULL"
    sorts: [jobs.job_count desc]
    join_fields:
    - field_name: ipo.stock_symbol
      source_field_name: ipo.stock_symbol
    - field_name: companies.name
      source_field_name: companies.name
    - field_name: companies.contact_email
      source_field_name: companies.contact_email

將篩選器套用至合併查詢元素

先前的合併查詢元素範例示範了如何使用 filters 參數,直接在每個來源查詢中套用硬式編碼篩選器。舉例來說,主要查詢中的篩選器 companies.contact_email: "-NULL" 和 ipo.valuation_amount: NOT NULL 會將結果限制為具有有效聯絡電子郵件和估值的公司。這些查詢層級篩選器會在合併查詢前預先篩選資料,使用者無法變更。

您也可以在每個來源查詢的定義中使用 listen 參數,將資訊主頁篩選器套用至合併查詢元素。舉例來說,假設您在資訊主頁層級,使用 LookML 資訊主頁的 filters 參數定義了名為 Industry 的資訊主頁篩選器:

filters:
- name: Industry
  title: Industry
  type: field_filter
  ui_config:
    type: dropdown_menu
    display: inline
  model: market_research
  explore: company_info
  field: companies.industry

如要將 Industry 篩選器套用至兩個來源查詢中的 companies.industry 欄位,請在每個合併查詢的來源查詢定義中加入 listen 參數,如下所示:

listen:
  Industry: companies.industry

舉例來說,下列程式碼範例會將 Industry 篩選器,新增至上一個範例中合併結果元素的兩個來源查詢。

- name: merged_results_element
  title: Merged Results Tile
  merged_queries:
  - model: market_research
    explore: company_info
    fields: [companies.name, companies.contact_email, ipo.public_year, ipo.stock_symbol]
    filters:
      companies.contact_email: "-NULL"
      ipo.valuation_amount: NOT NULL
    sorts: [ipo.public_year desc]
    listen:
      Industry: companies.industry
  - model: company_data
    explore: companies
    fields: [companies.name, ipo.stock_symbol, companies.contact_email,
      companies.number_of_employees, jobs.job_count]
    filters:
      companies.number_of_employees: NOT NULL
      ipo.stock_symbol: "-NULL"
      companies.contact_email: "-NULL"
    sorts: [jobs.job_count desc]
    join_fields:
    - field_name: ipo.stock_symbol
      source_field_name: ipo.stock_symbol
    - field_name: companies.name
      source_field_name: companies.name
    - field_name: companies.contact_email
      source_field_name: companies.contact_email
    listen:
      Industry: companies.industry

新增這項設定後,當使用者與「Industry」資訊主頁篩選器互動時,合併查詢元素中對應的來源查詢也會一併篩選。

資料欄參數

下列參數對應的是在表格圖表中移動及固定資料欄的功能。

auto_size_all_columns

auto_size_all_columns 參數會自動調整每個資料表欄的大小,使其寬度與欄標題或最長資料值的寬度相同 (以較寬者為準)。這個參數會覆寫 series_column_widths 和 size_to_fit 參數 (如有定義)。

- name: orders_by_date
  auto_size_all_columns: true

column_order

column_order 參數會定義表格圖表中的資料欄順序。

- name: orders_by_date
  column_order: [customer.city, customer.state, customer.count]

pinned_columns

pinned_columns 參數會定義固定在表格圖表左側的資料欄。

- name: orders_by_date
  pinned_columns:
    orders.created_date: left
    distribution_centers.name: left

繪圖參數

下列參數對應表格圖表視覺化編輯器中「繪圖」選單的選項。

table_theme

使用 table_theme 參數,為表格元素套用下列其中一種表格著色選項:

  • editable:資料表包含藍色維度、橘色測量指標和綠色資料表計算。
  • white:表格標題為白色,資料列交替顯示白色和灰色,文字為黑色。
  • gray:表格標頭為灰色,資料列交替顯示白色和淺灰色,文字為深灰色。
  • transparent:表格標頭完全透明,資料列交替顯示完全透明和半透明灰色,文字顏色會根據背景顏色自動調整為黑色或白色。使用自訂嵌入式資訊主頁時,將 table_theme 設為 transparent 相當實用,因為這樣圖表就會顯示圖塊背景顏色。
  • unstyled:表格標頭和資料列為白色,文字為黑色。

table_theme: editable | white | gray | transparent | unstyled

show_row_numbers

show_row_numbers 參數可設定是否在每個表格列的開頭顯示列號。


show_row_numbers: true | false

hide_totals

如果探索包含資料欄總計,hide_totals 會設定圖表是否顯示總計。


hide_totals: true | false

hide_row_totals

如果探索包含資料列總計,hide_row_totals 會設定是否要在圖表中顯示資料列總計。


hide_row_totals: true | false

transpose

transpose 參數可讓您將資料表列轉置為欄。可接受 true 或 false。

- name: orders_by_date
  transpose: true

hidden_fields

hidden_fields 參數會指出查詢中使用的欄位 (如有),但這些欄位不會顯示在圖表中。任何隱藏欄位都會顯示在「探索」的資料表部分。

hidden_fields: [inventory_items.count, distribution_centers.id]

limit_displayed_rows

limit_displayed_rows 參數可讓您根據資料列在結果中的位置,在圖表中顯示或隱藏資料列。舉例來說,如果圖表顯示 7 天累計平均,您可能需要隱藏前 6 列。如果將這個參數設為 true,您就能使用 limit_displays_rows_values 參數及其子參數,指定圖表中要套用這項設定的值和位置。

limit_displayed_rows: true
limit_displayed_rows_values:
  show_hide: hide | show
  first_last: first | last
  num_rows: '10'

limit_displayed_rows_values

使用 limit_displayed_rows_values 參數及其子參數 show_hide、first_last 和 num_rows,搭配 limit_displayed_rows 指定要在圖表中顯示或隱藏哪些資料列。如需使用範例,請參閱「limit_displayed_rows」一節。

show_hide

show_hide 子參數可設定是否在圖表中隱藏特定資料列。將 show_hide 設為 show,圖表就只會顯示部分資料列;將 show_hide 設為 hide,則可從圖表中排除特定資料列。

first_last

first_last 子參數會設定要隱藏或顯示的資料列,是結果集中的第一列或最後一列。將 first_last 設為 first 會顯示或隱藏前幾列,設first_last為 last 則會顯示或隱藏後幾列。

num_rows

num_rows 子參數會設定要隱藏或顯示的列數。舉例來說,num_rows: '10' 會顯示或隱藏圖表結果集的前 10 列或後 10 列。

系列參數

下列參數對應表格圖表視覺化編輯器中「系列」選單的選項。

truncate_text

truncate_text 參數會設定是否要以刪節號 (...) 縮短欄標題和資料儲存格內的文字。


truncate_text: true | false

show_view_names

show_view_names 參數會決定是否在圖表標籤 (例如軸名稱和欄名稱) 中顯示檢視表名稱。

show_view_names: true | false

## default value: true

size_to_fit

size_to_fit 參數會設定是否要調整所有資料欄的寬度,讓表格完美符合檢視元素的寬度。如果 auto_size_all_columns 參數設為 true,則會覆寫 size_to_fit。


size_to_fit: true | false

dynamic_fields

dynamic_fields 參數及其子參數會描述要與圖表搭配使用的資料表計算或自訂欄位。您必須具備建立自訂欄位的權限,才能新增最多 255 個字元的 description,或將 calculation_type 用於自訂群組或自訂分 bin。您必須具備建立資料表計算的權限,才能在資料表計算中新增最多 255 個字元的 description,或在快速計算中使用 calculation_type。

下列子參數可用於定義動態欄位:

您可以使用類似下列的語法建立資料表計算:

dynamic_fields:
  - table_calculation: running_total
    label: Running Total of Items
    expression: running_total(${inventory_items.count})
    value_format_name: decimal_0
    description: your description of up to 255 characters here
    _kind_hint: measure
    _type_hint: number
    is_disabled: false

您可以使用類似下列的語法,為多種計算類型建立捷徑計算:

dynamic_fields:
- category: table_calculation
  description: your description of up to 255 characters here
  label: Percent of Orders Count
  value_format:
  value_format_name: percent_0
  calculation_type: percent_of_column_sum
  table_calculation: percent_of_orders_count
  args:
  - orders.count
  _kind_hint: measure
  _type_hint: number
- category: table_calculation
  description: your description of up to 255 characters here
  label: Percent of previous - Orders Count
  value_format:
  value_format_name: percent_0
  calculation_type: percent_of_previous
  table_calculation: percent_of_previous_orders_count
  args:
  - orders.count
  _kind_hint: measure
  _type_hint: number
- category: table_calculation
  description: your description of up to 255 characters here
  label: Percent change from previous - Orders Count
  value_format:
  value_format_name: percent_0
  calculation_type: percent_difference_from_previous
  table_calculation: percent_change_from_previous_orders_count
  args:
  - orders.count
  _kind_hint: measure
  _type_hint: number
- category: table_calculation
  description: your description of up to 255 characters here
  label: Rank of Orders Count
  value_format: ## this field is optional
  value_format_name: ## this field is optional
  calculation_type: rank_of_column
  table_calculation: rank_of_orders_count
  args:
  - orders.count
  _kind_hint: measure
  _type_hint: number
- category: table_calculation
  description: your description of up to 255 characters here
  label: Running total of Orders Count
  value_format: ## this field is optional
  value_format_name: ## this field is optional
  calculation_type: running_total
  table_calculation: running_total_of_orders_count
  args:
  - orders.count
  _kind_hint: measure
  _type_hint: number

您可以使用類似下列的語法,建立要在圖表中使用的自訂測量指標:

dynamic_fields:
  - measure: avg_sale_price
    label: Average Sale Price
    based_on: products.sale_price
    type: average
    value_format_name: usd
    description: your description of up to 255 characters here
    _kind_hint: measure
    _type_hint: number

您可以使用類似下列的語法,建立篩選過的自訂測量指標,並用於圖表:

dynamic_fields:
  - measure: order_count_for_25_47_year_olds
    based_on: order_items.order_count
    type: count_distinct
    label: Order Count for 25- to 47-Year-Olds
    description: your description of up to 255 characters here
    value_format: 00#
    _kind_hint: measure
    _type_hint: number
    filter_expression: "${users.age} >= 25 AND ${users.age} <= 47"

您可以使用類似下列的語法,建立要在圖表中使用的自訂維度:

dynamic_fields:
  - dimension: user_city_state
    label: User City and State
    expression: concat(${users.city}, ", ", ${users.state})
    description: your description of up to 255 characters here
    _kind_hint: dimension
    _type_hint: string

您可以使用類似下列的語法,為維度建立自訂群組,以便在圖表中使用:

  - category: dimension
  description: 'States by region'
  label: State Groups
  value_format: ## this field is optional
  value_format_name: ## this field is optional
  calculation_type: group_by
  dimension: state_groups
  args:
  - users.state
  - - label: Pacific Northwest
      filter: Oregon,Idaho,Washington
  - Other
  _kind_hint: dimension
  _type_hint: string

您可以使用類似下列的語法,為維度建立自訂分塊,以便在圖表中使用:

- category: dimension
  description: Order item sale prices, in tiers of 10
  label: Sale Price Bins
  value_format:
  value_format_name:
  calculation_type: bin
  dimension: sale_price_bins
  args:
  - order_items.sale_price
  - '10'
  - '0'
  - '100'
  -
  - classic
  _kind_hint: dimension
  _type_hint: string

您可以在元素中加入多個動態欄位。您不需要將資料表計算新增至 fields 參數,即可在圖表中顯示,但您必須將其他類型的動態欄位新增至 fields,才能顯示。

table_calculation

如要定義資料表計算,請使用 table_calculation 子參數命名資料表計算。在 LookML 參照資料表計算時,請使用這個名稱。

measure

measure 子參數會定義自訂測量指標或篩選自訂測量指標的名稱。這個名稱用於在 LookML 中參照測量指標。

dimension

dimension 子參數定義自訂維度的名稱。這個名稱用於在 LookML 中參照維度。

label

label 子參數會定義動態欄位的標題,也就是在圖表中顯示的名稱。這個名稱可能與 table_calculation、measure 或 dimension 子參數中指定的名稱相同或不同。

based_on

如果您使用的是自訂測量指標或篩選過的自訂測量指標,based_on 子參數會使用 view_name.field_name 語法,識別該指標所依據的測量指標。

type

如果使用自訂測量指標,type 子參數會識別匯總類型。可接受 count_distinct、sum、average、min、max 或 median。

description

您可以使用 description 子參數,為任何自訂欄位或資料表計算新增說明,長度上限為 255 個半形字元。當使用者在欄位挑選器中,點選欄位名稱右側的資訊圖示,或是在探索、資訊主頁或 Look 的表格或表格圖表圖表中,將滑鼠游標懸停在欄名稱上時,Looker 就會顯示說明。

expression

如果您使用資料表計算,expression 子參數會定義用於建立資料表計算的 Looker 運算式。

filter_expression

如果您使用自訂篩選測量指標,filter_expression 子參數會定義用於篩選測量指標的 Looker 運算式。

value_format

使用自訂格式時,選用的 value_format 子參數會定義動態欄位的值格式。如要使用預設 Looker 格式,請改用 value_format_name。

value_format_name

選用的 value_format_name 子參數會將預設格式套用至動態欄位。如要使用自訂格式,請改用 value_format。

calculation_type

calculation_type 子參數定義捷徑計算或群組函式的類型,用於建立資料表計算,或為維度建立自訂群組:

自訂欄位 calculation_type 選項:

  • group_by:根據指定的自訂條件,將維度值歸入自訂固定標籤。類似於 SQL 中的 CASE WHEN,或 LookML case 欄位參數。
  • bin:將數值類型維度和自訂維度的值,分組到自訂特徵分塊或層級。類似於 LookML tier 維度類型。

資料表計算 calculation_type 選項:

  • percent_of_column_sum:資料列值除以資料欄值的總和。這項計算只會納入達到查詢資料列限制時,資料表中的值。
  • percent_of_previous:目前資料列的值除以下一列的值。
  • percent_difference_from_previous:目前資料列的值與下一列的值之間的差,除以下一列的值。
  • rank_of_column:資料列的值在資料欄中所有值的排名。這項計算只會納入達到查詢資料列限制時,資料表中的值。
  • running_total:目前資料列的值與資料欄中前面所有資料列值的累計總和。
  • percent_of_previous_column:如為已透視的欄位,則是目前資料欄的值除以左側資料欄的值。
  • percent_change_from_previous_column:如為已透視的欄位,則是目前資料欄值與左側資料欄值之間的差,除以左側資料欄的值。
  • percent_of_row:如為已透視的欄位,則是目前資料欄值的百分比除以該欄位的資料列總和。
  • running_row_total:如為已透視的欄位,則是目前資料欄與這個資料列前面所有資料欄的累計總和。

args 個自訂群組

如果您為維度使用自訂群組,args 會指定將固定標籤套用至維度值的引數。args 採用下列格式:

args:
- view_name.field_name
  - label: specified custom label
    filter: condition for values
  - label: another specified custom label
    filter: a different condition for values
- Other ## An optional customizable group label for values that do not meet specified conditions.

您可以視需要新增多個 label 和 filter 條件,具體取決於所需的群組數量。

請參考上方的範例。

args (自訂特徵分塊)

如果您針對數值維度使用自訂分類,args 會指定將固定層級套用至維度值的引數。args 採用下列格式:

  args:
  - view_name.field_name
  - bin_size ## The numeric interval on which to base each bin, in single quotes
  - min ## The numeric value of the minimum bin size, in single quotes
  - max ## The numeric value of the maximum bin size, in single quotes
  - override ## A value will only appear when a custom bin uses a Custom-sized bin type.
  - style ## The bin display style. Currently, only classic is supported.

請參考上方的範例。

args:快速計算

args 子參數用於指定捷徑計算所用的數值欄位名稱。引數格式如下:

- args:
  - view_name.field_name   ## the field on which the calculation is based

請參考上方的範例。

_kind_hint

選用的 _kind_hint 子參數會指出動態欄位傳回的是維度還是測量指標。可接受的值為 dimension 和 measure。

_type_hint

選用的 _type_hint 子參數會識別動態欄位運算式應產生的資料類型。

is_disabled

選用 is_disabled 子參數可指定是否要在圖表和基礎探索中顯示資料表計算。可接受的值為 true 和 false。

series_labels

使用 name: label 配對,根據系列名稱設定一或多個系列的標籤。

如果是透視圖表,系列名稱就是透視名稱。

series_labels:
  'Yes': iOS Users
  'No': Android Users

如果圖表有多個測量指標,系列名稱就是測量指標欄位名稱。

series_labels:
  inventory_items.count: Inventory
  orders.count: Orders

series_column_widths

根據系列名稱設定一或多個資料欄的寬度。如果 auto_size_all_columns 參數設為 true,則會覆寫 series_column_widths。

series_column_widths:
  order_times.shipping_time: 50
  orders.count: 60

series_cell_visualizations

使用 view_name.field_name 格式指定數列名稱,指出一或多個資料欄是否使用「儲存格視覺化」選項。series_cell_visualizations 包含子參數 is_active、palette 和 value_display。

series_cell_visualizations:
  order_items.count:
    is_active: true
    palette:
      palette_id: my-custom-colors-sequential-0
      collection_id: my-custom-colors
    value_display: true

is_active

選用的 is_active 子參數接受 true 或 false,用來表示是否為該系列啟用長條圖。如果未定義 is_active,則預設為 true。

palette

palette 子參數為選用項目。如未使用,調色盤會預設為執行個體預設顏色集合中的發散調色盤。

如果使用 palette,子參數 palette_id 和 collection_id 會將特定調色盤的顏色套用至長條圖。palette_id 必須使用依序或發散調色盤的 ID。如要進一步瞭解調色盤 ID 和顏色集合 ID,請參閱「color_application」一節。

palette 有一個替代子項參數 custom_colors,可設定二到五個自訂顏色,用於長條:

series_cell_visualizations:
  order_items.count:
    palette:
      custom_colors:
      - orange
      - "#0000ff"
      - red

value_display

選用的 value_display 子參數接受 true 或 false,指出是否要一併顯示每個資料儲存格的值和儲存格圖表。如果未定義 value_display,則預設為 true。

series_text_format

series_text_format 參數及其子參數會指定各欄的儲存格文字版面配置。要設定格式的序列會以 view_name.field_name 語法表示,子參數則會描述格式。

所有子參數均為選用,請只使用需要的參數。

  series_text_format:
    order_items.shipping_time:
      align: right
    order_items.shipped_date:
      align: center
      fg_color: "#EA8A2F"
      bg_color: "#64518A"
      bold: true
      italic: true

fg_color

fg_color 子參數代表儲存格文字的字型顏色。顏色值可採用十六進位字串 (例如 #2ca6cd) 或 CSS 具名顏色字串 (例如 mediumblue)。

bg_color

bg_color 子參數代表儲存格背景顏色。顏色值可採用十六進位字串 (例如 #2ca6cd) 或 CSS 具名顏色字串 (例如 mediumblue)。

bold

bold 子參數會指出儲存格文字是否為粗體,並接受 true 或 false。

italic

italic 子參數會指出儲存格文字是否為斜體,並接受 true 或 false。

align

align 子參數表示儲存格文字的對齊方式,可接受 left、center 或 right。

series_collapsed

series_collapsed 參數定義是否要收合或展開特定序列的小計。使用 view_name.field_name 語法和 true 或 false 識別系列。

series_collapsed:
  users.city: false
  users.state: true

如果資料欄已收合,只要按一下資料儲存格左側的箭頭,就會顯示構成小計的個別元素。

series_value_format

series_value_format 參數會指定要套用至序列的格式,不受套用至基礎維度或測量指標的任何格式影響。如未指定 series_value_format,系統會以基礎維度或測量指標的格式顯示值。

使用 view_name.field_name 語法,找出要設定格式的序列。

format_string 子參數可讓您使用 Excel 樣式格式定義數列的格式。

series_value_format:
  products.retail_price:
    format_string: "$#,##0.00"

您也可以像這樣定義格式:


series_value_format:
  order_items.count: "00#"

format_string 子參數使用的格式與 value_format LookML 參數使用的格式相同。如要瞭解如何指定這些格式,請參閱這個說明文件頁面。

格式設定參數

下列參數對應表格圖表圖表編輯器中「格式設定」選單的選項。

color_application

color_application 參數及其子參數 collection_id 和 palette_id 可用於將特定顏色集合和調色盤套用至資訊主頁元素。如要概略瞭解 Looker 的原生顏色集合,請參閱「顏色集合」說明文件頁面。

如果您有要使用的調色盤集合 ID 和調色盤 ID,可以在 collection_id 和 palette_id 子參數中輸入這些 ID。集合 ID 或調色盤 ID 可以是英數字元代碼,也可以根據顏色集合的名稱產生。Looker 的原生集合會使用英數字元代碼。這些網址是執行個體專屬,格式如下:


color_application:
  collection_id: 1297dk12-86a7-4xe0-8dfc-82de20b3806a
  palette_id: 93c8aeb7-3f8a-4ca7-6fee-88c3617516a1

自訂顏色集合會根據顏色集合的名稱使用集合和調色盤 ID,這些 ID 可在執行個體之間轉移,如下所示:


color_application:
  collection_id: blue-tone-collection
  palette_id: blue-tone-collection-categorical-0

您也可以透過使用者介面,找出想要的顏色、集合或調色盤,並產生 LookML,將這些項目新增至資訊主頁。前往使用者定義的內容 (例如 Look、資訊主頁或探索),並使用 UI 將所需顏色、集合或調色盤套用至該內容的圖表。完成後,請按照步驟取得資訊主頁 LookML,複製產生的 LookML,然後貼到 color_application 區段。

header_font_color

header_font_color 參數會將字型顏色套用至欄標頭。

顏色值可採用十六進位字串 (例如 #2ca6cd) 或 CSS 具名顏色字串 (例如 mediumblue)。


header_font_color: purple

預設顏色取決於使用 table_theme 參數定義的表格主題。

header_background_color

header_background_color 參數會將顏色套用至背景欄標題。

顏色值可採用十六進位字串 (例如 #2ca6cd) 或 CSS 具名顏色字串 (例如 mediumblue)。


header_background_color: #add8e6

預設顏色取決於使用 table_theme 參數定義的表格主題。

header_text_alignment

header_text_alignment 參數會將 left、right 或 center 對齊方式套用至欄標題。


header_text_alignment: center

預設對齊方式為 left。

header_font_size

header_font_size 參數會將 1 到 99 的字型大小套用至欄標題。


header_font_size: 16

標題和資料列字型的預設大小為 12。

rows_font_size

rows_font_size 參數會將 1 到 99 的字型大小套用至資料儲存格內的文字,但不套用至欄標頭。


rows_font_size: 8

標題和資料列字型的預設大小為 12。

enable_conditional_formatting

將 enable_conditional_formatting 設為 true,即可定義規則,依據特定範圍或指定值,為表格圖表設定顏色。


enable_conditional_formatting: true | false

conditional_formatting_include_totals

如果 enable_conditional_formatting 設為 true,conditional_formatting_include_totals 會指定是否將總計納入顏色編碼配置。


conditional_formatting_include_totals: true | false

conditional_formatting_include_nulls

如果 enable_conditional_formatting 設為 true,conditional_formatting_include_nulls 會指定是否應將空值表示為零。


conditional_formatting_include_nulls: true | false

conditional_formatting

將 enable_conditional_formatting 設為 true 後,請使用 conditional_formatting 參數定義規則,為表格圖表加上顏色代碼。您可以透過下列參數,為每項條件式格式設定規則指定設定:

以下是條件式格式設定規則範例:


conditional_formatting: [{type: less than, value: 20, background_color: "#9fdee0",
  font_color: "#b15928", bold: true, italic: false, strikethrough: false,
  fields: [order_items.count], color_application: {collection_id: my-custom-colors,
  palette_id: my-custom-colors-sequential-0}}]

type

type 參數會指定要根據刻度或邏輯條件,用不同顏色標示值。

如要為刻度上的值設定顏色代碼,可以將 type 設為 along a scale...。

如要根據邏輯條件為值加上顏色標示,可以為 type 指定下列其中一個值,並為 value 指定一個值:

  • equal to:規則會套用至等於 value 指定數字的值。
  • not equal to:規則會套用至不等於 value 指定數字的值。
  • greater than:規則會套用至大於 value 指定數字的值。
  • less than:規則會套用至小於 value 指定數字的值。
  • between:規則會套用至介於 value 指定的兩個數字之間的值。
  • not between:規則會套用至不介於 value 指定兩個數字之間的值。
  • 'null':規則僅適用於空值。
  • not null:規則僅適用於非空值。

type: along a scale... | equal to | not equal to | less than | between | not between | 'null' | not null

value

如要根據 'null' 或 not null 以外的邏輯條件,為值設定顏色代碼,請指定規則適用的值。value 參數可接受單一數字,或在 type 設為 between 或 not between 時,接受一組兩個數字。


value: N | [N, N]

background_color

如果顏色編碼是根據邏輯條件 (type 設為 along a scale... 以外的值),請使用 background_color 參數,為套用規則的值指定背景顏色。


background_color: "#49cec1"

font_color

如果顏色標示是根據邏輯條件 (type 設為 along a scale... 以外的值),請使用 font_color 參數,為套用規則的值指定字型顏色。


font_color: "#1f3e5a"

color_application

color_application 參數及其子參數 collection_id、palette_id 和 options 可用於將特定顏色集合和調色盤套用至條件式格式設定規則。

如果您有集合 ID 和調色盤 ID,可以透過這些 ID 將顏色新增至 LookML 資訊主頁。您也可以透過使用者介面找出所需顏色,並產生 LookML 程式碼,將這些顏色新增至資訊主頁。前往使用者定義的內容 (例如 Look、資訊主頁或探索),並使用 UI 將所需顏色套用至該內容的圖表。完成後,請按照步驟取得資訊主頁 LookML,複製產生的 LookML,然後貼到 color_application 區段。如要瞭解 Looker 預先定義的顏色集合,請參閱「顏色集合」說明文件頁面。

將 type 設為 along a scale... 時,可以使用 options 子參數。包含下列子參數:

  • steps:這個參數會將使用的顏色數量限制為指定值,並將資料分成該數量的群組。如果不使用這個參數,系統會根據涵蓋整個調色盤的漸層為資料上色。接受的值介於 2 到 100 之間。
  • mirror:設為 true 時,這個參數會對調色盤兩側套用相同的顏色偏移,使定義中心點兩側的值相等。可接受 true 或 false。
  • constraints:這個參數會設定條件式格式設定套用的資料範圍,以及調色盤套用的中心點。接受的語法如下:constraints: {min: {type: number, value: 3}, max: {type: percentile, value: 99}, mid: {type: average}}
  • reverse:這個參數決定是否要在套用顏色時反轉調色盤。可接受 true 或 false。

bold

根據邏輯條件設定顏色代碼時,請設定是否要將套用規則的值設為粗體。


bold: true | false

italic

根據邏輯條件設定顏色代碼時,請設定是否要將規則套用的值設為斜體。


italic: true | false

strikethrough

根據邏輯條件設定顏色代碼時,請設定是否要為規則的值套用刪除線格式。


strikethrough: true | false

fields

指定規則應套用的欄位。根據預設,規則會套用至所有數值欄位。


fields: [ view_name.field_name ]