1) 成功
2) 失败
成功:颜色 = 绿色
对于失败:颜色 = 红色
但问题是 ColumnChart 总是以蓝色显示栏,而且我希望图例为:
Success
Failed
代码 :
angular.module("google-chart-sample", ["googlechart"])
.controller("GenericChartCtrl", function ($scope) {
var data = { "data": { "graphResponse": { "cols": [{ "label": "Types", "type": "string" }, { "label": "values", "type": "number" }], "rows": [{ "c": [{ "v": "success" }, { "v": 11 }] }, { "c": [{ "v": "failed" }, { "v": 0 }] }] } } };
$scope.myChartObject = {};
$scope.myChartObject.type = "ColumnChart";
$scope.myChartObject.data = data.data.graphResponse;
$scope.myChartObject.options = {
slices: {
0: { color: '#50ce68' },
1: { color: '#ff7b7b' },
},
};
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.18/angular.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-google-chart/1.0.0-beta.1/ng-google-chart.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular-ui-bootstrap/0.13.4/ui-bootstrap-tpls.min.js"></script>
<ul ng-app="google-chart-sample" ng-controller="GenericChartCtrl">
<div google-chart chart="myChartObject" style="height:600px; width:100%;"></div>
</ul>
我想要成功栏为绿色,失败为红色,我还想要 2 个图例(成功 - 绿色和失败 - 红色)
我将不胜感激任何帮助:)