htmlewislulu-html-ppt-skill/html-ppt/templates/single-page/chart-line.html

36 lines
1.9 KiB
HTML

<!DOCTYPE html>
<html lang="zh-CN"><head><meta charset="utf-8"><title>Chart · Line</title>
<link rel="stylesheet" href="../../assets/fonts.css">
<link rel="stylesheet" href="../../assets/base.css">
<link rel="stylesheet" id="theme-link" href="../../assets/themes/minimal-white.css">
<link rel="stylesheet" href="../../assets/animations/animations.css">
<script src="https://cdn.jsdelivr.net/npm/chart.js@4.4.3/dist/chart.umd.min.js"></script>
</head><body class="single">
<div class="deck"><section class="slide is-active" data-title="Line chart">
<p class="kicker">Chart · 折线图</p>
<h2 class="h2">日活与留存并排看</h2>
<div class="card mt-l" style="height:520px;padding:28px"><canvas id="c"></canvas></div>
<script>
addEventListener('DOMContentLoaded',()=>{
const css=getComputedStyle(document.documentElement);
const accent=css.getPropertyValue('--accent').trim();
const acc2=css.getPropertyValue('--accent-2').trim();
const text2=css.getPropertyValue('--text-2').trim();
const border=css.getPropertyValue('--border').trim();
new Chart(document.getElementById('c'),{type:'line',
data:{labels:['W1','W2','W3','W4','W5','W6','W7','W8','W9','W10','W11','W12'],
datasets:[
{label:'DAU (K)',data:[12,14,15,19,24,28,33,38,45,51,58,66],
borderColor:accent,backgroundColor:accent+'22',fill:true,tension:.4,borderWidth:3,pointRadius:4},
{label:'Retention %',data:[38,40,42,45,48,50,53,55,58,60,62,64],
borderColor:acc2,backgroundColor:acc2+'22',fill:true,tension:.4,borderWidth:3,pointRadius:4}
]},
options:{plugins:{legend:{labels:{color:text2}}},
scales:{x:{ticks:{color:text2},grid:{color:border}},
y:{ticks:{color:text2},grid:{color:border}}}}});
});
</script>
</section></div>
<script src="../../assets/runtime.js"></script>
</body></html>