chart import
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<div>
<canvas id="chart" ></canvas>
</div>
Setup :
var data = {
labels: ['1', '2', '3', '4', '5', '6'],
datasets: [{
label: 'xxx',
data: [50, 60, 70, 180, 200, 5],
borderWidth: 1
},
config :
var options = {
responsive: true,
plugins: {
legend: {
position: 'top',
},
title: {
display: true,
text: 'Chart.js Pie Chart'
}
}
};
source : https://www.chartjs.org/docs/latest/samples/line/interpolation.html
var barCtx = $('#chart');
var barchart = new Chart(barCtx, {
type: 'bar',
data: data,
options: options
});
razor 裡使用 js 參數 為 @:
var a = '';
//razor
@{
foreach(var item in lists) {
@:a = '@item'; //@: razor 使用js
}
}
source : https://stackoverflow.com/questions/4599169/using-razor-within-javascript
https://stackoverflow.com/questions/28317182/how-to-pass-a-value-to-razor-variable-from-javascript-variable