Versions Compared

Key

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

...

Code Block
linenumberstrue
collapsetrue
.s-container{
    min-width: 300px;
}
.s-height{
    height: 40px;
    border-top: solid #d2d2d2;
}
.s-icon{
    font-size: 16px;
    width:50%;
    font-weight: bold;
}
.s-date{
    width:50%;
}
.n-chart{
    min-height: 350px;
    max-height: 400px;
    min-width: 500px;
}
.s-bottomLabel{
    font-size: 2vw;
    font-weight: bold;
}
.s-topLabel{
    font-size: 1.3vw;
}
.iconHeight{
    min-height: 400px;
    max-height: 450px;
}
.svgIcon{
    height:100px;
    width:125px;
}
.s-select{
    height:24px;
    width:85px;
}


.fHt{
    height: 100%;
}
.fWd{
    width: 100%;
}
.horizontal{
    display: flex;
    flex-direction: row;
}
.middle{
    align-items: center;
}
.vertical{
    display: flex;
    flex-direction: column;
}
.center{
    align-items: center;
}
.wrap{
    flex-wrap: wrap;
}
.flex{
    flex: 1 1 auto;
}
.mst{
    margin-top: 5px;
}
.msl{
    margin-left: 5px;
}
.mnv{
    margin-top: 10px;
    margin-bottom: 10px;
}
.mnt{
    margin-top: 10px;
}
.mnb{
    margin-bottom: 10px;
}
.pla{
    padding: 15px;
}
.pnr{
    padding-right: 10px;
}
.psb{
    padding-bottom: 5px;
}
.bottom{
    justify-content: flex-end;
}
.right{
    justify-content: flex-end;
}

Init

Code Block
linenumberstrue
collapsetrue
var self    = this;
var model   = self.ractive;

model.observe('points.*.view points.*.query', function(nVal,oVal,kPath){
   var pathToPoint  = kPath.substring(0, kPath.lastIndexOf('.'));
   var point        = model.get(pathToPoint);
   
   if (point) {
        if (kPath.indexOf('query') != -1) {
            var nQuery  = model.get('getUpdatedQueryStringForItem').call(model, point);
                
            if (!nQuery || !nQuery.length)
                return;
            
            finstack.eval(nQuery).then(function(data) {
                if (data && data.result && !data.result.isErrorGrid) {
                    point.chartConfig.dataProvider  = data.result.toObj();
                    model.get('updateChartForElementIdWithConfig').call(model, point.amId, point.chartConfig);
                } else {
                    console.log(data);
                }

            }, function(err) {
                console.error(err);
            });
        } else if (point && point.view == 'amChart') {
            model.get('updateChartForElementIdWithConfig').call(model, point.amId, point.chartConfig);
        }
    }
   
});

model.on('unrender', function() {
    model.get('updatePoll').call(model, true);
});


model.on('foldUpdate', function(event) {
    var point   = model.get(event.resolve());
    var fVal    = event.node.value;
    
    model.set(event.resolve()+ '.fold', fVal);
    model.get('updatePoll').call(model);
    
    if (fVal != 'live') {
        var q = 'readById(' +point.pointId+ ').hisRead(' +point.range+ ').foldCol("v0",'+point.fold+')';
        console.log("Setting out...", q);
        finstack.eval(q).then(function(data) {
            model.set(event.resolve()+ '.mainValue', fin.Data.PointUtil.GetPrettyValue(point.original,data.result.toObj(false,false,true)));
        }, function(err) {
            console.log(err);
        });
    }
});


this.ractive.on("calendar", function(event){
    var point   = self.ractive.get(event.resolve());
    var model   = self.ractive;
    
    top.app.ShowCalendar(true,function(calEvent){
        var date = top.app.Utils.DateRangeToAxonDate(calEvent.range, calEvent.mode);
        model.set(event.resolve()+ '.range', date);//.then(function() {
            
     if (point.fold != 'live') {
        var q = 'readById(' +point.pointId+ ').hisRead(' +point.range+ ').foldCol("v0",'+point.fold+')';
        console.log("Setting out...", q);
        finstack.eval(q).then(function(data) {
            model.set(event.resolve()+ '.mainValue', fin.Data.PointUtil.GetPrettyValue(point.original,data.result.toObj(false,false,true)));
        }, function(err) {
            console.log(err);
        });
            
    }
    }, {periods:true});
});



//  Init Data

self.ractive.set({points: [{
            mainIcon: "sm-oil",
            iconColor: "#3488b2",
            mainText: "Main Water",
            mainValue: "150L",
            btIcon: "icon-calendar",
            btIconText: "Today",
            view: 'icon',
            range:"Date",
            options: "hideButtons"
        },{
            mainIcon: "icon-location",
            iconColor: "red",
            mainText: "Rain Water",
            mainValue: "50L",
            btIcon: "icon-calendar",
            btIconText: "Today",
            view: 'waterdrop',
            fillColor:"lightblue",
            svgBackColor:"#d2d2d2",
            fillValue:50,
            myStart:"Select",
            myEnd:"Date",
            options: "hideButtons"
        },{
            mainIcon: "icon-graph-line",
            iconColor: "#b083e0",
            mainText: "Errors",
            mainValue: "23",
            btIcon: "icon-graph-line",
            btIconText: "Data",
            view: 'amChart',
            options: "hideButtons",
            amId: top.app.Utils.GetPseudoId(),
            range:"today()",
            fold:"avg",
            chartConfig: {
                "type": "pie",
                "theme": "light",
                dataProvider: [{
                    "country": "IT",
                    "value": 31.32
                  }, {
                    "country": "Heating",
                    "value": 27.47
                  }, {
                    "country": "Cooling",
                    "value": 25.55
                  }, {
                    "country": "Lighting",
                    "value": 15.66
                  } ],
                  "valueField": "value",
          "titleField": "country",
          "outlineAlpha": 0.4,
          "depth3D": 15,
          "balloonText": "[[title]]<br><span style='font-size:14px'><b>[[value]]:</b> ([[percents]]%)</span>",
          "angle": 30,
          "export": {
            "enabled": true
          }
        }
}]});

...