Advertisement
Guest User

Untitled

a guest
Aug 19th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.95 KB | None | 0 0
  1. <div class="radioButton">
  2. <form ng-submit="submit()" name="myForm" >
  3. <label>
  4. <input type="radio" ng-model="radioChartType" value="Absolute" id="0" ng-click="buttonClick($event)">
  5. Show as Absolute Numbers
  6. </label>
  7. <label>
  8. <input type="radio" ng-model="radioChartType" value="Percentage" id="1" ng-click="buttonClick($event)">
  9. Show as Percentage
  10. </label><br/>
  11. </form>
  12. </div>
  13. <div class="row justify-content-around" id="bar-chart">
  14. <div class="col-md-12" ng-repeat="module in ocw.modules">
  15. <div class="panel panel-default">
  16. <div class="panel-heading">Rule: {{ module.ruleName}} <br>
  17. <p>Total Assets: 1400 &emsp; Compliant Assets: 800 &emsp; Non-Compliant Assets: 600</p>
  18. </div>
  19. <div class="panel-body" >
  20. <div class="col-md-6">
  21. <canvas id="myChart" class="chart chart-line"
  22. chart-data="module.dataC"
  23. chart-labels="module.labels" chart-series="module.seriesC"
  24. chart-options="options" chart-colors="colours"
  25. chart-click="onClick" chart-hover="onHover"
  26. chart-dataset-override="datasetOverride">
  27. </canvas>
  28. </div>
  29. <div class="col-md-6">
  30. <canvas id="bar{{$index}}" class="chart chart-line"
  31. chart-data="module.dataNC"
  32. chart-labels="module.labels" chart-series="module.seriesNC"
  33. chart-options="options" chart-colors="colours"
  34. chart-dataset-override="datasetOverride">
  35. </canvas>
  36. </div>
  37. </div>
  38. </div>
  39. </div>
  40. </div>
  41.  
  42. app1.controller("ChartController", ['$scope', function($scope) {
  43.  
  44. $scope.title = "DMV Ledger";
  45. $scope.labels = ['2006', '2007', '2008', '2009', '2010', '2011', '2012'];
  46. $scope.series = ['Compliant'];
  47.  
  48.  
  49. $scope.colours = ['#72C02C', '#3498DB', '#717984', '#F1C40F'];
  50.  
  51. $scope.DataSetOverride = [{ lineTension: 0
  52. // yAxisID: 'y-axis-1'
  53. }]; //y-axis-1 is the ID defined in scales under options.
  54.  
  55. $scope.options = {
  56. legend: { display: true },
  57. responsive: true, // set to false to remove responsiveness. Default responsive value is true.
  58. scales: {
  59. yAxes: [
  60. {
  61. id: 'y-axis-1',
  62. display: true,
  63. scaleLabel: {
  64. display: true,
  65. // labelString: '# ',
  66. fontStyle: 'bold'
  67. },
  68. ticks: {
  69. fontStyle: 'bold'
  70. }
  71. }],
  72. xAxes: [
  73. {
  74. scaleLabel: {
  75. display: true,
  76. labelString: 'Month',
  77. type: 'linear',
  78. position: 'left',
  79. fontColor: '#72C02C',
  80. fontStyle: 'bold'
  81. },
  82. ticks: {
  83. fontStyle: 'bold'
  84. }
  85. }]
  86. }
  87. };
  88.  
  89.  
  90. $scope.radioChartType = 'Absolute';
  91.  
  92. $scope.radioChart = {
  93. type: 'Absolute'
  94. };
  95.  
  96.  
  97.  
  98.  
  99. //variables for Json data and ng-repeat example
  100.  
  101. var json = {
  102. "modules": [{
  103. "ruleName": "Valid-Registration",
  104. "seriesC": ["Compliant"],
  105. "seriesNC": ["Non-Compliant"],
  106. "dataC": [["900", "699", "780", "491", "676", "275", "660", "867"]],
  107. "dataPC": [["90", "99", "80", "91", "76", "75", "60", "67"]],
  108. "dataNC": [["10", "19", "81", "41", "26", "35", "10", "27"]],
  109. "labels": ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug"],
  110. },
  111.  
  112. {
  113. "ruleName": "Valid-Insurance",
  114. "seriesC": ["Compliant"],
  115. "seriesNC": ["Non-Compliant"],
  116. "dataC": [["10", "19", "20", "11", "26", "35", "40", "57"]],
  117. "dataPC": [["90", "99", "80", "91", "76", "75", "60", "67"]],
  118. "dataNC": [["0", "10", "12", "1", "18", "20", "10", "26"]],
  119. "labels": ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug"],
  120. }, {
  121. "ruleName": "Valid-License",
  122. "seriesC": ["Compliant"],
  123. "seriesNC": ["Non-Compliant"],
  124. "dataC": [["90", "99", "80", "91", "76", "75", "60", "67"]],
  125. "dataPC": [["90", "99", "80", "91", "76", "75", "60", "67"]],
  126. "dataNC": [["23", "29", "12", "10", "16", "15", "30", "27"]],
  127. "labels": ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug"],
  128. }
  129. ]};
  130. $scope.ocw = json;
  131.  
  132. $scope.onClick = function (points, evt) {
  133. console.log(points, evt);
  134. };
  135. }]);
  136.  
  137. $scope.ocw.modules.dataC = $scope.ocw.modules.dataC.map(function(data) {
  138. return ocw.modules.dataC.map(function(y) {
  139. return (y / $scope.max * 100).toFixed(0) ;
  140. });
  141. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement