我正在使用angular-chartjs,当我调整屏幕大小时出现以下错误:
未捕获的TypeError:无法读取属性'更新'未定义的
这是指令:
<canvas id="line" class="chart chart-line" chart-data="data" chart-labels="labels" chart-series="series" chart-legend="true" chart-options="options" chart-dataset-override="datasetOverride" chart-click="onClick">
和JS:
$scope.labels = [];
$scope.series = [];
$scope.data = [];
$scope.onClick = function(points, evt) {
console.log(points, evt);
};
$scope.datasetOverride = [{ yAxisID: 'y-axis-1' }];
$scope.options = {
responsive: true,
pointDot: false,
scaleShowVerticalLines: false,
showTooltips: false,
title: {
display: true,
text: 'asdsadsdsad'
},
tooltips: {
enabled: false
},
scales: {
yAxes: [{
id: 'y-axis-1',
type: 'linear',
display: true,
position: 'left'
}]
},
};
$http.get($scope.url).success(function(data, status, headers, config) {
$scope.series.push('ASD');
$scope.series.push('QWE');
var dataArray = [];
var dataArrayT = [];
var labels = [];
var progress = 1;
var month = 0;
var progressT=1.2;
data.forEach(function(d) {
progress += progress * d.change;
progressT += progressT * d.change;
if (month !== d.month) {
labels.push(d.month);
month = d.month;
} else {
labels.push('');
}
dataArray.push(progress);
dataArrayT.push(progressT);
});
$scope.labels = labels;
$scope.data.push(dataArray);
$scope.data.push(dataArrayT);
});
添加到图表的数据大约为400分。
我只是在调整屏幕大小时才会收到错误,所以并不是说它不能处理不同的大小,只是因为它没有响应。