<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ApexCharts 入门示例</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/apexcharts@latest/dist/apexcharts.css">
<script src="https://cdn.jsdelivr.net/npm/apexcharts@latest"></script>
</head>
<body>
<div id="chart"></div>
<script>
// 配置选项
const options = {
chart: {
type: 'line', // 图表类型:折线图
height: 350, // 图表高度
},
series: [{
name: 'Sales', // 数据系列名称
data: [30, 40, 35, 50, 49, 60, 70, 91, 125] // 数据值
}],
xaxis: {
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep'] // X 轴标签
},
stroke: {
curve: 'smooth' // 平滑曲线
},
colors: ['#008FFB'] // 折线颜色
};
// 创建图表
const chart = new ApexCharts(document.querySelector("#chart"), options);
chart.render();
</script>
</body>
</html>