Да, это возможно.
При создании записей в LegendBox
const legendBox = chart.addLegendBox( LegendBoxBuilders.HorizontalLegendBox )
// Add a single entry to the LegendBox. Since we know there is only one Entry, we can
// cast the returned entry as one to avoid checking for Arrays.
const entry = legendBox.add( series, true, splineSeries2.getName() ) as LegendBoxEntry
Вы можете подписаться на событие onSwitch , чтобы скрыть соответствующую ось:
// Subscribe to the onSwitch event.
entry.onSwitch( ( _, state ) => {
// The state parameter is the state of the CheckBox
// If the CheckBox was just switched off, dispose of the Axis. Else, restore it.
if ( !state ) {
AxisY2.dispose()
} else {
AxisY2.restore()
}
})
Однако вы не должны утилизировать Оси по умолчанию таким образом, так как нет никакой гарантии, что у вас будут другие Оси на своем месте при их утилизации.