,當我嘗試使用Angularchart,我得到這個錯誤:AngularJS - Angularchart - 錯誤有沒有方法「寬度」
TypeError: Object [object Object] has no method 'width'
at e (http://localhost:8080/lib/angular/angular-charts.min.js:1:10690)
at http://localhost:8080/lib/angular/angular.js:6680:44
at nodeLinkFn (http://localhost:8080/lib/angular/angular.js:6271:13)
at compositeLinkFn (http://localhost:8080/lib/angular/angular.js:5678:15)
at nodeLinkFn (http://localhost:8080/lib/angular/angular.js:6265:24)
at compositeLinkFn (http://localhost:8080/lib/angular/angular.js:5682:15)
at compositeLinkFn (http://localhost:8080/lib/angular/angular.js:5685:13)
at compositeLinkFn (http://localhost:8080/lib/angular/angular.js:5685:13)
at publicLinkFn (http://localhost:8080/lib/angular/angular.js:5587:30)
at http://localhost:8080/lib/angular/angular.js:1306:27 <div ac-chart="chartType" ac-data="data" ac-config="config" id="chart" class="chart ng-isolate-scope">
你知道如何解決這一問題?我沒有在互聯網上找到有用的東西。
這裏是我的代碼:
HTML
<!doctype html>
<html lang="en" ng-app="MYaPP">
<head>
<meta charset="utf-8">
<title>myApp</title>
<link rel="stylesheet" href="css/app.css">
<script src="lib/angular/angular.js"></script>
<script src="lib/angular/angular-route.js"></script>
<script src="lib/angular/angular-charts.min.js"></script>
<script src="js/app.js"></script>
<script src="/socket.io/socket.io.js"></script>
</head>
<body>
<div class="top" align="center"> Risk Proxy Manager </div>
<br></br>
<div class="plotGraph" ng-controller='plotGraph'>
<div ac-chart="chartType" ac-data="data" ac-config="config" id='chart' class='chart'></div>
</div>
</body>
</html>
應用:
var myApp = angular.module('myApp', ['angularCharts']);
function plotGraph($scope){
console.log("And here is the graph part");
//Graph
$scope.data = {
series: ['Sales', 'Income', 'Expense', 'Laptops', 'Keyboards'],
data : [{
x : "Sales",
y: [100,500, 0],
tooltip:"this is tooltip"
},
{
x : "Not Sales",
y: [300, 100, 100]
},
{
x : "Tax",
y: [351]
},
{
x : "Not Tax",
y: [54, 0, 879]
}]
}
$scope.chartType = 'bar';
$scope.config = {
labels: false,
title : "Not Products",
legend : {
display:true,
position:'left'
}
}
$scope.config1 = {
labels: false,
title : "Products",
legend : {
display:true,
position:'right'
}
}
}
而CSS:
.graph{
float:left;
width: 50%;
height:400px;
}
///////// ////////////////////////////////////////////////// ///////// /////////////////////////////// 謝謝
給一個變量粘貼plunkr例如 –
你能告訴你的代碼嗎? – qwertynl
是的,我已經把它,對不起 – WellWellWell