Skip to content

Commit

Permalink
✨ fix for #275 (#286)
Browse files Browse the repository at this point in the history
* ✨ fix for #275

* 🧹 review code

---------

Co-authored-by: Jeroen Van Der Donckt <boebievdd@gmail.com>
  • Loading branch information
jonasvdd and jvdd authored Jan 8, 2024
1 parent 2b79498 commit 46e629f
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions plotly_resampler/figure_resampler/assets/coarse_fine.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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]);
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 46e629f

Please sign in to comment.