整体的构成
旭日图
用两层圆环展示整体、各组成部分及其细分。
本页内容
旭日图将一个整体分两层展示。每个数据系列占内环的一个扇区,表示它在整体中的占比。其 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 类和自定义属性。