<html>
<head>
<script src="../../../../Scripts/angular.min.js"></script>
<script src="../../../../Scripts/angular.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/1.0.2/Chart.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/1.0.2/Chart.js"></script>
<script src="http://cdn.jsdelivr.net/angular.chartjs/latest/angular-chart.min.js"></script>
</head>
<body ng-app="myApp">
<div style="height:500px; width:800px" ng-controller="BarChartCtrl">
<h2>BarChart example</h2>
<canvas id="bar" class="chart chart-bar" chart-data="data" chart-labels="labels" chart-series="series"></canvas>
</div>
<script>
var app=angular.module('myApp', ['chart.js']);
app.controller('BarChartCtrl', function ($scope) {
$scope.labels = ['2014','2015','2016'];
$scope.series = ['Jan', 'Feb', 'Mar', 'Apr', 'May'];
$scope.data = [
[65, 59, 80],
[28, 48, 40],
[30, 0, 0],
[44, 10, 0],
[50, 0, 40],
[66, 50, 0],
[70, 0, 0],
[88, 0, 70],
[90, 30, 0],
[10, 0, 60],
[11, 20, 0],
[12, 0, 90]
];
});
在上面的代码中,Y轴值是Numbers,我想以排列方式将其更改为某个字符串,以便我可以从$ scope.data传递“range”字符串
答案 0 :(得分:0)
您可以将map
数组转换为所需的字符串数组,如下所示:
$scope.rangeArray = $scope.data.map(function(item) {
return {
Item.join(",") // join the nested array values to a string separated with a comma for example
}
});
item
函数中的每个map
都是data
数组中的嵌套数组。在我们的示例中,您将获得具有嵌套字符串数组的rangeArray
。
答案 1 :(得分:0)
在AngularJs-Charts中,我们无法将Y轴整数值更改为Range的字符串值,但在其他图表中,我们只需附加$或任何此类符号即可修改。