【问题标题】:Pentaho CDE : Provide different datasources for each bar of stacked bar chartPentaho CDE : 为堆积条形图的每个条形图提供不同的数据源
【发布时间】:2016-10-25 14:43:25
【问题描述】:

我正在使用 pentaho CDE。

有没有办法,我可以为 CCC 堆叠条形图的每个条形提供不同的数据源(MySQL 查询)?

【问题讨论】:

    标签: pentaho pentaho-cde


    【解决方案1】:

    我做了类似的事情:我有一个图表,其中包含一个可通过脚本编写的“虚拟”数据源 jsonscriptable 和一个函数,该函数通过 ajax 在构建结果集的承诺中激活不同的查询。然后,在图表的 postfetch 中,我只是返回了构建的结果集。

    编辑

    因此假设我在 /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&paramparam_annee='+a+'&paramparam_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 数据源相关联,其属性“开始时执行”设置为 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
    }
    

    玩得开心!

    【讨论】:

    • 你能附上那个 ajax 函数,然后在这里发布获取代码。
    • 是的,我必须找到代码在哪里......我明天会发布它
    • 如何以及在哪里为图表的每个条形图提供不同的数据源?
    • 您必须通过定义系列、轴等来配置图表。然后,图表的 postfech 属性负责为它提供数据
    猜你喜欢
    • 2016-05-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-10-14
    • 2022-08-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多