我的下图不应该以0开头,它应该以min值开头,但我的min值会覆盖0值,所以我应用beginAtZero:false,但它不适用于包中的代码,json我已经安装了这个版本的“chart.js”:“^2.9.4”和“ng2 charts”:“^ 4.1.1”
const ctx:any = document.getElementById('myChart');
new Chart(ctx, {
type: 'bar',
data: {
labels:this.labelData,
datasets: [
{
label:'COGS'+this.lastyear,
data: lastYear,
backgroundColor:'rgb(0, 82, 204)',
borderColor: [
'rgb(229, 228, 226)'
]
},
{
label: 'COGS'+this.year,
data: currentYear,
backgroundColor:'rgb(255, 51, 0)',
borderColor: [
'rgb(229, 228, 226)'
]
},
{
label: 'COGS Budget',
data: budget,
backgroundColor:'rgb(230, 138, 0)',
borderColor: [
'rgb(229, 228, 226)'
]
}
]
},
options: {
responsive: true,
tooltips: {
mode: 'index',
// backgroundColor:'rgb(225,225,200)',
intersect: false
},
hover: {
mode: 'index',
intersect: false
},
scales: {
yAxes: [{
display: true,
ticks: {
beginAtZero:false,
min:this.minvaluefromresponse,// value coming from response service
max:this.maxvaluefromresponse,// value coming from response service
callback: v =>'\u20AC'+ v // for assign euro symbol
}
}],
}
},
});