我用的是五角星CDE。
有没有一种方法,可以为CCC堆叠条形图的每个条形图提供不同的数据源(MySQL查询)?
发布于 2016-10-24 06:23:47
我做了类似的事情:我有一个图表,它有一个“虚拟”的数据源jsonscriptable而不是脚本,还有一个函数,它通过ajax在构建结果集的承诺内激活不同的查询。然后,在图表的后取中,我只返回了构建的结果集。
编辑
因此,假设我在/home/myhome中有一个仪表板testpromise,其中有3个数据源返回了相似的结果集(即:具有相同类型的相同数量的列)。在我的仪表板中,我实际上用不同的参数调用了3次相同的查询:你必须调整代码。假设我们的图表名为mychart。我有一个按钮(但它可以是其他任何东西),在单击操作上有以下代码:
function(){
Dashboards.res=[];//will contain the result ; As for Pentaho 5.4 without RequireJS, Dashboards is a global varialbe, so that Dashboards.res is accessible eveywhere
Promise.all([getib3(2016,3),getib3(2015,3),getib3(2016,8)]).then(
function(r){
//res contains the result of the 3 queries
console.log(res);
Dashboards.etComponentByName('render_mychart').update(); //Activates the chart
},
function(err) {
console.error(err);
}
);
function getib3(a,m){
var postquery='path=%2Fhome%2myhome%Ftestpromise.cda&dataAccessId=sql_get_ib3¶mparam_annee='+a+'¶mparam_mois=' +m;
$.ajax({
url: '/pentaho/plugin/cda/api/doQuery?',
type: 'POST',
dataType: 'json',
data: postquery,
// async:false,
}).done(function (data) { console.log(data) ;
res.push(data.resultset);//ad the result of the query
}).fail(function ( jqXHR, textStatus, errorThrown) {
alert('query :' + textStatus);
});
}
}
该图表与一个虚拟的jsonscript数据源相关联,其属性"execute at start“被设置为false。postfetch属性:
function(d) {//d is the resultset of the dummy datasource, here we can ignore it.
return (Dashboards.res); //We override d with the resultset we build above
}
玩得开心!
https://stackoverflow.com/questions/40211726
复制相似问题