This branch was built to address the idea put forth in #46 - a tool to be able to see an editable layout and plot side by side as an interactive Layout/Plot builder.
In building this tool a few latent bugs in initialization, layout parsing, and state I/O quickly surfaced. This led to an idea that's been brought up before coming to pass - merging the layout and state.
Unified Layout
Wherever there once was a layout and/or a state, now there's just a layout. State is still there. It's just inside layout, and it's still called state.
From this the following changes fall out:
Initialization functions like LocusZoom.populate()still take state as a fourth argument for backward compatibility. Now, however, populate()'s logic merges any state passed in with state defined in the passed in layout and state detected from the data-region parameter on the container into a single state object in the layout.
The nested structure of panels and data layers is no longer repeated in both layout and state.
A new state syntax has been developed for the states of panels and datalayers to allow for tracking their state in a deterministic way without building a deeply nested JSON object (the thinking here is to make it easy for implementers to pre-load state).
Plot Builder
A new demo appears in this branch - plot_builder.html. This is a simple tool that shows a plot next to a textarea filled with the current layout with simple UI and hooks to keep them in sync with one another as either is changed.
onUpdate()
To make the tool function the plot builder needed a means to know when the layout has been updated (e.g. the plot resizing, any data query, selecting elements in the plot, etc.) so this branch adds support for a user-defined onUpdate() event handler that can be added to a plot. It is automatically triggered whenever a plot's layout is effectively changed.
Status
This branch is now Development Complete.
The attention paid to backward compatibility should mean that existing LocusZoom implementations are not disrupted, unless those implementations are directly passing state objects to pre-select points on data layers. That syntax has been simplified in this branch, so that change will need to be communicated.
What
This branch was built to address the idea put forth in #46 - a tool to be able to see an editable layout and plot side by side as an interactive Layout/Plot builder.
In building this tool a few latent bugs in initialization, layout parsing, and state I/O quickly surfaced. This led to an idea that's been brought up before coming to pass - merging the layout and state.
Unified Layout
Wherever there once was a layout and/or a state, now there's just a layout. State is still there. It's just inside layout, and it's still called
state
.From this the following changes fall out:
LocusZoom.populate()
still takestate
as a fourth argument for backward compatibility. Now, however,populate()
's logic merges any state passed in with state defined in the passed in layout and state detected from thedata-region
parameter on the container into a singlestate
object in the layout.Plot Builder
A new demo appears in this branch -
plot_builder.html
. This is a simple tool that shows a plot next to a textarea filled with the current layout with simple UI and hooks to keep them in sync with one another as either is changed.onUpdate()
To make the tool function the plot builder needed a means to know when the layout has been updated (e.g. the plot resizing, any data query, selecting elements in the plot, etc.) so this branch adds support for a user-defined
onUpdate()
event handler that can be added to a plot. It is automatically triggered whenever a plot's layout is effectively changed.Status
This branch is now Development Complete.
The attention paid to backward compatibility should mean that existing LocusZoom implementations are not disrupted, unless those implementations are directly passing state objects to pre-select points on data layers. That syntax has been simplified in this branch, so that change will need to be communicated.