Support full width and height plots
When plotting single plots, we want to see all the data! Use a value of
0 to signal that we want 100%. Do this with CSS to keep things
simplest.
Change-Id: I59e5fa22e0fbe28e9616cf12e2afa2385ebde612
Signed-off-by: Austin Schuh <austin.linux@gmail.com>
diff --git a/frc971/analysis/plot_data_utils.ts b/frc971/analysis/plot_data_utils.ts
index a93a2ae..f8debe7 100644
--- a/frc971/analysis/plot_data_utils.ts
+++ b/frc971/analysis/plot_data_utils.ts
@@ -42,8 +42,20 @@
for (let ii = 0; ii < plotFb.figuresLength(); ++ii) {
const figure = plotFb.figures(ii);
const figureDiv = document.createElement('div');
- figureDiv.style.width = figure.position().width().toString() + "px";
- figureDiv.style.height = figure.position().height().toString() + "px";
+ if (figure.position().width() == 0) {
+ figureDiv.style.width = '100%';
+ } else {
+ figureDiv.style.width = figure.position().width().toString() + 'px';
+ }
+ if (figure.position().height() == 0) {
+ // TODO(austin): I don't know the css for 100%, excluding other
+ // stuff in the div... Just go with a little less for now, it's
+ // good enough and quite helpful.
+ figureDiv.style.height = '97%';
+ } else {
+ figureDiv.style.height =
+ figure.position().height().toString() + 'px';
+ }
figureDiv.style.position = 'relative';
div.appendChild(figureDiv);
const plot = new Plot(figureDiv);
@@ -90,5 +102,12 @@
line.setPoints(points);
}
}
+
+ // If this is the first new element (ignoring the placeholder up top),
+ // select it by default.
+ if (plotSelect.length == 2) {
+ plotSelect.value = name;
+ plotSelect.dispatchEvent(new Event('input'));
+ }
});
}