html原生echart柱状图
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/512926cbb7a75577ada7c19a2730db4c.png#pic_center)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Bar Chart Example</title>
<!-- Include Chart.js library -->
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<style>
canvas {
max-width: 600px;
margin: 20px;
}
</style>
</head>
<body>
<!-- Create a canvas element to render the chart -->
<canvas id="myChart"></canvas>
<script>
// Data for the bar chart
var data = {
labels: ['January', 'February', 'March', 'April', 'May'],
datasets: [{
label: 'Sample Bar Chart',
backgroundColor: 'rgba(54, 162, 235, 0.5)',
borderColor: 'rgba(54, 162, 235, 1)',
borderWidth: 1,
data: [12, 19, 15, 10, 7],
}]
};
// Configuration options
var options = {
scales: {
y: {
beginAtZero: true
}
}
};
// Get the canvas element
var ctx = document.getElementById('myChart').getContext('2d');
// Create the bar chart
var myChart = new Chart(ctx, {
type: 'bar',
data: data,
options: options
});
</script>
</body>
</html>