Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example code for Line chart does not work #591

Closed
shafeerambatt opened this issue Feb 2, 2017 · 10 comments
Closed

Example code for Line chart does not work #591

shafeerambatt opened this issue Feb 2, 2017 · 10 comments

Comments

@shafeerambatt
Copy link

I copied the same example code given for Line Chart, but its not working. Nothing is shown in the HTML. Given below my code.

<title>Chart_Tutorials</title> <script src="angular.js" ></script> <script src="Chart.js"></script> <script src="angular-chart.js"></script>
	<canvas id="line" class="chart chart-line" chart-data="data" chart-labels="labels" chart-series="series" chart-options="options" chart-dataset-override="datasetOverride" chart-click="onClick">
	</canvas>

	<script>
		angular.module('myModule', ['chart.js']);
		angular.module("app", ["chart.js"]).controller("LineCtrl", function ($scope) { $scope.labels = ["January", "February", "March", "April", "May", "June", "July"];$scope.series = ['Series A', 'Series B'];
		$scope.data = [[65, 59, 80, 81, 56, 55, 40],[28, 48, 40, 19, 86, 27, 90]];
		$scope.onClick = function (points, evt) {
		console.log(points, evt);};
		$scope.datasetOverride = [{ yAxisID: 'y-axis-1' }, { yAxisID: 'y-axis-2' }];
		$scope.options = {
			scales: {
				yAxes: [
			        {
			          id: 'y-axis-1',
			          type: 'linear',
			          display: true,
			          position: 'left'
			        },
			        {
			          id: 'y-axis-2',
			          type: 'linear',
			          display: true,
			          position: 'right'
			        }
			      ]
			    }
			  };
			});
	</script>



</body>

PS: I have the libraries in the same folder as the html file.

@garretwilson
Copy link

It's not working for me either. Absolutely nothing is showing up.

@shafeerambatt
Copy link
Author

I tried other examples also. But result is same, nothing is showing up.

@shafeerambatt
Copy link
Author

@garretwilson I made some changes and its working now. Make sure you have the dependencies in the same folder as the html file.

linechart.txt

@garretwilson
Copy link

What dependencies? Why was this closed?

What do you mean, in the same folder as the HTML file? This is an Angular application. That means it's a real application --- a large application with components, services, and routing. Nobody puts all their files in the same folder! Unless your application is a "Hello World" demo, it is imperative to arrange your source files in multiple folders.

Show me a single Angular book that recommends putting all your files in a single folder. Moreover this is not a limitation of Angular --- Angular was designed to have files in multiple folders.

If Angular Chart requires that its source files be in the same folder as my HTML template, it is fundamentally broken.

@garretwilson
Copy link

Since this issue was closed even though it isn't satisfactorily resolved, I've opened Bug #594. I had already asked a question on Stack Overflow. We need to get to the bottom of this.

@shafeerambatt
Copy link
Author

shafeerambatt commented Feb 6, 2017 via email

@Ygilany
Copy link

Ygilany commented Feb 20, 2017

@shafeerambatt The text file you attached is empty !!

@shafeerambatt
Copy link
Author

@Ygilany linechart.txt is the file attached. I just downloaded it and opened it in notepad and saw the code. Try again.

@Ygilany
Copy link

Ygilany commented Feb 20, 2017

okay, This might not make any sense. But I only put the canvas element within a div and it worked

The canvas needs to be in a div wrapper apparently .. hope it may help someone

@jtblin
Copy link
Owner

jtblin commented Apr 28, 2017

Sorry to answer so late @garretwilson, note that the creator of the issue closed the issue him/herself because they think it was fixed :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants