如何显示条形图

时间:2019-12-13 14:20:01

标签: javascript charts

我的页面上已经有条形图,但是没有数据,如何使此脚本显示数据:

<script>

    var progress = document.getElementById('animationProgress');
    		var config = {
    			type: 'bar',
    			data: {
    				labels: [ '1', '2', '3'],
    				
    				datasets: [ {
    					label: 'Items ',
    					fill: false,
    					borderColor: window.chartColors.blue,
    					backgroundColor: window.chartColors.blue,
    					data: [
            data.addColumn(),
            data.addColumn(),
    		data.addColumn()
    		 for(i = 0; i < my_2d.length; i++)
        data.addRow([my_2d[i][0], parseInt(my_2d[i][1]),parseInt(my_2d[i][2])]);
      
    					]
    				}]
    			},
    			options: {
    				title: {
    					display: true,
    				},
    				animation: {
    					duration: 2000,
    					onProgress: function(animation) {
    						progress.value = animation.currentStep / animation.numSteps;
    					},
    					onComplete: function() {
    						window.setTimeout(function() {
    							progress.value = 0;
    						}, 2000); } } } };
         window.onload = function() {
    			var ctx = document.getElementById('canvas2').getContext('2d');
          window.myLine = new Chart(ctx, config);
    		};
    	</script>
我在页面中没有出现任何错误..应该如何使数据出现?

0 个答案:

没有答案