Merge "Default plots to just a bit bigger"
diff --git a/frc971/analysis/in_process_plotter.h b/frc971/analysis/in_process_plotter.h
index 1c97287..8d4c84c 100644
--- a/frc971/analysis/in_process_plotter.h
+++ b/frc971/analysis/in_process_plotter.h
@@ -40,8 +40,8 @@
// Sets the title for the current set of plots; if you
void Title(std::string_view title);
- void AddFigure(std::string_view title = "", double width = 900,
- double height = 400);
+ void AddFigure(std::string_view title = "", double width = 0,
+ double height = 0);
void AddLine(const std::vector<double> &x, const std::vector<double> &y,
std::string_view label = "", std::string_view line_style = "*-");
void ShareXAxis(bool share) { share_x_axis_ = share; }
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'));
+ }
});
}
diff --git a/frc971/analysis/plot_index.ts b/frc971/analysis/plot_index.ts
index 150407e..27a3ab7 100644
--- a/frc971/analysis/plot_index.ts
+++ b/frc971/analysis/plot_index.ts
@@ -58,6 +58,7 @@
import {plotData} from 'org_frc971/frc971/analysis/plot_data_utils';
const rootDiv = document.createElement('div');
+rootDiv.style.width = '100%';
document.body.appendChild(rootDiv);
const helpDiv = document.createElement('div');
@@ -96,9 +97,10 @@
rootDiv.appendChild(plotSelect);
const plotDiv = document.createElement('div');
-plotDiv.style.top = (plotSelect.getBoundingClientRect().bottom + 10).toString();
+plotDiv.style.marginTop = '10px';
plotDiv.style.left = '0';
plotDiv.style.position = 'absolute';
+plotDiv.style.width = '100%';
rootDiv.appendChild(plotDiv);
// The master list of all the plots that we provide. For a given config, it