整體的組成
旭日圖
以兩層圓環呈現整體、各部分及其組成。
本頁內容
旭日圖以兩個層級呈現整體的組成。每個資料序列在內環占一個扇形,大小代表它占整體的比例。其 children 則在對應的外環區段各占一個扇形。從中心往外看,就能依序看出各部分及其組成。子項目沿用所屬部分的色相,並以不同的淺色區分。中央留給數值提示。
旭日圖
<div class="card max-w(480) mx-auto"> <div class="card-header"> <h3 class="card-title">Sessions</h3> <p class="card-description">By device and system</p> </div> <figure class="chart chart-split" id="devices" style="--chart-size: 11rem"></figure></div><script>addEventListener('DOMContentLoaded', function () {MasterUI.chart(document.getElementById('devices'), { type: 'sunburst', label: 'Sessions by device and operating system, in percent', format: function (value) { return value + '%' }, series: [ { name: 'Mobile', children: [{ name: 'iOS', value: 34 }, { name: 'Android', value: 27 }] }, { name: 'Desktop', children: [{ name: 'Windows', value: 18 }, { name: 'macOS', value: 12 }, { name: 'Linux', value: 3 }] }, { name: 'Tablet', children: [{ name: 'iPadOS', value: 5 }, { name: 'Android', value: 1 }] } ]})})</script><script type="module"> import { attach } from '@master/ui/behaviors' attach()</script>import { Chart } from './ui/chart'<div className="card max-w(480) mx-auto"> <div className="card-header"> <h3 className="card-title">Sessions</h3> <p className="card-description">By device and system</p> </div> <Chart className="chart-split" id="devices" style={{ '--chart-size': '11rem' } as React.CSSProperties} type="sunburst" label="Sessions by device and operating system, in percent" format={function (value) { return value + '%' }} series={[ { name: 'Mobile', children: [{ name: 'iOS', value: 34 }, { name: 'Android', value: 27 }] }, { name: 'Desktop', children: [{ name: 'Windows', value: 18 }, { name: 'macOS', value: 12 }, { name: 'Linux', value: 3 }] }, { name: 'Tablet', children: [{ name: 'iPadOS', value: 5 }, { name: 'Android', value: 1 }] } ]} /></div><script> import Chart from './ui/Chart.svelte'</script><div class="card max-w(480) mx-auto"> <div class="card-header"> <h3 class="card-title">Sessions</h3> <p class="card-description">By device and system</p> </div> <Chart class="chart-split" id="devices" style="--chart-size: 11rem" type="sunburst" label="Sessions by device and operating system, in percent" format={function (value) { return value + '%' }} series={[ { name: 'Mobile', children: [{ name: 'iOS', value: 34 }, { name: 'Android', value: 27 }] }, { name: 'Desktop', children: [{ name: 'Windows', value: 18 }, { name: 'macOS', value: 12 }, { name: 'Linux', value: 3 }] }, { name: 'Tablet', children: [{ name: 'iPadOS', value: 5 }, { name: 'Android', value: 1 }] } ]} /></div><script setup>import Chart from './ui/Chart.vue'</script><template> <div class="card max-w(480) mx-auto"> <div class="card-header"> <h3 class="card-title">Sessions</h3> <p class="card-description">By device and system</p> </div> <Chart class="chart-split" id="devices" style="--chart-size: 11rem" type="sunburst" label="Sessions by device and operating system, in percent" :format="function (value) { return value + '%' }" :series="[ { name: 'Mobile', children: [{ name: 'iOS', value: 34 }, { name: 'Android', value: 27 }] }, { name: 'Desktop', children: [{ name: 'Windows', value: 18 }, { name: 'macOS', value: 12 }, { name: 'Linux', value: 3 }] }, { name: 'Tablet', children: [{ name: 'iPadOS', value: 5 }, { name: 'Android', value: 1 }] } ]" /> </div></template>各部分若有指定 value,就使用該值,否則取子項目的總和。沒有子項目的部分只在內環顯示。圖例列出各部分的名稱。子項目的名稱會顯示在數值提示中,也會納入對應資料點的名稱。請維持兩個層級,每個部分只放少量子項目。第三層圓環會讓圖表難以判讀。有更多部分時,可用樹狀矩形圖。
#選項
| 選項 | 預設 | |
|---|---|---|
label | 無 | 說明圖表呈現的內容與單位,作為繪圖區的無障礙名稱 |
series | [] | 每個資料序列包含 name,並依圖表形式提供 values、value、points、ranges 或 children。也可指定 category、type、low、high 和圓環的 max |
format, tickFormat | 依語系 | 數值與刻度標籤的顯示格式。散佈圖的水平軸使用 xFormat |
legend, toggle | 有兩個資料序列時, true | 是否顯示圖例,以及圖例項目是否使用核取方塊 |
各種圖表共用數值提示、鍵盤操作、圖例、色彩與刻度。請參閱 圖表元件 的完整選項、CSS 類別與自訂屬性。