Hi I have a select option in html showing Apple, Google and Amazon
<div class="col-md-9" id="line-chart" ng-controller="LineCtrl">
<div class="panel panel-default" >
<select ng-model="selec">
<option value="aapl">AAPL(Apple)</option>
<option value="goog">GOOG(Google)</option>
<option value="amzn">AMZN(Amazon)</option>
</select>
<div class="panel-body">
<canvas id="line" class="chart chart-line chart-xl" data="data" labels="labels" legend="true"
click="onClick()" series="series"></canvas>
</div>
</div>
</div>
I can show the Apple data as a default with Angualr JS
(function () {
'use strict';
var app = angular.module('examples', ['chart.js', 'ui.bootstrap']);
app.controller('LineCtrl', ['$scope', '$http', function($scope, $http) {
$http.get('stock/aapl.json').success(function(data) {
$scope.selec = 'aapl'; //default as age
$scope.series = ['Tweet Mood', 'Stock Market'];
$scope.stocks = data;
$scope.data = [[], []];
$scope.createGraphArray = function() {
for (var i = 0; i < $scope.stocks.length; i++) {
$scope.data[0].push($scope.stocks[i].percentage1);
$scope.data[1].push($scope.stocks[i].percentage2);
}
};
$scope.createGraphArray();
How can I use other select options (google and amazon) taking the data from json files. json files are already exist. (eg . goog.json, amzn.json) Should I make another controller in javascript? or any other solution?
Thanks in advance.