我获得了图表的一些数据,我需要它们的最大值。 在我的成功中,我在$ scope.tempData中正确获得了这个值,但是如何在$ scope.options scaleStepWidth中使用它呢?
这是我的代码
$scope.truc = [];
$scope.tac = [];
$scope.tic;
$scope.tempData = 0;
$scope.chargerStats = function () {
var idProd = document.getElementById("idProduit").value;
$http.post("{{path('pfcrm_phone_factory_graphe_nbventesproduitpartemps')}}", {id: idProd})
.success(function (data, status, headers, config) {
$scope.data = data;
$scope.truc = $scope.data['datasets'];
$scope.tac = $scope.truc[0].data;
$scope.tempData = Math.max.apply(null, $scope.tac);
})
.error(function (data, status, headers, config) {
alert("Erreur pour l'affichage des graphiques");
});
};
var steps = 3;
// Chart.js Options
$scope.options = {
// Sets the chart to be responsive
responsive: true,
// Boolean - If we should show the scale at all
showScale: true,
// Boolean - If we want to override with a hard coded scale
scaleOverride: true,
// Number - The number of steps in a hard coded scale
scaleSteps: steps,
// Number - The value jump in the hard coded scale
scaleStepWidth: 500,
//Boolean - Whether the scale should start at zero, or an order of magnitude down from the lowest value
scaleBeginAtZero: true,
//Boolean - Whether grid lines are shown across the chart
scaleShowGridLines: true,
//String - Colour of the grid lines
scaleGridLineColor: "rgba(0,0,0,.05)",
//Number - Width of the grid lines
scaleGridLineWidth: 1,
//Boolean - If there is a stroke on each bar
barShowStroke: true,
//Number - Pixel width of the bar stroke
barStrokeWidth: 2,
//Number - Spacing between each of the X value sets
barValueSpacing: 5,
//Number - Spacing between data sets within X values
barDatasetSpacing: 1
};
});
非常感谢。
答案 0 :(得分:0)
我通过将$ scope.option置于成功中解决了我的问题。 非常感谢你的帮助。