Я бы посоветовал попробовать использовать компоновщики Horizontal LegendBox и Vertical LegendBox. Вы можете сделать это, передав LegendBoxBuilder во время создания legendBox
// Align legendBox entries vertically, with groups aligned horizontally
const legendBox = chart.addLegendBox( LegendBoxBuilders.HorizontalLegendBox )
// Align legendBox entries horizontally, with groups aligned vertically
const legendBox = chart.addLegendBox( LegendBoxBuilders.VerticalLegendBox )
Если этого недостаточно, вы также можете попробовать сгруппировать серию в legendBox, чтобы они не получили выровнен вне области диаграммы.
// Add a series to a legendBox, attach it to a specific group
legendBox.add(
// Series to attach to the legendBox.
series1,
// Boolean to set if clicking on the checkbox should hide/show the series attached.
true,
// Group name the entry should be grouped under; if no group with the name exists, it is created. If left empty, entry will be grouped under 'undefined group'.
'Group 1'
)
// Add a series to a legendBox, set it to a second group
legendBox.add(
series6,
true,
'Group 2'