chart-line
展示 砌成一個畫面嘅嗰啲細塊講法:狀態、身分、進度、資料表格同圖表,同唯一嗰種提示形狀。
折線圖將平均分佈嘅點上面嘅一個系列畫成 SVG,唔使 JavaScript。座標軸標籤係 HTML,螢幕閱讀器會跳過圖形。可以展開嘅「顯示數字」入面有晒每個數值。
每個例子都真係用得,不過入面啲連結唔會帶你去邊度。 HTML 顯示可以複製嘅標記。
每週銷量對比目標
<div rst-box-head >
<h2 id ="weekly-h" >每週銷量</h2 >
</div >
<div rst-card >
<figure rst-chart aria-labelledby ="weekly-h" aria-describedby ="weekly-d" >
<p rst-chart-desc id ="weekly-d" >銷量差唔多每週都升,第 6 週超過咗 600 嘅目標。</p >
<div rst-chart-plot aria-hidden ="true" >
<div rst-chart-y >
<span >750</span ><span >500</span ><span >250</span ><span >0</span >
</div >
<svg viewBox ="0 0 1000 1000" preserveAspectRatio ="none" focusable ="false" >
<path rst-chart-grid d ="M0 0H1000M0 333.3H1000M0 666.7H1000" />
<path rst-chart-base d ="M0 1000H1000" />
<path rst-chart-goal d ="M0 200H1000" />
<polyline rst-chart-line points ="0,840 142.9,760 285.7,653.3 428.6,680 571.4,480 714.3,186.7 857.1,133.3 1000,80" />
<path rst-chart-ring d ="M1000 80h0" />
<path rst-chart-dot d ="M1000 80h0" />
</svg >
<div rst-chart-hits >
<span title ="第 1 週:120" ></span ><span title ="第 2 週:180" ></span ><span title ="第 3 週:260" ></span ><span title ="第 4 週:240" ></span ><span title ="第 5 週:390" ></span ><span title ="第 6 週:610" ></span ><span title ="第 7 週:650" ></span ><span title ="第 8 週:690" ></span >
</div >
<div rst-chart-x >
<span rst-chart-keep >1</span ><span >2</span ><span rst-chart-keep >3</span ><span >4</span ><span rst-chart-keep >5</span ><span >6</span ><span >7</span ><span rst-chart-keep >8</span >
</div >
</div >
<p rst-chart-key >目標:600</p >
<details rst-chart-data >
<summary >顯示數字</summary >
<div rst-table-scroll tabindex ="0" role ="region" aria-labelledby ="weekly-h" >
<table rst-table ="dense" aria-labelledby ="weekly-h" >
<thead >
<tr >
<th scope ="col" >週</th >
<th scope ="col" rst-num >賣出</th >
</tr >
</thead >
<tbody >
<tr >
<th scope ="row" >1</th >
<td rst-num >120</td >
</tr >
<tr >
<th scope ="row" >2</th >
<td rst-num >180</td >
</tr >
<tr >
<th scope ="row" >3</th >
<td rst-num >260</td >
</tr >
<tr >
<th scope ="row" >4</th >
<td rst-num >240</td >
</tr >
<tr >
<th scope ="row" >5</th >
<td rst-num >390</td >
</tr >
<tr >
<th scope ="row" >6</th >
<td rst-num >610</td >
</tr >
<tr >
<th scope ="row" >7</th >
<td rst-num >650</td >
</tr >
<tr >
<th scope ="row" >8</th >
<td rst-num >690</td >
</tr >
</tbody >
<tfoot >
<tr >
<th scope ="row" >目標</th >
<td rst-num >600</td >
</tr >
</tfoot >
</table >
</div >
</details >
</figure >
</div >
有一週冇數據
缺咗嘅數值會令條線斷開,喺表格入面顯示做「冇數據」,所以唔會俾人當成零。
<div rst-box-head >
<h2 id ="weekly-h" >每週銷量</h2 >
</div >
<div rst-card >
<figure rst-chart aria-labelledby ="weekly-h" aria-describedby ="weekly-d" >
<p rst-chart-desc id ="weekly-d" >第 5 週冇銷售紀錄;條線喺嗰度斷開。</p >
<div rst-chart-plot aria-hidden ="true" >
<div rst-chart-y >
<span >750</span ><span >500</span ><span >250</span ><span >0</span >
</div >
<svg viewBox ="0 0 1000 1000" preserveAspectRatio ="none" focusable ="false" >
<path rst-chart-grid d ="M0 0H1000M0 333.3H1000M0 666.7H1000" />
<path rst-chart-base d ="M0 1000H1000" />
<path rst-chart-goal d ="M0 200H1000" />
<polyline rst-chart-line points ="0,840 142.9,760 285.7,653.3 428.6,680" />
<polyline rst-chart-line points ="714.3,186.7 857.1,133.3 1000,80" />
<path rst-chart-ring d ="M1000 80h0" />
<path rst-chart-dot d ="M1000 80h0" />
</svg >
<div rst-chart-x >
<span rst-chart-keep >1</span ><span >2</span ><span rst-chart-keep >3</span ><span >4</span ><span rst-chart-keep >5</span ><span >6</span ><span >7</span ><span rst-chart-keep >8</span >
</div >
</div >
<p rst-chart-key >目標:600</p >
<details rst-chart-data >
<summary >顯示數字</summary >
<div rst-table-scroll tabindex ="0" role ="region" aria-labelledby ="weekly-h" >
<table rst-table ="dense" aria-labelledby ="weekly-h" >
<thead >
<tr >
<th scope ="col" >週</th >
<th scope ="col" rst-num >賣出</th >
</tr >
</thead >
<tbody >
<tr >
<th scope ="row" >1</th >
<td rst-num >120</td >
</tr >
<tr >
<th scope ="row" >2</th >
<td rst-num >180</td >
</tr >
<tr >
<th scope ="row" >3</th >
<td rst-num >260</td >
</tr >
<tr >
<th scope ="row" >4</th >
<td rst-num >240</td >
</tr >
<tr >
<th scope ="row" >5</th >
<td rst-num >冇數據</td >
</tr >
<tr >
<th scope ="row" >6</th >
<td rst-num >610</td >
</tr >
<tr >
<th scope ="row" >7</th >
<td rst-num >650</td >
</tr >
<tr >
<th scope ="row" >8</th >
<td rst-num >690</td >
</tr >
</tbody >
<tfoot >
<tr >
<th scope ="row" >目標</th >
<td rst-num >600</td >
</tr >
</tfoot >
</table >
</div >
</details >
</figure >
</div >