如何在仪表板中生成状态值(计数)

How can I generate the status values(count) in Dashboard

如何在仪表板中生成状态值(计数)(参见图片)

我的状态选项是“WIP,"Open",已关闭”和 "Total",

我试过使用@datasources.Requset.query.filters.Status._equals生成值但没有成功

我认为你需要先创建一个Calculated Model,在其中你需要编写你的逻辑来计算每个状态值,然后你可以直接在这个图中显示这些值。

这是我用类似方法生成饼图的代码。

// server script
var calculatedModelRecords = [];
var recordsByStatus = {};
var allRecord = app.models.DataSource.newQuery().run();

var pendingrecord = app.models.NewCalculatedDatasource.newRecord();
pendingrecord.count = 0;

for (var i = 0; i < allRecord.length; i++) {
     var record = allRecord[i];

     if(record.Status == 'Pending') {
       // follow same approach for rest of the status count
       pendingrecord.count++;
     }
}

calculatedModelRecords.push(record);

return calculatedModelRecords;