[CalendarServer-changes] [12759] CalendarServer/trunk/calendarserver/webadmin/work.xhtml

source_changes at macosforge.org source_changes at macosforge.org
Wed Feb 26 14:30:18 PST 2014


Revision: 12759
          http://trac.calendarserver.org//changeset/12759
Author:   wsanchez at apple.com
Date:     2014-02-26 14:30:18 -0800 (Wed, 26 Feb 2014)
Log Message:
-----------
Updates now work.
Thanks to http://stackoverflow.com/questions/22052694/

Modified Paths:
--------------
    CalendarServer/trunk/calendarserver/webadmin/work.xhtml

Modified: CalendarServer/trunk/calendarserver/webadmin/work.xhtml
===================================================================
--- CalendarServer/trunk/calendarserver/webadmin/work.xhtml	2014-02-26 22:28:47 UTC (rev 12758)
+++ CalendarServer/trunk/calendarserver/webadmin/work.xhtml	2014-02-26 22:30:18 UTC (rev 12759)
@@ -26,9 +26,9 @@
     <script src="http://d3js.org/d3.v3.min.js"></script>
     <script>
 
-      function init() {
+      function drawChart(data) {
 
-        var data = [4, 8, 15, 16, 23, 42];
+        // var data = [4, 8, 15, 16, 23, 42];
 
         var width = 600;
         var barHeight = 20;
@@ -43,29 +43,43 @@
             .attr("width", width)
             .attr("height", barHeight * data.length);
 
-        var bar =
+        var bars =
           chart.selectAll("g")
             .data(data)
-          .enter().append("g")
-            .attr(
-              "transform",
-              function(d, i) { return "translate(0," + i * barHeight + ")"; }
-            );
 
-        bar.append("rect")
+        // Enter selection
+        bars.enter().append("g")
+
+        // Update selection
+        bars.attr(
+          "transform",
+          function(d, i) { return "translate(0," + i * barHeight + ")"; }
+        );
+
+        bars.append("rect")
           .attr("width", scaledWidth)
           .attr("height", barHeight - 1);
 
-        bar.append("text")
+        bars.append("text")
           .attr("x", function(d) { return scaledWidth(d) - 3; })
           .attr("y", barHeight / 2)
           .attr("dy", "0.35em")
           .text(function(d) { return d; });
 
+        // Exit selection
+        bars.exit().remove()
       }
 
-      window.onload = init;
+      function update() {
+        drawChart([4, 8, 15, 16, 23, 42]);
+      }
 
+      function initChart() {
+        drawChart([0, 0, 0, 0, 0, 0]);
+      }
+
+      window.onload = initChart;
+
     </script>
 
   </head>
@@ -75,8 +89,9 @@
     <h1><t:slot name="title" /></h1>
 
     <svg id="work_queues_chart" />
+    <br />
+    <button onclick="update()">Update</button>
 
   </body>
 
-
 </html>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20140226/4e1f1436/attachment-0001.html>


More information about the calendarserver-changes mailing list