@ostup17
Начинающий программист (flutter dev - frontend de)

Как «удалить переменную»?

Мне нужно в else, добавить какой-то код, который будет удалять вторую серию. Вот мой код
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;
          }
        })

Вот, что я получаю627b69163af55878881635.png Много второй серии (при клике несколько раз на чекбокс). А мне нужно, чтобы если чекбокс не был выбран, то вторая серия как-то удалялась. Возможно ли это?
  • Вопрос задан
  • 222 просмотра
Решения вопроса 1
@alexalexes
Удаление плота:
https://docs.anychart.com/Stock_Charts/Chart_Plots....
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.


Удаление серии:
https://docs.anychart.com/Working_with_Data/Series....

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.
Ответ написан
Комментировать
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы
КРАФТТЕК Санкт-Петербург
от 60 000 до 80 000 ₽
Brightdata Тель-Авив
от 5 500 до 6 500 $
Rocket Брянск
от 60 000 до 100 000 ₽
28 мая 2024, в 17:13
35000 руб./за проект
28 мая 2024, в 17:11
15000 руб./за проект
28 мая 2024, в 17:01
2000 руб./за проект