网站首页
百度ECharts
ECharts实例
ECharts入门
地图大全
ECharts官网
源代码:
点击运行 》
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Chart.js 折线图 实例</title> <script src="/js/jquery-1.9.0.min.js"></script> <!-- 引入 chart.js --> <script src="/js/chart.js"></script> </head> <body> <canvas id="myChart" width='400' height='260'></canvas> <script type="text/javascript"> const ctx = document.getElementById('myChart'); const data = { labels: ['周一', '周二', '周三','周四', '周五', '周六', '周日'], datasets: [{ label: '折线图', data: [165, 159, 180, 181, 156, 255, 140], fill: false, borderColor: '#389af4', // 设置线的颜色 tension: 0.1 }] }; const config = { type: 'line', // 设置图表类型 data: data, options: { plugins: { legend: { display: false } } }, }; const myChart = new Chart(ctx, config); </script> </body> </html>
运行结果: