整体的构成
多环进度图
用多个圆环分别展示各项数值占各自上限的比例。
本页内容
多环进度图用于展示各自有上限的多个读数,例如三项目标的完成度或套餐中各项配额的使用情况。每个圆环依次向内嵌套,从顶部开始按当前值占 max 的比例填充。图表和该数据系列均未指定上限时,默认为 100。各环用同色的浅色轨道显示剩余部分。
多环进度图
<div class="card max-w(480) mx-auto"> <div class="card-header"> <h3 class="card-title">Today</h3> <p class="card-description">Three goals</p> </div> <figure class="chart chart-split" id="goals" style="--chart-size: 10rem"></figure></div><script>addEventListener('DOMContentLoaded', function () {MasterUI.chart(document.getElementById('goals'), { type: 'rings', label: 'Progress of three goals today, in percent', center: { value: '72%', label: 'Move' }, format: function (value) { return value + '%' }, series: [ { name: 'Move', value: 72 }, { name: 'Exercise', value: 45 }, { name: 'Stand', value: 90 } ]})})</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">Today</h3> <p className="card-description">Three goals</p> </div> <Chart className="chart-split" id="goals" style={{ '--chart-size': '10rem' } as React.CSSProperties} type="rings" label="Progress of three goals today, in percent" center={{ value: '72%', label: 'Move' }} format={function (value) { return value + '%' }} series={[ { name: 'Move', value: 72 }, { name: 'Exercise', value: 45 }, { name: 'Stand', value: 90 } ]} /></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">Today</h3> <p class="card-description">Three goals</p> </div> <Chart class="chart-split" id="goals" style="--chart-size: 10rem" type="rings" label="Progress of three goals today, in percent" center={{ value: '72%', label: 'Move' }} format={function (value) { return value + '%' }} series={[ { name: 'Move', value: 72 }, { name: 'Exercise', value: 45 }, { name: 'Stand', value: 90 } ]} /></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">Today</h3> <p class="card-description">Three goals</p> </div> <Chart class="chart-split" id="goals" style="--chart-size: 10rem" type="rings" label="Progress of three goals today, in percent" :center="{ value: '72%', label: 'Move' }" :format="function (value) { return value + '%' }" :series="[ { name: 'Move', value: 72 }, { name: 'Exercise', value: 45 }, { name: 'Stand', value: 90 } ]" /> </div></template>只需展示一个数值及其接近上限的程度时,可使用仪表盘。
#选项
| 选项 | 默认值 | |
|---|---|---|
label | 无 | 说明图表展示的内容及其单位,用作绘图区的无障碍名称 |
series | [] | 每个系列包含 name 和 values,也可为扇区或圆环提供 value,或为散点图提供 points;还可指定 category、type 及圆环的 max |
min, max, ticks | 自动适配, 4 | 刻度范围的两端及大致的刻度数;散点图的横轴使用 xMin、xMax 和 xTicks |
format, tickFormat | 由区域设置决定 | 数值和刻度的显示格式;散点图的横轴使用 xFormat |
hole, center | .7, 无 | 分别设置环形图内孔的大小和环形图或多环进度图的中心内容 |
legend, toggle | 有两个数据系列时显示, true | 分别控制是否显示图例,以及图例项是否以复选框呈现 |
所有图表类型共用相同的读数提示、键盘操作、图例、配色和刻度机制。图表 组件文档列出了全部选项、CSS 类和自定义属性。