From 46e629fc9e29af792981908085fa4e7b09024dc3 Mon Sep 17 00:00:00 2001 From: Jonas Van Der Donckt <38005924+jonasvdd@users.noreply.github.com> Date: Mon, 8 Jan 2024 10:56:14 +0100 Subject: [PATCH] :sparkles: fix for #275 (#286) * :sparkles: fix for #275 * :broom: review code --------- Co-authored-by: Jeroen Van Der Donckt --- .../figure_resampler/assets/coarse_fine.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/plotly_resampler/figure_resampler/assets/coarse_fine.js b/plotly_resampler/figure_resampler/assets/coarse_fine.js index 3d850f3b..ee0a0b58 100644 --- a/plotly_resampler/figure_resampler/assets/coarse_fine.js +++ b/plotly_resampler/figure_resampler/assets/coarse_fine.js @@ -90,7 +90,7 @@ window.dash_clientside = Object.assign({}, window.dash_clientside, { const layout_axis_anchors = getLayoutAxisAnchors(main_graphDiv.layout); // Use the maingraphDiv its layout to obtain a list of a list of all shared (x)axis names - // in practice, these are the xaxis names that are linked to each other (i.e. the inner list is the + // in practice, these are the xaxis names that are linked to each other (i.e. the inner list is the // xaxis names of the subplot columns) // e.g.: [ [xaxis1, xaxis2], [xaxis3, xaxis4] ] let shared_axes_list = _.chain(main_graphDiv.layout) @@ -127,7 +127,7 @@ window.dash_clientside = Object.assign({}, window.dash_clientside, { }; // iterate over the selected data range - console.log('selected data range', selectedData.range); + // console.log("selected data range", selectedData.range); for (const anchor_key in selectedData.range) { const selected_range = selectedData.range[anchor_key]; // Obtain the anchor key of the orthogonal axis (x or y), based on the coarse graphdiv anchor pairs @@ -157,6 +157,7 @@ window.dash_clientside = Object.assign({}, window.dash_clientside, { Object.keys(relayout).length > 0 ? Plotly.relayout(main_graphDiv, relayout) : null; return mainFigID; }, + main_to_coarse: function (mainRelayout, coarseFigID, mainFigID) { const coarse_graphDiv = getGraphDiv(coarseFigID); const main_graphDiv = getGraphDiv(mainFigID); @@ -184,7 +185,7 @@ window.dash_clientside = Object.assign({}, window.dash_clientside, { if (!currentSelections) { // if current selections is None coarse_xy_axiskeys.forEach((xy_pair) => { - console.log("xy pair", xy_pair); + // console.log("xy pair", xy_pair); const x_axis_key = _.has(layout_axis_anchors, xy_pair.y) ? layout_axis_anchors[xy_pair.y] : "xaxis"; const y_axis_key = _.has(layout_axis_anchors, xy_pair.x) ? layout_axis_anchors[xy_pair.x] : "yaxis"; // console.log('xaxis key', x_axis_key, main_graphDiv.layout[x_axis_key]); @@ -220,11 +221,9 @@ window.dash_clientside = Object.assign({}, window.dash_clientside, { ) { performed_update = true; if ( - // mainRelayout[x_axis_key + ".showspikes"] === false && - // mainRelayout[y_axis_key + ".showspikes"] === false - // NOTE: for some reason, showspikes info is only availabel for the xaxis & yaxis keys - mainRelayout["xaxis.showspikes"] === false && - mainRelayout["yaxis.showspikes"] === false + // NOTE: for some reason, showspikes info is only available for the xaxis & yaxis keys + _.has(mainRelayout, "xaxis.showspikes") && + _.has(mainRelayout, "yaxis.showspikes") ) { // reset axis -> we use the coarse graphDiv layout x_range = coarse_graphDiv.layout[x_axis_key].range;