整體的組成
馬賽克圖
欄寬與各欄的總量成正比,欄內再依組成比例分段。
本頁內容
馬賽克圖同時呈現兩種占比。每個標籤對應一欄,欄寬代表該組占總量的比例,欄內各資料序列的區段高度則代表它在該組內的占比。讀者能從同一張圖看出各組的規模與組成,這是等寬堆疊長條圖無法同時呈現的。
馬賽克圖
<div class="card max-w(560) mx-auto"> <div class="card-header"> <h3 class="card-title">Revenue</h3> <p class="card-description">By region and product, in millions of dollars</p> </div> <figure class="chart" id="mix"></figure></div><script>addEventListener('DOMContentLoaded', function () {MasterUI.chart(document.getElementById('mix'), { type: 'marimekko', label: 'Revenue by region and product, in millions of dollars', labels: ['Americas', 'Europe', 'Asia', 'Other'], series: [ { name: 'Hardware', values: [320, 180, 260, 40] }, { name: 'Software', values: [280, 220, 140, 30] }, { name: 'Services', values: [160, 120, 60, 20] } ]})})</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">Revenue</h3> <p className="card-description">By region and product, in millions of dollars</p> </div> <Chart id="mix" type="marimekko" label="Revenue by region and product, in millions of dollars" labels={['Americas', 'Europe', 'Asia', 'Other']} series={[ { name: 'Hardware', values: [320, 180, 260, 40] }, { name: 'Software', values: [280, 220, 140, 30] }, { name: 'Services', values: [160, 120, 60, 20] } ]} /></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">Revenue</h3> <p class="card-description">By region and product, in millions of dollars</p> </div> <Chart id="mix" type="marimekko" label="Revenue by region and product, in millions of dollars" labels={['Americas', 'Europe', 'Asia', 'Other']} series={[ { name: 'Hardware', values: [320, 180, 260, 40] }, { name: 'Software', values: [280, 220, 140, 30] }, { name: 'Services', values: [160, 120, 60, 20] } ]} /></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">Revenue</h3> <p class="card-description">By region and product, in millions of dollars</p> </div> <Chart id="mix" type="marimekko" label="Revenue by region and product, in millions of dollars" :labels="['Americas', 'Europe', 'Asia', 'Other']" :series="[ { name: 'Hardware', values: [320, 180, 260, 40] }, { name: 'Software', values: [280, 220, 140, 30] }, { name: 'Services', values: [160, 120, 60, 20] } ]" /> </div></template>繪圖區的縱軸表示欄內占比,從 0% 到 100%。橫向沒有刻度,因此數值提示的標題會列出該欄的總量及其占整體的比例。面積比長度更難比較,掌握全貌時可用馬賽克圖,要跨組比較同一組成項目時,則可用堆疊長條圖。
#選項
| 選項 | 預設 | |
|---|---|---|
label | 無 | 說明圖表呈現的內容與單位,作為繪圖區的無障礙名稱 |
labels | [] | 沿刻度、雷達圖周圍或熱圖各欄上方顯示的名稱 |
series | [] | 每個資料序列都有 name,並依圖表類型提供 values、value、points、ranges 或 children。可選填 category、type、low 和 high,以及圓環的 max |
format, tickFormat | 依地區設定 | 數值與刻度標籤的顯示格式。散佈圖的橫軸使用 xFormat |
current | 無 | 標有 aria-current 的資料點索引 |
legend, toggle | 有兩個資料序列時顯示、true | 是否顯示圖例,以及是否將圖例項目呈現為核取方塊 |
各種圖表共用數值提示、鍵盤操作、圖例、色彩與刻度。圖表 元件提供這些功能,並列出所有選項、CSS 類別與自訂屬性。