[CalendarServer-changes] [12803] CalendarServer/trunk/calendarserver/webadmin/work.xhtml
source_changes at macosforge.org
source_changes at macosforge.org
Tue Mar 4 15:51:38 PST 2014
Revision: 12803
http://trac.calendarserver.org//changeset/12803
Author: wsanchez at apple.com
Date: 2014-03-04 15:51:38 -0800 (Tue, 04 Mar 2014)
Log Message:
-----------
Add value labels
Modified Paths:
--------------
CalendarServer/trunk/calendarserver/webadmin/work.xhtml
Modified: CalendarServer/trunk/calendarserver/webadmin/work.xhtml
===================================================================
--- CalendarServer/trunk/calendarserver/webadmin/work.xhtml 2014-03-04 23:14:01 UTC (rev 12802)
+++ CalendarServer/trunk/calendarserver/webadmin/work.xhtml 2014-03-04 23:51:38 UTC (rev 12803)
@@ -123,6 +123,14 @@
.range([xInset, innerWidth])
;
+ function xLocationWithZero(value) {
+ if (value < 1) {
+ return 0;
+ } else {
+ return xLocation(value);
+ }
+ }
+
var yLocation =
d3.scale.ordinal()
.domain(items.map(function(i) { return i.description; }))
@@ -194,10 +202,7 @@
// Update bars selection
bars
.attr("class", "bar")
- .attr("width", function(i) {
- if (i.count < 1) { return 0; }
- return xLocation(i.count);
- })
+ .attr("width", function(i) { return xLocationWithZero(i.count); })
.attr("height", yLocation.rangeBand())
.attr(
"transform",
@@ -207,6 +212,28 @@
// Exit bars selection
bars.exit().remove();
+ // Select labels
+ var labels =
+ inner.selectAll(".label")
+ .data(items);
+
+ // Enter labels selection
+ labels.enter().append("text");
+
+ // Update labels selection
+ labels
+ .attr("class", "label")
+ .attr("x", function(i) { return xLocationWithZero(i.count) + 4; })
+ .attr("y", function(i) { return yLocation(i.description) + (yLocation.rangeBand() / 2); })
+ .attr("dy", "0.32em")
+ .text(function(i) {
+ if (i.count < 1) { return ""; }
+ return i.count;
+ })
+
+ // Exit labels selection
+ labels.exit().remove();
+
// Exit inner selection
inner.exit().remove();
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20140304/7db48f1a/attachment-0001.html>
More information about the calendarserver-changes
mailing list