Monday, 23 October 2023

Adding data from all datasources to display only the sum value in barchart of thingsboard widget

Following is the JS script that I'm trying to modify (time series):

self.onInit = function() {
    self.ctx.flot = new TbFlot(self.ctx, 'bar');   
    
    console.log("console",self.ctx.data)
}

self.onDataUpdated = function() {
    
   
    //console.log("console",self.ctx.$scope.data[0]) //
    self.ctx.flot.update();
}

self.onLatestDataUpdated = function() {
    self.ctx.flot.latestDataUpdate();
}

self.onResize = function() {
    self.ctx.flot.resize();
}

self.onEditModeChanged = function() {
    self.ctx.flot.checkMouseEvents();
}

self.onDestroy = function() {
    self.ctx.flot.destroy();
}

self.typeParameters = function() {
    return {
        hasAdditionalLatestDataKeys: true
    };
}

I plan to add one more data source by duplicating the first element:

self.ctx.data.push(self.ctx.data[0]);

And later sum data from all the sources to update the data at the duplicated element and finally plot this value only in the barchart.

However, I get the following error just after duplicating the element and running:

enter image description here

enter image description here

I can see that data being updated in the chart but I get an error before I can do the mathematics. Following is the console log before and after duplicating the data.

enter image description here

enter image description here

Is my approach correct? Shall I update the HTML template and use $scope ?

Thank you.



from Adding data from all datasources to display only the sum value in barchart of thingsboard widget

Sunday, 22 October 2023

How to execute/evaluate dynamic mixt of html and JavaScript code and the result to embed it into the angular component?

The problem is like this. There is an API that generates PDFs from using HTML to PDF mechanism. The API returns the nicely generated PDFs to an angular app. So far so good. Now there is a new requirement that pieces from these PDFs should be embedded into some Angular components. I get these pieces from the API as strings and now I must find a way to make them run. The problem is that some have JavaScript in them and this code is not executed by the Angular when I bind them to the components. Any advice or workaround is welcome. I have created an example with such code for a easy testing and understanding of the problem.

https://stackblitz.com/edit/angular-ksytg4



from How to execute/evaluate dynamic mixt of html and JavaScript code and the result to embed it into the angular component?

Lifelines Reference Group | Python Survival Analysis

Is there a way to calculate Hazard Ratios in Python's Lifeline package relative to a specified group?

What I have at the moment is:

from lifelines import CoxPHFitter

data=KM_DF[["Survival_Time","Event","30_40","40_50","50_60","60_70","70_80","Male"]]

cph=CoxPHFitter()
cph.fit(data,"Survival_Time",event_col="Event",show_progress=True)
cph.print_summary()

I would like to know the HR of the 40_50, 50_60, 60_70, and 70_80 group relative to the 30_40 group while also adjusting for sex. But at the moment, I get a HR of the group I want to be the reference ("30-40") as 3.02.

Is there a way to do this with lifelines?

For greater context/motivation, in R's workflow for Cox Proportional Hazard Ratio calculations, one can set variable "levels", and the subsequent Hazard Ratios are relative to the 1st level. However, I have been unable to sort out if this is possible in the popular "Lifelines" Python package.



from Lifelines Reference Group | Python Survival Analysis