This branch refactors the formerly very basic panel geometry logic into something that allows for the dynamic adding and removing of panels with top-level API calls.
Before
Before this branch panels behaved more or less like this:
Panels could be added only before the plot was initialized
Panels could not be removed
Panels could be absolutely or relatively positioned anywhere within the bounds of the plot's dimensions
Panels could overlap (had no logic to prevent overlapping)
All logic related to dimensions tended to favor the plot's dimensions over the aggregate dimensions of the panels. That is, if the two were not in agreement the most common behavior would be to scale the panels to fit into the dimensions hard-set on the plot, rather than allowing the plot to expand.
After
As of this branch panel geometry logic has been refactored to meet a more specific use case. In places it is more restrictive and in others it's more liberal. Now panels can:
Panels can be added at any time after plot initialization (and will be automatically initialized to load and display data) with an ID and a layout
Panels can be removed at any time by ID
Panel layouts can be defined with a variety of different dimension values, including discrete dimensions, discrete minimum dimensions, proportional dimensions, discrete origin coordinates, and/or proportional origin coordinates. Any combination of these can be provided and will be brought into agreement favoring proportional values over discrete values. All of these values can also be missing and default behavior is defined to add panels at full width with a height comparable to existing panels.
Panels are now restricted to a vertical orientation only. This was a necessary step to add sane panel overlap prevention logic when considering the ability to arbitrarily add and remove panels. In the future we may want to support fully two-dimensional panel orientations, but this is not an easy problem and not something with a well defined use case as of now.
Previously proportional values were ignored when determining plot minimum dimensions by aggregating panel minimum dimensions. Now all values are taken into account and plot minimum dimensions are automatically updated as panel layouts are added/removed/changed.
Demo
To see the net result of this branch in action do the following:
Check out the branch
Load up plot_builder.html
In the console run addAnalysis(). See plotBuilder.html page source for details. In a nutshell, this function does the following:
Generate a randomized name space name
Add new data sources for association and LD using the name space ID (sticking with analysis 3 for association as other analyses do not appear to return results right now)
Define a layout that describes a standard-looking Positions panel using the new data sources
Add the new panel to the plot, expanding the plot vertically to make room
To remove any panel, in the console run removePanel(id) where id is the ID of the panel (the keys in plot.panels are the panel IDs).
This is a big and necessary step toward supporting multiple phenotypes in the Broad Portal, LocusZoom's current primary consumer. The work done on this branch, however, is a big benefit to all future LocusZoom implementations that will have cause to dynamically add and remove panels based on user input.
Testing
There was a significant amount of test refactoring and expansion done on this branch as some previously tested-for behavior changed. In general the tests in test/Instance.js tend to cover many of the changed and new behaviors, including the critical addPanel() and removePanel() Instance-level methods.
Marked as active development while ironing out any lingering bugs. Scope should probably be capped at this point and we can discuss where best to go from here.
What
This branch refactors the formerly very basic panel geometry logic into something that allows for the dynamic adding and removing of panels with top-level API calls.
Before
Before this branch panels behaved more or less like this:
After
As of this branch panel geometry logic has been refactored to meet a more specific use case. In places it is more restrictive and in others it's more liberal. Now panels can:
Demo
To see the net result of this branch in action do the following:
plot_builder.html
addAnalysis()
. SeeplotBuilder.html
page source for details. In a nutshell, this function does the following:3
for association as other analyses do not appear to return results right now)removePanel(id)
whereid
is the ID of the panel (the keys inplot.panels
are the panel IDs).This is a big and necessary step toward supporting multiple phenotypes in the Broad Portal, LocusZoom's current primary consumer. The work done on this branch, however, is a big benefit to all future LocusZoom implementations that will have cause to dynamically add and remove panels based on user input.
Testing
There was a significant amount of test refactoring and expansion done on this branch as some previously tested-for behavior changed. In general the tests in
test/Instance.js
tend to cover many of the changed and new behaviors, including the criticaladdPanel()
andremovePanel()
Instance-level methods.Marked as active development while ironing out any lingering bugs. Scope should probably be capped at this point and we can discuss where best to go from here.