Add default location handling to AosPlotter

This stacks plots vertically with the default width/height if the user
doesn't specify anything more.

Change-Id: I2f1cc16f64fcf3298c2e506d3dcb1598cb444b0f
diff --git a/aos/network/www/aos_plotter.ts b/aos/network/www/aos_plotter.ts
index a84fc66..4b1d8bf 100644
--- a/aos/network/www/aos_plotter.ts
+++ b/aos/network/www/aos_plotter.ts
@@ -168,6 +168,7 @@
 
   private plots: AosPlot[] = [];
   private messages = new Set<MessageHandler>();
+  private lowestHeight = 0;
   constructor(private readonly connection: Connection) {
     // Set up to redraw at some regular interval. The exact rate is unimportant.
     setInterval(() => {
@@ -199,7 +200,13 @@
   }
   // Add a new figure at the provided position with the provided size within
   // parentElement.
-  addPlot(parentElement: Element, topLeft: number[], size: number[]): AosPlot {
+  addPlot(
+      parentElement: Element, topLeft: number[]|null = null,
+      size: number[] = [AosPlotter.DEFAULT_WIDTH, AosPlotter.DEFAULT_HEIGHT]):
+      AosPlot {
+    if (topLeft === null) {
+      topLeft = [0, this.lowestHeight];
+    }
     const div = document.createElement("div");
     div.style.top = topLeft[1].toString();
     div.style.left = topLeft[0].toString();
@@ -210,6 +217,8 @@
       newPlot.linkXAxis(plot.plot);
     }
     this.plots.push(new AosPlot(this, newPlot));
+    // Height goes up as you go down.
+    this.lowestHeight = Math.max(topLeft[1] + size[1], this.lowestHeight);
     return this.plots[this.plots.length - 1];
   }
   private draw(): void {