Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
var template = this;
var dataTEST = []; 
var mySites; 
var vavNum = 0;
var ahuNum = 0;
var boilerNum = 0;
var chillerNum = 0;
var myTest = query('targetPoint');
console.log(myTest.pointId);
var myTarget = myTest.pointId;

    finstack.eval('readAll(site and regionRef=='+ myTarget+')').then(function(data) {
    mySites  = data.result.toObj();
        mySites.forEach(function(p,index) {
            finstack.eval('readAll(siteRef=='+p.id+' and equip and vav).alarms(today).size').then(function(data) {
                var newVAVPOINTS  = data.result.toObj();
                newVAVPOINTS.forEach(function(p,index) {
                    vavNum += p.val;
                    console.log(vavNum);
                });
            });
            finstack.eval('readAll(siteRef=='+p.id+' and equip and ahu).alarms(today).size').then(function(data) {
                var newAHUPOINTS  = data.result.toObj();
                newAHUPOINTS.forEach(function(p,index) {
                    ahuNum += p.val;
                    console.log(ahuNum);
                });
            });
            finstack.eval('readAll(siteRef=='+p.id+' and equip and chiller).alarms(today).size').then(function(data) {
                var newCHILLERPOINTS  = data.result.toObj();
                newCHILLERPOINTS.forEach(function(p,index) {
                    chillerNum += p.val;
                    console.log(chillerNum);
                });
            });
            finstack.eval('readAll(siteRef=='+p.id+' and equip and boiler).alarms(today).size').then(function(data) {
                var newBOILERPOINTS  = data.result.toObj();
                newBOILERPOINTS.forEach(function(p,index) {
                    boilerNum += p.val;
                    console.log(boilerNum);
                });
            });
            setTimeout(function(){
            dataTEST.push({
                navName : p.dis,
                Vav : vavNum,
                Ahu : ahuNum,
                Boiler : boilerNum,
                Chiller : chillerNum
            });
            
            vavNum = 0;
            ahuNum = 0;
            boilerNum = 0;
            chillerNum = 0;
            }, 100);
        });
    });
        
    console.log('dataTEST', dataTEST);
  
var chart = AmCharts.makeChart(Chart.view, {
  "type": "serial",
	"theme": "light",
    "legend": {
        "horizontalGap": 10,
        "maxColumns": 1,
        "position": "right",
		"useGraphSettings": true,
		"markerSize": 10
    },
    	"titles": [
		{
			"id": "Title-1",
			"size": 15,
			"text": myTest.dis
		}
	],
    "dataProvider": dataTEST,
    "valueAxes": [{
        "stackType": "regular",
        "axisAlpha": 0.5,
        "gridAlpha": 0
    }],
    "graphs": [{
        "balloonText": "<b>[[title]]</b><br><span style='font-size:14px'>[[category]]: <b>[[value]]</b></span>",
        "fillAlphas": 0.8,
        "labelText": "[[value]]",
        "lineAlpha": 0.3,
        "title": "Vav",
        "type": "column",
		"color": "#000000",
        "valueField": "Vav"
    }, {
        "balloonText": "<b>[[title]]</b><br><span style='font-size:14px'>[[category]]: <b>[[value]]</b></span>",
        "fillAlphas": 0.8,
        "labelText": "[[value]]",
        "lineAlpha": 0.3,
        "title": "Ahu",
        "type": "column",
		"color": "#000000",
        "valueField": "Ahu"
    }, {
        "balloonText": "<b>[[title]]</b><br><span style='font-size:14px'>[[category]]: <b>[[value]]</b></span>",
        "fillAlphas": 0.8,
        "labelText": "[[value]]",
        "lineAlpha": 0.3,
        "title": "Boiler",
        "type": "column",
		"color": "#000000",
        "valueField": "Boiler"
    }, {
        "balloonText": "<b>[[title]]</b><br><span style='font-size:14px'>[[category]]: <b>[[value]]</b></span>",
        "fillAlphas": 0.8,
        "labelText": "[[value]]",
        "lineAlpha": 0.3,
        "title": "Chiller",
        "type": "column",
		"color": "#000000",
        "valueField": "Chiller"
    }],
    "rotate": true,
    "categoryField": "navName",
    "categoryAxis": {
        "gridPosition": "start",
        "axisAlpha": 0,
        "gridAlpha": 0,
        "position": "left"
    },
    "export": {
    	"enabled": true
     }
});

...