以下是一个示例代码,其中演示了通过在p-chart组件上配置选项解决问题的方法:
import { Component } from '@angular/core';
@Component({
selector: 'app-chart',
templateUrl: './chart.component.html',
styleUrls: ['./chart.component.scss']
})
export class ChartComponent {
chartOptions: any = {
scales: {
yAxes: [{
ticks: {
beginAtZero: true
}
}]
}
};
chartData: any = {
datasets: [{
label: 'Sales in past 12 months',
data: [12000, 19000, 30000, 5000, 20000, 3000]
}],
labels: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun']
};
}
在此示例中,我们在p-chart组件中使用了自定义选项,该选项配置了图表的Y轴标尺始于0。如果您在自己的代码中遇到类似的问题,请仔细检查代码,确保已在组件上正确使用选项。