Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix maximizing the plot. #422

Merged
merged 1 commit into from
Sep 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 28 additions & 7 deletions histomicsui/web_client/panels/MetadataPlot.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,19 @@ var MetadataPlot = Panel.extend({
this.plottableList = null;
if (this.plottableListPromise) {
this.plottableListPromise.abort();
this.plottableListLoading = false;
}
this.plottableData = null;
if (this.plottableDataPromise) {
this.plottableDataPromise.abort();
this.plottableDataPromise = null;
this.plottableDataLoading = false;
}
const hasPlot = (this.getPlotOptions().filter((v) => v.type === 'number' && v.count).length >= 2);

// redo this when annotations are turned on or off
this.$el.addClass('loading');
this.plottableListLoading = true;
this.plottableListPromise = restRequest({
url: `annotation/item/${this.item.id}/plot/list`,
method: 'POST',
Expand All @@ -102,14 +105,17 @@ var MetadataPlot = Panel.extend({
}
}).done((result) => {
this.plottableList = result;
this.plottableListPromise = null;
this.$el.toggleClass('loading', !!(this.plottableListPromise || this.plottableDataPromise));
this.plottableListLoading = false;
this.$el.toggleClass('loading', !!(this.plottableListLoading || this.plottableDataLoading));
const plotOptions = this.getPlotOptions();
if (plotOptions.filter((v) => v.type === 'number' && v.count).length >= 2) {
if (!hasPlot) {
this.render();
}
}
}).fail((result) => {
this.plottableListLoading = false;
this.$el.toggleClass('loading', !!(this.plottableListLoading || this.plottableDataLoading));
});
},

Expand Down Expand Up @@ -198,18 +204,22 @@ var MetadataPlot = Panel.extend({
}
if (!_.isEqual(this._lastPlottableDataParams, params)) {
this.$el.addClass('loading');
this.plottableDataLoading = true;
this.plottableDataPromise = restRequest({
url: `annotation/item/${this.item.id}/plot/data`,
method: 'POST',
error: null,
data: params
});
this._lastPlottableDataParams = params;
}
this._lastPlottableDataParams = params;
this.plottableDataPromise.done((result) => {
this.plottableData = result;
this.plottableDataPromise = null;
this.$el.toggleClass('loading', !!(this.plottableListPromise || this.plottableDataPromise));
this.plottableDataLoading = false;
this.$el.toggleClass('loading', !!(this.plottableListLoading || this.plottableDataLoading));
}).fail(() => {
this.plottableDataLoading = false;
this.$el.toggleClass('loading', !!(this.plottableListLoading || this.plottableDataLoading));
});
},

Expand Down Expand Up @@ -483,17 +493,28 @@ var MetadataPlot = Panel.extend({
plotlyData.yaxis = {zeroline: false};
plotlyData.scalemode = 'width';
plotlyData.spanmode = 'hard';
plotlyData.showlegend = false;
plotlyData.width = 0.9;
// plotlyData.points = 'outliers';
plotlyData.points = 'all';
plotlyData.pointpos = 0;
plotlyData.jitter = 0;
// plotlyData.side = 'positive';
if (plotData.series.c && plotData.series.c.distinct) {
if (plotData.series.c && plotData.series.c.distinct && plotData.series.s.distinct) {
plotlyData.transforms = [{
type: 'groupby',
groups: plotlyData.x,
styles: Object.keys(plotData.series.c.distinct).map((k, kidx) => ({target: kidx, value: {line: {color: colorBrewerPaired12[kidx]}}}))
styles: Object.keys(plotData.series.s.distinct).map((k, kidx) => {
k = plotData.series.s.distinct[kidx];
for (let didx = 0; didx < plotData.data.length; didx += 1) {
if (plotData.data[didx][plotData.series.s.index] === k) {
const cval = plotData.data[didx][plotData.series.c.index];
const cidx = plotData.series.c.distinct.indexOf(cval);
return {target: kidx, value: {line: {color: colorBrewerPaired12[cidx]}}};
}
}
return {target: kidx, value: {line: {color: '#000000'}}};
})
}];
}
}
Expand Down