網站導覽

v2.1.0
比較

瀑布圖

逐步呈現起始值經過哪些增減,最後得到結束值。

本頁內容

瀑布圖呈現數值如何經過一連串增減而改變,例如期初現金餘額如何經過各筆流入與流出,得到期末餘額。第一根長條從基準線畫起,後續每根都從上一根的結束位置起算。細線將每根長條的終點接到下一根的起點,方便追蹤累計值。增加和減少以狀態色及數值的正負號區分。

瀑布圖

<div class="card max-w(560) mx-auto">  <div class="card-header">    <h3 class="card-title">Cash</h3>    <p class="card-description">Thousands of dollars, January to June</p>  </div>  <figure class="chart" id="cash" style="--chart-height: 13rem"></figure></div><script>addEventListener('DOMContentLoaded', function () {MasterUI.chart(document.getElementById('cash'), {  type: 'waterfall',  total: 'June',  values: true,  label: 'Cash from January to June, in thousands of dollars',  labels: ['January', 'Sales', 'Refunds', 'Payroll', 'Grants', 'Rent'],  series: [{ name: 'Cash', values: [420, 310, -64, -280, 90, -110] }]})})</script><script type="module">  import { attach } from '@master/ui/behaviors'  attach()</script>
import { Chart } from './ui/chart'<div className="card max-w(560) mx-auto">  <div className="card-header">    <h3 className="card-title">Cash</h3>    <p className="card-description">Thousands of dollars, January to June</p>  </div>  <Chart    id="cash"    style={{ '--chart-height': '13rem' } as React.CSSProperties}    type="waterfall"    total="June"    values    label="Cash from January to June, in thousands of dollars"    labels={['January', 'Sales', 'Refunds', 'Payroll', 'Grants', 'Rent']}    series={[{ name: 'Cash', values: [420, 310, -64, -280, 90, -110] }]}  /></div>
<script>  import Chart from './ui/Chart.svelte'</script><div class="card max-w(560) mx-auto">  <div class="card-header">    <h3 class="card-title">Cash</h3>    <p class="card-description">Thousands of dollars, January to June</p>  </div>  <Chart    id="cash"    style="--chart-height: 13rem"    type="waterfall"    total="June"    values    label="Cash from January to June, in thousands of dollars"    labels={['January', 'Sales', 'Refunds', 'Payroll', 'Grants', 'Rent']}    series={[{ name: 'Cash', values: [420, 310, -64, -280, 90, -110] }]}  /></div>
<script setup>import Chart from './ui/Chart.vue'</script><template>  <div class="card max-w(560) mx-auto">    <div class="card-header">      <h3 class="card-title">Cash</h3>      <p class="card-description">Thousands of dollars, January to June</p>    </div>    <Chart      id="cash"      style="--chart-height: 13rem"      type="waterfall"      total="June"      values      label="Cash from January to June, in thousands of dollars"      :labels="['January', 'Sales', 'Refunds', 'Payroll', 'Grants', 'Rent']"      :series="[{ name: 'Cash', values: [420, 310, -64, -280, 90, -110] }]"    />  </div></template>

total 用來命名最後的合計長條。這根長條從基準線畫到累計總值。省略此選項時,圖表會在最後一筆變動處結束,適合只列出各筆變動的情況。values: true 會在各增減長條上方顯示帶正負號的變動量,數值提示還會顯示該筆變動後的累計值。

#增減與狀態色

瀑布圖是唯一用狀態色繪製資料標記的圖表形式。增加使用成功色,減少使用危險色,與 Stat 元件 的變動值配色相同。每個數值都會標示正負號,數值提示和各資料點的名稱也會保留這個符號。如果數值上升代表負面變化,例如成本增加,請在圖表的 label 與標題中說明。

#選項

選項預設
label無繪圖區的無障礙名稱,說明圖表呈現的內容與單位
labels[]沿刻度排列、環繞雷達圖或位於熱圖各欄上方的標籤
series[]每個資料序列包含 name,並依圖表形式提供 values、value、points、ranges 或 children。也可指定 category、type、low、high 和圓環的 max
total無瀑布圖最後一根合計長條的名稱
min, max, ticks依資料調整, 4刻度範圍的上下限與大致的刻度數。散佈圖的水平軸使用 xMin、xMax 和 xTicks
format, tickFormat依語系數值與刻度標籤的顯示格式。散佈圖的水平軸使用 xFormat
dots, valuesfalse標記折線上的每個資料點,以及顯示每根長條的數值
current無標有 aria-current 的資料點索引

各種圖表共用數值提示、鍵盤操作、圖例、色彩與刻度。請參閱 圖表 的完整選項、CSS 類別與自訂屬性。