我正在使用 Apache ECharts,除了最小值和最大值之外,我不想显示 y 轴的标签。
这是一个屏幕截图,我想隐藏除 1 和 625 之外的所有内容:
目前,我对 y 轴有以下设置:
{
type: "log",
min: 1,
logBase: 5,
}
我认为你可以使用
。formatter
这只是使用
formatter
的示例执行。
option = {
yAxis: {
type: "log",
min: 1,
max: 625,
logBase: 5,
axisLabel: {
formatter: function(value, index) {
// If the value is equal to the min or max, return the value
if (value === 1 || value === 625) {
return value;
}
// Otherwise, return an empty string to hide the label
return '';
}
}
}
};option = {
yAxis: {
type: "log",
min: 1,
max: 625,
logBase: 5,
axisLabel: {
formatter: function(value, index) {
// If the value is equal to the min or max, return the value
if (value === 1 || value === 625) {
return value;
}
// Otherwise, return an empty string to hide the label
return '';
}
}
}
};
您可以在此处看到我使用
formatter
来自定义标签在 y 轴上的显示。该函数检查标签的当前值是否等于最小值或最大值,如果为 true,则返回该值,如果为 false,则返回一个空字符串,因此我们使用的这个空字符串可能隐藏了标签,但实际上它显示为 ""
。