Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

adding widget dependency in service portal

rick48
Tera Contributor

i have added the widget dependency for creating a Bar chart , but i am unable to get the output

Below i have mentioned the screen shots 

HTML:

<div>
<!-- your widget template -->
   Test

   <canvas id="bar" class="chart chart-bar"


                   chart-data="data" chart-labels="c.labels" chart-series="c.series">

   </canvas>

</div>




Client script:


function($scope) {


var c = this;


c.lables = ['2006','2007','2008','2009','2010','2011','2012'];


c.series = ['Series A', 'Series B'];



c.data = [


[65, 59,80,81,56,55,40],


[28, 48,40,19,86,27,90]


];


}



find_real_file.png

 

 

find_real_file.png

1 ACCEPTED SOLUTION

arey yaar
Giga Guru

i used the below code and it worked 

and added ui script in dependency

Client script:

(function() {
  
  var category_count = {};


var  ga = new GlideAggregate('incident');
  ga.addAggregate('COUNT');  
  ga.groupBy('category');  
   ga.query();
  while (ga.next()) { 
   var category_name = ga.category.getDisplayValue() + '' || '(empty)';
      count = ga.getAggregate('COUNT') * 1;
      category_count[category_name] = count;
     
  }


  data.categories = Object.keys(category_count);
  data.series = [{
      'name':'category count',
      'legendIndex': 0,
      'data': []
  }
];

 data.categories.forEach(function(it) 
													{
     data.series[0].data.push(category_count[it]);
     
  });
})();

server script:

function() {

  var c = this;

    var chart1 = new Highcharts.Chart({  
  chart: {  
      renderTo: 'custom_report',  
      type: 'column'  
  },  
  title: {  
      text: null  
  },  
  xAxis: {  
      categories: c.data.categories,  
      title: {  
          text: null  
      },  
      labels: {  
          rotation: -45  
      }  
  },  
  yAxis: {  
      min: 0,  
      title: {  
          text: null  
      }  
  },  
  series: c.data.series  
 });  
}

html:

<div>
<body>
<div id="custom_report">

</div>

</body>
</div>

View solution in original post

9 REPLIES 9

Chandra Prakash
Tera Expert

Hi Jidesh,

What error you are getting here?

Regards,

Chandra Prakash

Can you explain where you are using dependencies in your Client Script?

 i am using dependency in widget dependency

no error but chart isn't displaying