我有以下图,它使用两个轴:一个用于差异,另一个用于累积差异。
我想强制两个 y 轴匹配为 0,稍后缩放第二个轴更快(请注意,现在我们有 0:200 匹配)
我一直在检查文档,它似乎包含一些用于此目的的变量:onZero和onZeroAxisIndex。尽管如此,我没有找到任何成功的解决方案。目前,我的轴代码如下所示:
xAxis: {
type: "category",
data: props.dates,
},
yAxis: [
{
type: 'value',
name: 'Discprepancia',
position: 'left',
axisLabel: {
formatter: '{value} °C'
},
},
{
type: 'value',
name: 'Discprepancia acumulada',
position: 'right',
alignTicks: true,
axisLabel: {
formatter: '{value} °C'
}
}
]
编辑:我发现了一个类似的问题在此线程中
我通过使用 yAxis 内的 min 和 max 解决了这个问题,如下所示:
yAxis: [
// Make both y axis ticks to match
{
type: 'value',
name: 'Desviación',
// Title is shown on bottom of axis
interval: 3,
position: 'left',
// alignTicks: true,
axisLabel: {
formatter: '{value}°C'
},
min: function (value) {
const absValue = max_abs(value.min, value.max)
const absValueRounded = (absValue * -1).toFixed(0)
return absValueRounded - (absValueRounded % 3) - 3;
},
max: function (value) {
const absValue = max_abs(value.min, value.max)
const absValueRounded = (absValue).toFixed(0)
return absValueRounded - (absValueRounded % 3) + 3;
},
},
{
type: 'value',
name: 'Desv. media',
position: 'right',
alignTicks: true,
axisLabel: {
formatter: '{value}°C'
},
min: function (value) {
const absValue = max_abs(value.min, value.max)
const absValueRounded = (absValue * -1).toFixed(0)
return absValueRounded - (absValueRounded % 3) - 3;
},
max: function (value) {
const absValue = max_abs(value.min, value.max)
const absValueRounded = (absValue).toFixed(0)
return absValueRounded - (absValueRounded % 3) + 3;
},
}
]
如您所见,我使用了值 3,它与所有绘图变化(对于每个气象站)相匹配。根据您的需要,您可以更改它或动态定义它。