CustomJS pt2

Hi everyone, below is a code snippet I wrote for an interactive pie chart I’m trying to plot.

From my understanding, this code will be triggered when I interact with the object associated with this callback (slider), and this code should update the data in the source_dict depending on the widget value.

Looking at the last couple of lines (last for loop) I’m clearly updating the value in my source_dict however I don’t see this change being reflected in my plot. Can anyone correct any misunderstandings I may have? (specific context in the previous post if interested)

cjs = CustomJS(args=dict(sl=slider, source=source, source_dict=source_dict),code=''' 
    var year = cb_obj.value;
    var upd_source = {};
    var multiplier = year - 1990;

    for (const [k,v] of Object.entries(source_dict)){
          upd_source[k] = [];

    for (const [k,v] of Object.entries( {
        if (v >= multiplier * 31 && v < multiplier * 32) {
    // Loops through the source_dict (i.e {"1990": CDS({Disease: [...]...,})})
    /* Find whether the year k is the same as the slider value, if so set the CDS data for that year
    as the value in upd_source["Disease"/"Deaths"...] (for e.g) */
    for (const [k,v] of Object.entries(source_dict)){
        if (k == year) {
            for (const [a,b] of Object.entries( {
       = upd_source[a];
        else {
            for (let key in {
       [key] = [];

This is a duplicate of this topic:

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.