let chBox = document.querySelector("#checkbox");
let series_two;
chBox.addEventListener("click", function() {
// document.location.reload();
if (chBox.checked) {
series_two = chart.plot(0).line(data);
series_two.name("НАЦБанк");
} else {
series_two = undefined;
}
})
Много второй серии (при клике несколько раз на чекбокс). А мне нужно, чтобы если чекбокс не был выбран, то вторая серия как-то удалялась. Возможно ли это? DISABLING AND REMOVING
If you want to disable plot temporarily use the enabled() method, the series and settings will stay there once you enable plot again.
To remove plot with all its contents and settings use the dispose() method.
REMOVING SERIES
As far as any chart can be adjusted or added at any time, you can also remove any series. If you know the id of the series that should be removed, invoke removeSeries() method and use series id as a parameter for this method. In the situation, when the series has no id it can be removed using removeSeriesAt() method. removeSeriesAt() method uses series index as a parameter and removes the series with the given index.