Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
357 views
in Technique[技术] by (71.8m points)

javascript - Is it possible to animate the hidden/shown element when clicking its label in the legend in ChartJs Bubble Chart?

I've been searching everywhere for a way to animate my bubble chart when an element is shown/hidden but couldnt find a solution anywhere. I tried using:

animation: {
  duration: 2000,
  show: {
    duration: 1000,
    x: {
      from: 0
    },
    y: {
      from: 0
    }
  },
  hide: {
    duration: 1000,
    x: {
      to: 0
    },
    y: {
      to: 0
    }
  }
},

as suggested by some websites but it doesnt work.

I have a custom legend with the following callback function:

function legendClickCallback(event) {
    var event = event || window.event;
    var target = event.target || event.srcElement;
    while (target.nodeName !== 'LI') {
        target = target.parentElement;
    }
    var parent = target.parentElement;
    var chartId = parseInt(parent.classList[0].split("-")[0], 10);
    var chart = Chart.instances[chartId];
    var indexData = parseInt($(target).attr('indexData'));
    var meta = chart.getDatasetMeta(indexData);
    meta.hidden = meta.hidden == null ? !chart.data.datasets[indexData].hidden : null;

    chart.update();
};
question from:https://stackoverflow.com/questions/66048657/is-it-possible-to-animate-the-hidden-shown-element-when-clicking-its-label-in-th

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...