Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Series Details Not Showing in Angular Chart with Charts.js

I am implementing the Angular Line Chart Functionality in my ionic application as described in the link https://jtblin.github.io/angular-chart.js/

The charts are displayed successfully, but the series details below the chart are not displayed(Meaning which color represents which Line)

I am passing the Chart-series field but still not showing. Kindly, advise.

Here is index.html

 <ion-content ng-controller="ExampleCtrl">
     <div class="card">
        <div class="item item-divider">
          This is a Line Chart
        </div>
        <div class="item item-text-wrap">
          <canvas id="line" class="chart chart-line" chart-data="data" chart-labels="labels" chart-series="series" chart-options="options" chart-legend="true"
          chart-dataset-override="datasetOverride" chart-click="onClick"> 
          </canvas> 
        </div>
     </div>          
  </ion-content>

Here is my app.js

angular.module('starter', ['ionic', 'chart.js'])

.run(function($ionicPlatform) {
 $ionicPlatform.ready(function() {
if(window.cordova && window.cordova.plugins.Keyboard) {
  // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
  // for form inputs)
  cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);

  // Don't remove this line unless you know what you are doing. It stops the viewport
  // from snapping when text inputs are focused. Ionic handles this internally for
  // a much nicer keyboard experience.
  cordova.plugins.Keyboard.disableScroll(true);
}
if(window.StatusBar) {
  StatusBar.styleDefault();
}
});
})

.controller("ExampleCtrl", 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]
 ];

});
like image 918
Sourav Das Avatar asked Nov 30 '22 22:11

Sourav Das


1 Answers

You Should set legends display true . that will solve your problem

$scope.labels = ["January", "February", "March", "April", "May", "June", "July"];
$scope.series = ['Series A', 'Series B'];
$scope.options = { legend: { display: true } }; // missing 

$scope.data = [
   [65, 59, 80, 81, 56, 55, 40],
   [28, 48, 40, 19, 86, 27, 90]
];

Hope this solve your problem . Thanks

like image 188
Ujjwal kaushik Avatar answered Dec 11 '22 02:12

Ujjwal kaushik