区域
|
价格(元/㎡·天)
|
变化率(%)
|
市中心
|
150
|
+5%
|
天府新区
|
120
|
+3%
|
高新区
|
100
|
+2%
|
双流区
|
80
|
+1%
|
郫都区
|
60
|
不变
|
javascript
// JavaScript代码
const ctx = document.getElementById('chart').getContext('2d');const data = {labels: ['市中心', '天府新区', '高新区', '双流区', '郫都区'],datasets: [{label: '成都写字楼价格趋势',data: [150, 120, 100, 80, 60],backgroundColor: ['FF0000', 'FF8000', 'FFFF00', '00FF00', '0000FF'],}]
};const config = {type: 'bar',data: data,options: {indexAxis:'y',plugins: {legend: {display: false},title: {display: true,text: '成都写字楼价格趋势'}}}
};const myChart = new Chart(ctx, config);
css
/ CSS样式 /
body {font-family: Arial, Helvetica, sans-serif;
}.container {display: flex;justify-content: center;
}.chart {width: 500px;height: 500px;
}.table {margin-left: 20px;
}table {border-collapse: collapse;width: 300px;
}th, td {border: 1px solid black;padding: 5px;
}th {text-align: center;
}