BLUR-269: Swapped out Chart.js with flotr2.js

Project: http://git-wip-us.apache.org/repos/asf/incubator-blur/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-blur/commit/fe4f054b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-blur/tree/fe4f054b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-blur/diff/fe4f054b

Branch: refs/heads/blur-console-v2
Commit: fe4f054b9d482c4e470588fd8ce21fae0550af6e
Parents: 70fced0
Author: Chris Rohr <[email protected]>
Authored: Tue Oct 15 23:31:09 2013 -0400
Committer: Chris Rohr <[email protected]>
Committed: Tue Oct 15 23:31:09 2013 -0400

----------------------------------------------------------------------
 contrib/blur-console/pom.xml                    |  11 ++
 .../blur/console/servlets/DashboardServlet.java |   9 +-
 .../org/apache/blur/console/util/NodeUtil.java  | 126 +++++++------
 .../org/apache/blur/console/util/TableUtil.java |  78 ++++----
 .../apache/blur/console/webapp/css/console.css  |   6 +
 .../apache/blur/console/webapp/js/directives.js | 187 ++++++++++---------
 .../apache/blur/console/webapp/js/factories.js  |  17 ++
 .../console/webapp/partials/dashboard.tpl.html  |  34 +++-
 pom.xml                                         |   2 +-
 9 files changed, 278 insertions(+), 192 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/fe4f054b/contrib/blur-console/pom.xml
----------------------------------------------------------------------
diff --git a/contrib/blur-console/pom.xml b/contrib/blur-console/pom.xml
index 7c72537..521b3e3 100644
--- a/contrib/blur-console/pom.xml
+++ b/contrib/blur-console/pom.xml
@@ -45,6 +45,17 @@ under the License.
                        <artifactId>blur-core</artifactId>
                        <version>${project.version}</version>
                </dependency>
+               <dependency>
+            <groupId>org.codehaus.jackson</groupId>
+            <artifactId>jackson-mapper-asl</artifactId>
+            <version>1.8.1</version>
+         </dependency>
+         <dependency>
+            <groupId>org.codehaus.jackson</groupId>
+            <artifactId>jackson-core-asl</artifactId>
+            <version>1.8.1</version>
+         </dependency>
+       
     </dependencies>
 
     <build>

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/fe4f054b/contrib/blur-console/src/main/java/org/apache/blur/console/servlets/DashboardServlet.java
----------------------------------------------------------------------
diff --git 
a/contrib/blur-console/src/main/java/org/apache/blur/console/servlets/DashboardServlet.java
 
b/contrib/blur-console/src/main/java/org/apache/blur/console/servlets/DashboardServlet.java
index 9e4001c..cad5ab0 100644
--- 
a/contrib/blur-console/src/main/java/org/apache/blur/console/servlets/DashboardServlet.java
+++ 
b/contrib/blur-console/src/main/java/org/apache/blur/console/servlets/DashboardServlet.java
@@ -18,6 +18,8 @@ package org.apache.blur.console.servlets;
  */
 
 import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
 
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServlet;
@@ -28,6 +30,7 @@ import org.apache.blur.console.util.HttpUtil;
 import org.apache.blur.console.util.NodeUtil;
 import org.apache.blur.console.util.TableUtil;
 import org.apache.commons.io.IOUtils;
+import org.codehaus.jackson.map.ObjectMapper;
 import org.json.JSONException;
 import org.json.JSONObject;
 
@@ -58,7 +61,7 @@ public class DashboardServlet extends HttpServlet {
        }
 
        private void sendNodeStatus(HttpServletResponse response) throws 
IOException {
-               JSONObject nodeData = new JSONObject();
+               Map<String, Object> nodeData = new HashMap<String, Object>();
 
                try {
                        nodeData.put("zookeepers", 
NodeUtil.getZookeeperStatus());
@@ -69,11 +72,11 @@ public class DashboardServlet extends HttpServlet {
                        return;
                }
 
-               HttpUtil.sendResponse(response, nodeData.toString(), 
HttpUtil.JSON);
+               HttpUtil.sendResponse(response, new 
ObjectMapper().writeValueAsString(nodeData), HttpUtil.JSON);
        }
        
        private void sendTableStatus(HttpServletResponse response) throws 
IOException {
-               JSONObject tableData = new JSONObject();
+               String tableData = "{}";
 
                try {
                        tableData = TableUtil.getTableStatus();

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/fe4f054b/contrib/blur-console/src/main/java/org/apache/blur/console/util/NodeUtil.java
----------------------------------------------------------------------
diff --git 
a/contrib/blur-console/src/main/java/org/apache/blur/console/util/NodeUtil.java 
b/contrib/blur-console/src/main/java/org/apache/blur/console/util/NodeUtil.java
index 6c6d0cc..2029cc3 100644
--- 
a/contrib/blur-console/src/main/java/org/apache/blur/console/util/NodeUtil.java
+++ 
b/contrib/blur-console/src/main/java/org/apache/blur/console/util/NodeUtil.java
@@ -25,10 +25,11 @@ import java.net.Socket;
 import java.net.URI;
 import java.nio.ByteBuffer;
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.Collection;
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
 
 import org.apache.blur.manager.clusterstatus.ZookeeperClusterStatus;
@@ -36,19 +37,21 @@ import org.apache.blur.thrift.BlurClient;
 import org.apache.blur.thrift.generated.Blur.Iface;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang.StringUtils;
-import org.json.JSONArray;
 import org.json.JSONException;
-import org.json.JSONObject;
 
 public class NodeUtil {
        @SuppressWarnings("unchecked")
-       public static JSONObject getControllerStatus() throws JSONException, 
IOException {
+       public static Map<String, Object> getControllerStatus() throws 
JSONException, IOException {
                ZookeeperClusterStatus zk = new 
ZookeeperClusterStatus(Config.getBlurConfig().get("blur.zookeeper.connection"),
                                Config.getBlurConfig());
 
                // TODO: Fix with another call, this will return online only 
every time
-               List<String> allControllers = zk.getControllerServerList();
-               zk.close();
+               List<String> allControllers = new ArrayList<String>();
+               try {
+                       allControllers = zk.getControllerServerList();
+               } finally {
+                       zk.close();
+               }
 
                Iface client = 
BlurClient.getClient(StringUtils.join(allControllers, ","));
                List<String> controllersFromBlur = new ArrayList<String>();
@@ -60,70 +63,75 @@ public class NodeUtil {
                Collection<String> onlineControllers = 
CollectionUtils.intersection(allControllers, controllersFromBlur);
                Collection<String> offlineControllers = 
CollectionUtils.subtract(allControllers, controllersFromBlur);
 
-               JSONObject data = new JSONObject();
+               Map<String, Object> data = new HashMap<String, Object>();
 
-               data.put("online", new JSONArray(onlineControllers));
-               data.put("offline", new JSONArray(offlineControllers));
+               data.put("online", onlineControllers);
+               data.put("offline", offlineControllers);
 
-               JSONArray chartData = new JSONArray();
+               List<Map<String, Object>> chartData = new 
ArrayList<Map<String,Object>>();
 
-               JSONObject online = new JSONObject();
-               online.put("data", new JSONArray(Arrays.asList(new 
int[]{0,onlineControllers.size()})));
+               Map<String, Object> online = new HashMap<String, Object>();
+               online.put("data", new int[][]{{0,onlineControllers.size()}});
                online.put("label", "Online");
                online.put("color", "#7DC77D");
 
-               JSONObject offline = new JSONObject();
-               offline.put("data", new JSONArray(Arrays.asList(new 
int[]{0,offlineControllers.size()})));
+               Map<String, Object> offline = new HashMap<String, Object>();
+               offline.put("data", new int[][]{{0,offlineControllers.size()}});
                offline.put("label", "Offline");
                offline.put("color", "#FF1919");
 
-               chartData.put(online);
-               chartData.put(offline);
+               chartData.add(online);
+               chartData.add(offline);
 
                data.put("chart", chartData);
                
                return data;
        }
 
-       public static JSONArray getClusterStatus() throws IOException, 
JSONException {
+       public static List<Map<String, Object>> getClusterStatus() throws 
IOException, JSONException {
                ZookeeperClusterStatus zk = new 
ZookeeperClusterStatus(Config.getBlurConfig().get("blur.zookeeper.connection"),
                                Config.getBlurConfig());
 
-               List<String> clusters = zk.getClusterList(false);
-               JSONArray data = new JSONArray();
-
-               for (String cluster : clusters) {
-                       JSONObject clusterObj = new JSONObject();
-                       clusterObj.put("name", cluster);
-
-                       List<String> offlineShardServers = 
zk.getOfflineShardServers(false, cluster);
-                       List<String> onlineShardServers = 
zk.getOnlineShardServers(false, cluster);
-
-                       clusterObj.put("online", new 
JSONArray(onlineShardServers));
-                       clusterObj.put("offline", new 
JSONArray(offlineShardServers));
-
-                       JSONArray clusterData = new JSONArray();
-
-                       JSONObject online = new JSONObject();
-                       online.put("value", onlineShardServers.size());
-                       online.put("color", "#7DC77D");
-
-                       JSONObject offline = new JSONObject();
-                       offline.put("value", offlineShardServers.size());
-                       offline.put("color", "#FF1919");
-
-                       clusterData.put(online);
-                       clusterData.put(offline);
-                       clusterObj.put("chart", clusterData);
-
-                       data.put(clusterObj);
+               List<Map<String, Object>> data = new 
ArrayList<Map<String,Object>>();
+               try {
+                       List<String> clusters = zk.getClusterList(false);
+       
+                       for (String cluster : clusters) {
+                               Map<String, Object> clusterObj = new 
HashMap<String, Object>();
+                               clusterObj.put("name", cluster);
+       
+                               List<String> offlineShardServers = 
zk.getOfflineShardServers(false, cluster);
+                               List<String> onlineShardServers = 
zk.getOnlineShardServers(false, cluster);
+       
+                               clusterObj.put("online", onlineShardServers);
+                               clusterObj.put("offline", offlineShardServers);
+       
+                               List<Map<String, Object>> clusterData = new 
ArrayList<Map<String,Object>>();
+                               
+                               Map<String, Object> online = new 
HashMap<String, Object>();
+                               online.put("data", new 
int[][]{{0,onlineShardServers.size()}});
+                               online.put("label", "Online");
+                               online.put("color", "#7DC77D");
+       
+                               Map<String, Object> offline = new 
HashMap<String, Object>();
+                               offline.put("data", new 
int[][]{{0,offlineShardServers.size()}});
+                               offline.put("label", "Offline");
+                               offline.put("color", "#FF1919");
+       
+                               clusterData.add(online);
+                               clusterData.add(offline);
+                               clusterObj.put("chart", clusterData);
+       
+                               data.add(clusterObj);
+                       }
+               } finally {
+                       zk.close();
                }
-               zk.close();
 
                return data;
        }
 
-       public static JSONObject getZookeeperStatus() throws IOException, 
JSONException {
+       public static Map<String, Object> getZookeeperStatus() throws 
IOException, JSONException {
                String[] connections = 
Config.getBlurConfig().get("blur.zookeeper.connection").split(",");
                Set<String> onlineZookeepers = new HashSet<String>();
                Set<String> offlineZookeepers = new HashSet<String>();
@@ -165,23 +173,25 @@ public class NodeUtil {
                        }
                }
                
-               JSONObject data = new JSONObject();
+               Map<String, Object> data = new HashMap<String, Object>();
                
-               data.put("online", new JSONArray(onlineZookeepers));
-               data.put("offline", new JSONArray(offlineZookeepers));
+               data.put("online", onlineZookeepers);
+               data.put("offline", offlineZookeepers);
                
-               JSONArray chartData = new JSONArray();
-
-               JSONObject online = new JSONObject();
-               online.put("value", onlineZookeepers.size());
+               List<Map<String, Object>> chartData = new 
ArrayList<Map<String,Object>>();
+               
+               Map<String, Object> online = new HashMap<String, Object>();
+               online.put("data", new int[][]{{0,onlineZookeepers.size()}});
+               online.put("label", "Online");
                online.put("color", "#7DC77D");
 
-               JSONObject offline = new JSONObject();
-               offline.put("value", offlineZookeepers.size());
+               Map<String, Object> offline = new HashMap<String, Object>();
+               offline.put("data", new int[][]{{0,offlineZookeepers.size()}});
+               offline.put("label", "Offline");
                offline.put("color", "#FF1919");
 
-               chartData.put(online);
-               chartData.put(offline);
+               chartData.add(online);
+               chartData.add(offline);
 
                data.put("chart", chartData);
                

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/fe4f054b/contrib/blur-console/src/main/java/org/apache/blur/console/util/TableUtil.java
----------------------------------------------------------------------
diff --git 
a/contrib/blur-console/src/main/java/org/apache/blur/console/util/TableUtil.java
 
b/contrib/blur-console/src/main/java/org/apache/blur/console/util/TableUtil.java
index ab29f59..7cc05bb 100644
--- 
a/contrib/blur-console/src/main/java/org/apache/blur/console/util/TableUtil.java
+++ 
b/contrib/blur-console/src/main/java/org/apache/blur/console/util/TableUtil.java
@@ -19,79 +19,89 @@ package org.apache.blur.console.util;
 
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 import org.apache.blur.thirdparty.thrift_0_9_0.TException;
 import org.apache.blur.thrift.BlurClient;
 import org.apache.blur.thrift.generated.Blur.Iface;
 import org.apache.blur.thrift.generated.BlurException;
-import org.json.JSONArray;
+import org.codehaus.jackson.map.ObjectMapper;
 import org.json.JSONException;
-import org.json.JSONObject;
 
 public class TableUtil {
-       public static JSONObject getTableStatus() throws IOException, 
BlurException, TException, JSONException {
-               //TODO: Change this to a stacked bar chart when chart.js 
supports it
-               
+       public static String getTableStatus() throws IOException, 
BlurException, TException, JSONException {
                Iface client = 
BlurClient.getClient(Config.getConnectionString());
                
                List<String> clusters = client.shardClusterList();
+
+               Map<String, Object> data = new HashMap<String, Object>();
+               List<Map<String, Object>> clusterInfo = new 
ArrayList<Map<String,Object>>();
                
-               JSONObject data = new JSONObject();
-               JSONArray clusterInfo = new JSONArray();
+               List<List<Object>> enabledPoints = new 
ArrayList<List<Object>>();
+               List<List<Object>> disabledPoints = new 
ArrayList<List<Object>>();
                
-               List<Integer> enabledCounts = new ArrayList<Integer>();
-               List<Integer> disabledCounts = new ArrayList<Integer>();
-
+               int clusterCount = 0;
                for (String cluster : clusters) {
-                       JSONObject clusterObj = new JSONObject();
+                       Map<String, Object> clusterObj = new HashMap<String, 
Object>();
                        clusterObj.put("name", cluster);
 
                        List<String> tables = 
client.tableListByCluster(cluster);
                        
                        List<String> enabledTables = new ArrayList<String>();
                        List<String> disabledTables = new ArrayList<String>();
+                       int enabledCount = 0;
+                       int disabledCount = 0;
                        
                        for (String table : tables) {
                                boolean enabled = 
client.describe(table).isEnabled();
                                
                                if (enabled) {
                                        enabledTables.add(table);
+                                       enabledCount++;
                                } else {
                                        disabledTables.add(table);
+                                       disabledCount++;
                                }
                        }
                        
-                       clusterObj.put("enabled", new JSONArray(enabledTables));
-                       clusterObj.put("disabled", new 
JSONArray(disabledTables));
+                       clusterObj.put("enabled", enabledTables);
+                       clusterObj.put("disabled", disabledTables);
+                       
+                       List<Object> e = new ArrayList<Object>();
+                       e.add(clusterCount);
+                       e.add(enabledCount);
+                       
+                       List<Object> d = new ArrayList<Object>();
+                       d.add(clusterCount);
+                       d.add(disabledCount);
                        
-                       enabledCounts.add(enabledTables.size());
-                       disabledCounts.add(disabledTables.size());
+                       enabledPoints.add(e);
+                       disabledPoints.add(d);
 
-                       clusterInfo.put(clusterObj);
+                       clusterInfo.add(clusterObj);
+                       clusterCount++;
                }
                
-               JSONObject clusterData = new JSONObject();
+               List<Map<String, Object>> datasets = new 
ArrayList<Map<String,Object>>();
                
-               clusterData.put("labels", new JSONArray(clusters));
+               Map<String, Object> eData = new HashMap<String, Object>();
+               eData.put("data", enabledPoints);
+               eData.put("label", "Enabled");
+               eData.put("color", "#7DC77D");
+               datasets.add(eData);
                
-               JSONArray datasets = new JSONArray();
-
-               JSONObject enabled = new JSONObject();
-               enabled.put("data", new JSONArray(enabledCounts));
-               enabled.put("fillColor", "#7DC77D");
-
-               JSONObject disabled = new JSONObject();
-               disabled.put("data", new JSONArray(disabledCounts));
-               disabled.put("fillColor", "#FF1919");
-
-               datasets.put(enabled);
-               datasets.put(disabled);
-               clusterData.put("datasets", datasets);
+               Map<String, Object> dData = new HashMap<String, Object>();
+               dData.put("data", disabledPoints);
+               dData.put("label", "Disabled");
+               dData.put("color", "#CCCCCC");
+               datasets.add(dData);
                
                data.put("tables", clusterInfo);
-               data.put("chart", clusterData);
-
-               return data;
+               data.put("chart", datasets);
+               data.put("clusters", clusters);
+               
+               return new ObjectMapper().writeValueAsString(data);
        }
 }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/fe4f054b/contrib/blur-console/src/main/resources/org/apache/blur/console/webapp/css/console.css
----------------------------------------------------------------------
diff --git 
a/contrib/blur-console/src/main/resources/org/apache/blur/console/webapp/css/console.css
 
b/contrib/blur-console/src/main/resources/org/apache/blur/console/webapp/css/console.css
index b7fc785..25e3dba 100644
--- 
a/contrib/blur-console/src/main/resources/org/apache/blur/console/webapp/css/console.css
+++ 
b/contrib/blur-console/src/main/resources/org/apache/blur/console/webapp/css/console.css
@@ -62,6 +62,12 @@ body { padding-top: 70px; }
     *border-right-color: #fff;
 }
 
+.tab-content .row {
+    margin-right: 0px;
+    margin-left: 0px;
+    margin-bottom: 5px;
+}
+
 .center {
     text-align: center;
 }

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/fe4f054b/contrib/blur-console/src/main/resources/org/apache/blur/console/webapp/js/directives.js
----------------------------------------------------------------------
diff --git 
a/contrib/blur-console/src/main/resources/org/apache/blur/console/webapp/js/directives.js
 
b/contrib/blur-console/src/main/resources/org/apache/blur/console/webapp/js/directives.js
index 3ed1a87..dba4d40 100644
--- 
a/contrib/blur-console/src/main/resources/org/apache/blur/console/webapp/js/directives.js
+++ 
b/contrib/blur-console/src/main/resources/org/apache/blur/console/webapp/js/directives.js
@@ -1,8 +1,26 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ 
 blurApp.directive('piechart', ['flotrService', '$window', 
function(flotrService, $window){
        return {
                restrict: 'EA',
                scope: {
-                       chartdata: '='
+                       chartdata: '=',
+                       title: '@'
                },
                link: function(scope, element, attrs) {
                        flotrService.flotr().then(function(Flotr) {
@@ -24,25 +42,31 @@ blurApp.directive('piechart', ['flotrService', '$window', 
function(flotrService,
                                        element.children().remove();
                                        if (!data) return;
 
-                                       var width = 
element.parent()[0].clientWidth - 10,
+                                       var width = 
element.parent()[0].clientWidth - 150,
                                                height = width;
 
                                        element.css('height', height);
                                        element.css('width', width);
+                                       element.css('min-height', 200);
+                                       element.css('min-weight', 200);
+                                       element.css('max-height', 500);
+                                       element.css('max-width', 500);
 
                                        Flotr.draw(element[0], data, {
                                                HtmlText: false,
+                                               title: scope.title,
                                                grid: {
                                                        verticalLines: false,
-                                                       horizontalLines: false
+                                                       horizontalLines: false,
+                                                       outlineWidth: 0
                                                },
                                                xaxis: { showLabels: false },
                                                yaxis: { showLabels: false },
                                                pie: {
-                                                       show: true
-                                               },
-                                               legend: {
-                                                       show: false
+                                                       show: true,
+                                                       labelFormatter: 
function(pie, slice) {
+                                                               return slice;
+                                                       }
                                                }
                                        });
                                }
@@ -51,90 +75,77 @@ blurApp.directive('piechart', ['flotrService', '$window', 
function(flotrService,
        };
 }]);
 
-// blurApp.directive('doughnutchart', ['d3Service', '$window', 
function(d3Service, $window) {
-//     return {
-//             restrict: 'EA',
-//             scope: {
-//                     chartdata: '='
-//             },
-//             link: function (scope, element, attrs) {
-//                     d3Service.d3().then(function(d3) {
-//                             var margin = parseInt(attrs.margin) || 20,
-//                                     ringHeight = parseInt(attrs.ringHeight) 
|| 300,
-//                                     ringRadius = parseInt(attrs.ringRadius) 
|| 5;
-
-//                             var svg = 
d3.select(element[0]).append("svg:svg");
-
-//                             window.onresize = function() {
-//                                     scope.$apply();
-//                             };
-
-//                             scope.$watch(function() {
-//                                     return 
angular.element($window)[0].innerWidth;
-//                             }, function() {
-//                                     scope.render(scope.chartdata);
-//                             });
-
-//                             scope.$watch('data', function(newVals, oldVals) 
{
-//                                     return scope.render(newVals);
-//                             }, true);
-
-//                             scope.render = function(data) {
-//                                     svg.selectAll('*').remove();
-
-//                                     if (!data) return;
-
-//                                     var w = 400,
-//                                             h = 400,
-//                                             r = Math.min(w, h) / 2,
-//                                             labelr = r + 30,
-//                                             color = d3.scale.category20,
-//                                             donut = d3.layout.pie(),
-//                                             arc = 
d3.svg.arc().innerRadius(r * .6).outerRadius(r);
-
-//                                     var vis = svg.data([data])
-//                                                             .attr('width', 
w + 150)
-//                                                             .attr('height', 
h);
-
-//                                     var arcs = vis.selectAll('g.arc')
-//                                                                     
.data(donut.value(function(d){ return d.val }))
-//                                                                     
.enter().append('svg:g')
-//                                                                     
.attr('class', 'arc')
-//                                                                     
.attr('transform', 'translate(' + (r + 30) + ',' + r + ')');
+blurApp.directive('stackedbarchart', ['flotrService', '$window', 
function(flotrService, $window){
+       return {
+               restrict: 'EA',
+               scope: {
+                       chartdata: '=',
+                       title: '@',
+                       xlabels: '='
+               },
+               link: function(scope, element, attrs) {
+                       flotrService.flotr().then(function(Flotr) {
+                               window.onresize = function() {
+                                       scope.$apply();
+                               };
 
-//                                     arcs.append('svg:path')
-//                                             .attr('fill', function(d, i){ 
return color(i); })
-//                                             .attr('d', arc);
+                               scope.$watch(function() {
+                                       return 
angular.element($window)[0].innerWidth;
+                               }, function() {
+                                       scope.render(scope.chartdata);
+                               });
 
-//                                     arcs.append('svg:text')
-//                                             .attr('transform', function(d){
-//                                                     var c = arc.centroid(d),
-//                                                             x = c[0],
-//                                                             y = c[1],
-//                                                             h = 
Math.sqrt(x*x + y*y);
-//                                                     return "translate(" + 
(x/h * labelr) + ',' + (y/h * labelr) + ")";
-//                                             })
-//                                             .attr('dy', '.35em')
-//                                             .attr('text-anchor', 
function(d){
-//                                                     return (d.endAngle + 
d.startAngle)/2 > Math.PI ? "end" : "start";
-//                                             })
-//                                             .text(function(d, i){ return 
d.value.toFixed(2); });
+                               scope.$watch('chartdata', function(newVals, 
oldVals) {
+                                       return scope.render(newVals);
+                               }, true);
 
-//                                     // var width = 
d3.select(element[0]).node().offsetWidth - margin,
-//                                     //      height = ringHeight,
-//                                     //      color = d3.scale.category20();
+                               scope.render = function(data) {
+                                       element.children().remove();
+                                       if (!data) return;
 
-//                                     // var pie = d3.layout.pie().sort(null);
-//                                     // var arc = 
d3.svg.arc().innerRadius(ringRadius - 100).outerRadius(ringRadius - 50);
+                                       var width = 
element.parent()[0].clientWidth - 150,
+                                               height = width;
 
-//                                     // svg.attr('width', width);
-//                                     // svg.attr('height', height);
-//                                     // svg.append('g');
-//                                     // svg.attr('transform', 'translate(' + 
width / 2 + ',' + height /2 + ')');
+                                       element.css('height', height);
+                                       element.css('width', width);
+                                       element.css('min-height', 200);
+                                       element.css('min-weight', 200);
+                                       element.css('max-height', 500);
+                                       element.css('max-width', 500);
 
-//                                     // var path = 
svg.selectAll('path').data(pie(scope.chartdata)).enter().append('path').attr('fill',
 function(d, i) { return color(i); }).attr('d', arc);
-//                             }
-//                     });
-//             }
-//     }
-// }]);
\ No newline at end of file
+                                       Flotr.draw(element[0], data, {
+                                               title: scope.title,
+                                               bars: {
+                                                       show: true,
+                                                       stacked: true,
+                                                       barWidth : 0.6,
+                                               lineWidth : 1,
+                                               shadowSize : 0
+                                               },
+                                               grid: {
+                                                       verticalLines: false,
+                                                       grid: null
+                                               },
+                                               yaxis: {
+                                                       min: 0,
+                                                       tickDecimals: 0
+                                               },
+                                               xaxis: {
+                                                       showLabels: false
+                                               },
+                                               mouse: {
+                                                       track: true,
+                                                       relative: true,
+                                                       trackFormatter: 
function(obj) {
+                                                               if 
(scope.xlabels) {
+                                                                       return 
scope.xlabels[obj.x] || obj.x;
+                                                               }
+                                                               return obj.x;
+                                                       }
+                                               }
+                                       });
+                               }
+                       });
+               }
+       };
+}]);
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/fe4f054b/contrib/blur-console/src/main/resources/org/apache/blur/console/webapp/js/factories.js
----------------------------------------------------------------------
diff --git 
a/contrib/blur-console/src/main/resources/org/apache/blur/console/webapp/js/factories.js
 
b/contrib/blur-console/src/main/resources/org/apache/blur/console/webapp/js/factories.js
index 9aa764a..d8d0efd 100644
--- 
a/contrib/blur-console/src/main/resources/org/apache/blur/console/webapp/js/factories.js
+++ 
b/contrib/blur-console/src/main/resources/org/apache/blur/console/webapp/js/factories.js
@@ -1,3 +1,20 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 angular.module('flotr', []).factory('flotrService', ['$document', '$q', 
'$rootScope', function($document, $q, $rootScope) {
        var d = $q.defer();
        function onScriptLoad() {

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/fe4f054b/contrib/blur-console/src/main/resources/org/apache/blur/console/webapp/partials/dashboard.tpl.html
----------------------------------------------------------------------
diff --git 
a/contrib/blur-console/src/main/resources/org/apache/blur/console/webapp/partials/dashboard.tpl.html
 
b/contrib/blur-console/src/main/resources/org/apache/blur/console/webapp/partials/dashboard.tpl.html
index 6a2a70c..6c47ccb 100644
--- 
a/contrib/blur-console/src/main/resources/org/apache/blur/console/webapp/partials/dashboard.tpl.html
+++ 
b/contrib/blur-console/src/main/resources/org/apache/blur/console/webapp/partials/dashboard.tpl.html
@@ -1,12 +1,31 @@
+<!--
+
+Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file 
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+
+-->
+
 <div ng-controller="DashboardCtrl">
     <div id="slow-query-warnings" class="alert alert-danger 
hidden">Warning</div>
     <div class="row">
-        <div class="col-md-8">
+        <div class="col-md-7">
             <div class="row">
                 <div class="col-md-6 center">
                     <h4>Zookeepers</h4>
-                    <!-- div>{{nodeData.zookeepers.chart}}</div>
-                    <div doughnutchart 
chartdata="nodeData.zookeepers.chart"></div -->
+                    <div piechart chartdata="nodeData.zookeepers.chart"></div>
                 </div>
                 <div class="col-md-6 center">
                     <h4>Controllers</h4>
@@ -28,16 +47,15 @@
             <div class="row">
                 <div class="col-md-12 center">
                     <h4>Shards</h4>
-                    <!-- div ng-repeat="cluster in nodeData.clusters" 
style="text-align:center">
-                        <h5>{{cluster.name}}</h5>
-                        <div doughnutchart chartData="cluster.chart"></div>
-                    </div -->
+                    <div ng-repeat="cluster in nodeData.clusters" 
style="text-align:center">
+                        <div piechart chartdata="cluster.chart" 
title="{{cluster.name}}"></div>
+                    </div>
                 </div>
             </div>
             <div class="row">
                 <div class="col-md-12 center">
                     <h4>Tables</h4>
-                    <!-- canvas barchart data="tableData.chart" width="100" 
height="100" options="chartOptions"></canvas -->
+                    <div stackedbarchart chartdata="tableData.chart" 
xlabels="tableData.clusters"></div>
                 </div>
             </div>
         </div>

http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/fe4f054b/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 1649adb..4c41a87 100644
--- a/pom.xml
+++ b/pom.xml
@@ -246,7 +246,7 @@ under the License.
                                                <!-- These javascript libs are 
accounted for in the 
                                                LICENSE-src file in 
distribution/src/main/resources -->
                                                
<exclude>contrib/blur-console/src/main/resources/org/apache/blur/console/webapp/js/angular.js</exclude>
-                                               
<exclude>contrib/blur-console/src/main/resources/org/apache/blur/console/webapp/js/Chart.js</exclude>
+                                               
<exclude>contrib/blur-console/src/main/resources/org/apache/blur/console/webapp/js/flotr2.js</exclude>
                                                
<exclude>contrib/blur-console-old/blur-admin/vendor/assets/javascripts/d3/**</exclude>
                                                
<exclude>contrib/blur-console-old/blur-admin/vendor/assets/javascripts/backbone/**</exclude>
                                                
<exclude>contrib/blur-console-old/blur-admin/vendor/assets/javascripts/flot/**</exclude>

Reply via email to