- Re added the original d3.legend.js version (however in a subdirectory) to get things working again.
Project: http://git-wip-us.apache.org/repos/asf/incubator-edgent/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-edgent/commit/20a9eef9 Tree: http://git-wip-us.apache.org/repos/asf/incubator-edgent/tree/20a9eef9 Diff: http://git-wip-us.apache.org/repos/asf/incubator-edgent/diff/20a9eef9 Branch: refs/heads/develop Commit: 20a9eef9d4600c949e978e08ba9d746acf259b5c Parents: 3be8c49 Author: Christofer Dutz <christofer.d...@c-ware.de> Authored: Tue Oct 24 08:47:30 2017 +0200 Committer: Christofer Dutz <christofer.d...@c-ware.de> Committed: Tue Oct 24 08:47:30 2017 +0200 ---------------------------------------------------------------------- console/servlets/pom.xml | 23 ++- .../main/webapp/js/ext/d3.legend/d3.legend.js | 191 +++++++++++++++++++ 2 files changed, 212 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/20a9eef9/console/servlets/pom.xml ---------------------------------------------------------------------- diff --git a/console/servlets/pom.xml b/console/servlets/pom.xml index db097fa..3ceeaec 100644 --- a/console/servlets/pom.xml +++ b/console/servlets/pom.xml @@ -47,6 +47,25 @@ </resources> <plugins> <plugin> + <groupId>org.apache.rat</groupId> + <artifactId>apache-rat-plugin</artifactId> + <executions> + <execution> + <id>license-check</id> + <phase>verify</phase> + <goals> + <goal>check</goal> + </goals> + </execution> + </executions> + <configuration> + <excludes combine.children="append"> + <!-- TODO: Still got one unlicensed file in there ... --> + <exclude>src/main/webapp/js/ext/**</exclude> + </excludes> + </configuration> + </plugin> + <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-remote-resources-plugin</artifactId> <configuration> @@ -112,7 +131,7 @@ </executions> </plugin> <!-- Download JavaScript form GitHub --> - <plugin> + <!--plugin> <groupId>com.googlecode.maven-download-plugin</groupId> <artifactId>download-maven-plugin</artifactId> <version>1.2.1</version> @@ -130,7 +149,7 @@ </configuration> </execution> </executions> - </plugin> + </plugin--> <plugin> <!-- Included to enable "mvn tomcat:run" and have a running console server without using the server jar. http://git-wip-us.apache.org/repos/asf/incubator-edgent/blob/20a9eef9/console/servlets/src/main/webapp/js/ext/d3.legend/d3.legend.js ---------------------------------------------------------------------- diff --git a/console/servlets/src/main/webapp/js/ext/d3.legend/d3.legend.js b/console/servlets/src/main/webapp/js/ext/d3.legend/d3.legend.js new file mode 100644 index 0000000..b225804 --- /dev/null +++ b/console/servlets/src/main/webapp/js/ext/d3.legend/d3.legend.js @@ -0,0 +1,191 @@ +// d3.legend.js +// (C) 2012 ziggy.jonsson....@gmail.com +// MIT licence + +(function() { + d3.legend = function(g, chartSvg, pItems, legendTitle) { + g.each(function() { + var g= d3.select(this); + var items = {}; + var svg = !chartSvg ? d3.select(g.property("nearestViewportElement")) : chartSvg; + var isTupleFlowLegend = false; + var isRect = function(d) { + var k = d.key.toUpperCase(); + return k.startsWith("COUNTEROP") + || k.startsWith("STREAMSCOPE"); + }; + + var legendPadding = g.attr("data-style-padding") || 5, + lTitleItems = g.selectAll(".legend-title-items").data([true]), + lb = g.selectAll(".legend-box").data([true]), + li = g.selectAll(".legend-items").data([true]) + + lTitleItems.enter().append("g").classed("legend-title-items", true) + lb.enter().append("rect").classed("legend-box",true) + liG = li.enter().append("g").classed("legend-items",true) + + if (pItems) { + pItems.forEach(function(p){ + if (p.idx !== undefined) { + items[p.name] = {color: p.fill, idx: p.idx}; + isTupleFlowLegend = true; + } else { + items[p.name] = {color: p.fill}; + isTupleFlowLegend = false; + } + }); + } else { + svg.selectAll("[data-legend]").each(function() { + var self = d3.select(this); + items[self.attr("data-legend")] = { + pos : self.attr("data-legend-pos") || this.getBBox().y, + color : self.attr("data-legend-color") != undefined ? self.attr("data-legend-color") : self.style("fill") != 'none' ? self.style("fill") : self.style("stroke") + } + }); + } + + if (isTupleFlowLegend) + items = d3.entries(items).sort( + function(a,b) { + if (a.value.idx < b.value.idx) { + return -1; + } else if (a.value.idx > b.value.idx) { + return 1; + } else { + return 0; + } + }); + else { + items = d3.entries(items).sort( + function(a,b) { + // rect before circle - graphic positioning code below + var ra = isRect(a); + var rb = isRect(b); + if (ra && !rb) { + return -1; + } else if (!ra && rb) { + return 1; + } + if (a.key < b.key) { + return -1; + } else if (a.key > b.key) { + return 1; + } else { + return 0; + } + }); + } + + li.selectAll("text") + .data(items,function(d) { + return d.key} + ) + .call(function(d) { d.enter().append("text")}) + .call(function(d) { d.exit().remove()}) + .attr("y",function(d,i) { return i+"em"}) + .attr("x","1.5em") + .text(function(d) { + return d.key; + }) + + var legendOpacity = 0.7; + if (legendTitle && legendTitle === "Stream tags") { + legendOpacity = 1.0; + li.selectAll("rect") + .data(items,function(d) { + return d.key} + ) + .call(function(d) { d.enter().append("rect")}) + .call(function(d) { d.exit().remove()}) + .attr("y", function(d,i) { + return i-0.75+ "em"}) + .attr("width", 10) + .attr("height", 8) + .style("fill",function(d) { + return d.value.color === "#c7c7c7" ? "#008080" : d.value.color; + }) + .style("stroke", "none") + .style("fill-opacity", legendOpacity); + } else if (legendTitle && legendTitle === "Oplet kind" || legendTitle === "Tuple count"){ + liG.selectAll("g") + .data(items, function(d) { + return d.key; + }) + .enter() + .append(function(d) { + if (isRect(d)) { + return document.createElementNS(d3.ns.prefix.svg, 'rect'); + } else { + return document.createElementNS(d3.ns.prefix.svg, 'circle'); + } + }); + + // rects before circles + var count = 0; + li.selectAll("rect") + .attr("x", -3) + .attr("y", function(d,i) { + count++; + return i-0.75+ "em"}) + .attr("width", legendTitle === "Oplet kind" ? 8 : 10) + .attr("height", 8) + .style("fill",function(d) { + return d.value.color + }) + .style("stroke", "none") + .style("fill-opacity", legendOpacity); + + li.selectAll("circle") + .attr("cy",function(d,i) { + return (i+count)-0.25+"em"}) + .attr("cx",0) + .attr("r","0.4em") + .style("fill",function(d) { + return d.value.color + }) + .style("fill-opacity", legendOpacity); + + } else { + li.selectAll("circle") + .data(items,function(d) { + return d.key} + ) + .call(function(d) { d.enter().append("circle")}) + .call(function(d) { d.exit().remove()}) + .attr("cy",function(d,i) { return i-0.25+"em"}) + .attr("cx",0) + .attr("r","0.4em") + .style("fill",function(d) { + return d.value.color + }) + .style("fill-opacity", legendOpacity); + } + // Reposition and resize the box + var lbbox = li[0][0].getBBox(); + lb.attr("x",(lbbox.x-legendPadding)) + .attr("y",(lbbox.y-legendPadding)) + .attr("height",(lbbox.height+2*legendPadding)) + .attr("width",((lbbox.width+12) + 2*legendPadding)); + + lTitleItems.attr("x", 0) + .attr("y", (lbbox.y - legendPadding - 15)) + .attr("height",15) + .attr("width",(lbbox.width+2*legendPadding)); + if (legendTitle) { + lTitleItems.selectAll("text") + .data([""],function(d) { + return legendTitle; + }) + .call(function(d) { d.enter().append("text")}) + .call(function(d) { d.exit().remove()}) + .attr("y",function(d,i) { return "-2em"}) + .attr("x",(lbbox.x-legendPadding)) + .text(function(d) { + return legendTitle; + }); + } + + }) + return g + } +})()