var myApp = angular.module("myApp", ['ngResource']);
myApp.factory("server", function($resource) {
return $resource('https://tcp.firebaseio.com/graph.json')
})
myApp.controller("main", function($scope, server) {
$scope.test = "Hellow";
$scope.data = server.query();
$scope.data.$promise.then(function(result) {
$scope.values = result;
$scope.defaultValue = $scope.values[0].value;
console.log($scope.defaultValue);
})
$scope.updateGraph = function(item) {
$scope.defaultValue = item.value;
}
});
var planVsActual = function($timeout) {
return {
replace: true,
template: "<div id='pieGraph'></div>",
link: function(scope, element, attr) {
$timeout(function() {
scope.$watch("defaultValue", function(newVal, oldVal) {
var phraseValue = [newVal, 100 - newVal];
drawPie(phraseValue);
function drawPie(array) {
console.log(element.width)
var width = element.width(), height = element.height(),
radius = Math.min(width, height) / 1.2, data = array;
if (!array.length) return;
var color = d3.scale.ordinal()
.domain(array)
.range(["#ffff00", "#1ebfc5"]);
var pie = d3.layout.pie()
.sort(null)
.value(function(d) { return d });
var arc = d3.svg.arc()
.outerRadius(radius - 90)
.innerRadius(radius - 85);
var svg = d3.select("#pieGraph")
.append("svg")
.attr("width", width)
.attr("height", height)
.append("g")
.attr("transform", "translate(" + width / 2 + "," + height / 2 + ")");
var g = svg.selectAll(".arc")
.data(pie(array))
.enter().append("g")
.attr("class", "arc");
g.append("path")
.attr("d", arc)
.style("fill", function(d,i) { return color(d.data); });
g.append("text")
.text(array[0]+'%')
.attr("class", "designVal")
.style("text-anchor", "middle")
}
})
}, 100)
}
}
}
angular.module("myApp")
.directive("planVsActual", planVsActual);
我是hive的新手,我也不擅长sql。我试图运行多连接查询,但我不断收到此错误:
SELECT t.col1, t.col2, t.col3, e.col1
FROM table1 t
JOIN table2 s
ON (t.col1 = s.col1) sv
JOIN table3 e
ON (sv.col1 = e.col1) svv
JOIN table4 c
ON (svv.col3 = c.col3);
答案 0 :(得分:1)
删除别名&#39; sv&#39; svv&#39;。我不确定你尝试做什么,但你已经为你的桌子设置了别名字符&#39;&#39; e&#39;并且&#39; c&#39;。我给你的建议是:使用具体的标识符作为别名和你在这里做的连接,你会很快失去焦点。
我假设您要执行以下操作:
SELECT t1.col1, t1.col2, t1.col3, t3.col1
FROM table1 t1
JOIN table2 t2
ON (t1.col1 = t2.col1)
JOIN table3 t3
ON (t2.col1 = t3.col1)
JOIN table4 t4
ON (t3.col3 = t4.col3);