使用 pimeng Chart 设置最小值 yAxes
set min value yAxes using pimeng Chart
我正在使用 primeng 可视化带有 angular 的图表,但 y 轴的最小值不起作用。有人可以告诉我我做错了什么吗?
barComponent.ts
import { Component, OnInit } from "@angular/core";
@Component({
selector: "app-grafica-bar",
templateUrl: "./grafica-bar.component.html",
styleUrls: ["./grafica-bar.component.css"]
})
export class GraficaBarComponent implements OnInit {
data: any;
options: any;
constructor() {
this.data = {
labels: [
"Enero",
"Febrero",
"Marzo",
"Abril",
"Mayo",
"Junio",
"Julio",
"Agosto",
"Septiembre",
"Octubre",
"Noviembre",
"Diciembre"
],
datasets: [
{
label: 'Descargas',
backgroundColor: ['#16d24a', '#2ece47', '#40cb44', '#5ac640', '#6ac43e', '#75c23c', '#16d24a', '#3fb37b', '#28ad97', '#1aa9a8', '#02a3c3', '#02a3c3'],
data: [65, 59, 80, 81, 56, 10, 55, 65, 59, 80, 81, 56]
}
]
}
this.options = {
scales: {
yAxes: {
ticks: {
beginAtZero: true,
min: 0,
max: 100
}
}
}
}
}
ngOnInit() {};
}
得到的结果是
enter image description here
谢谢大家
解决了!!
this.options = {
scales: {
yAxes: [{
ticks: {
beginAtZero: true,
suggestedMax: 100,
}
}]
}
}
我正在使用 primeng 可视化带有 angular 的图表,但 y 轴的最小值不起作用。有人可以告诉我我做错了什么吗?
barComponent.ts
import { Component, OnInit } from "@angular/core";
@Component({
selector: "app-grafica-bar",
templateUrl: "./grafica-bar.component.html",
styleUrls: ["./grafica-bar.component.css"]
})
export class GraficaBarComponent implements OnInit {
data: any;
options: any;
constructor() {
this.data = {
labels: [
"Enero",
"Febrero",
"Marzo",
"Abril",
"Mayo",
"Junio",
"Julio",
"Agosto",
"Septiembre",
"Octubre",
"Noviembre",
"Diciembre"
],
datasets: [
{
label: 'Descargas',
backgroundColor: ['#16d24a', '#2ece47', '#40cb44', '#5ac640', '#6ac43e', '#75c23c', '#16d24a', '#3fb37b', '#28ad97', '#1aa9a8', '#02a3c3', '#02a3c3'],
data: [65, 59, 80, 81, 56, 10, 55, 65, 59, 80, 81, 56]
}
]
}
this.options = {
scales: {
yAxes: {
ticks: {
beginAtZero: true,
min: 0,
max: 100
}
}
}
}
}
ngOnInit() {};
}
得到的结果是
enter image description here
谢谢大家
解决了!!
this.options = {
scales: {
yAxes: [{
ticks: {
beginAtZero: true,
suggestedMax: 100,
}
}]
}
}