• smartBI宏定义01


    function main(chartView) {
    var chart = chartView.getChartObject();
    var option = chart.getOptions();
    var data = [];
    var series = option.series;

    for (var i in series) {
    var seriesItem = series[i];
    data = seriesItem.data;
    delete seriesItem.data; //初始option中去掉data数据,拼在独立的options中。
    }

    var val = getSqlResult();

    var data1 = [];
    //data1 = val;

    var test = 22;

    var daDiShiName = val[0][1];
    var didiChuXingName = val[12][1];
    var gongJiaoCheName = val[24][1];
    var ziXingCheName = val[36][1];

    var daDiShiData = [];
    var didiChuXingData = [];
    var gongJiaoCheData = [];
    var ziXingCheData = [];

    for (var i = 0; i < val.length; i++) {
    if (series.name == val[i][1].value) {

    }
    if(i <= 11) {
    daDiShiData.push(val[i][0].value);
    }
    if(i >= 12 && i <= 23) {
    didiChuXingData.push(val[i][0].value);
    }
    if(i >= 24 && i <= 35) {
    gongJiaoCheData.push(val[i][0].value);
    }
    if(i >= 36) {
    ziXingCheData.push(val[i][0].value);
    }

    data1.push(val[i][0].value);
    test = val[i][0].value;
    }

    series[0].data = ziXingCheData;
    series[1].data = gongJiaoCheData;
    series[2].data = daDiShiData;
    series[3].data = didiChuXingData;

    //设置标题
    /*
    option.title = {
    text: test + '',
    textAlign: 'center',
    left: '63%',
    top: '55%',
    textStyle: {
    fontSize: 60
    }
    };
    */

    //series.data = data1;
    option.series = series;

    chart.setOptions(option);
    }

    function getSqlResult() {

    var sql = " select * FROM ( select * FROM ( select count(t2.cxgj) as 出行次数, t2.cxgj as 出行工具, t2.mm as 月份 FROM ( select cxgj from SP_RKCXSJ group by cxgj ) t1 inner join ( select cxgj, 1 as mm from SP_RKCXSJ where to_char(cxrq,'mm') = 01 )t2 on T2.CXGJ = T1.cxgj group by t2.cxgj, t2.mm order by count(t2.cxgj) desc ) t union all select * FROM ( select count(t2.cxgj) as 出行次数, t2.cxgj as 出行工具, t2.mm as 月份 FROM ( select cxgj from SP_RKCXSJ group by cxgj ) t1 inner join ( select cxgj, 2 as mm from SP_RKCXSJ where to_char(cxrq,'mm') = 02 )t2 on T2.CXGJ = T1.cxgj group by t2.cxgj, t2.mm order by count(t2.cxgj) desc ) t union all select * FROM ( select count(t2.cxgj) as 出行次数, t2.cxgj as 出行工具, t2.mm as 月份 FROM ( select cxgj from SP_RKCXSJ group by cxgj ) t1 inner join ( select cxgj, 3 as mm from SP_RKCXSJ where to_char(cxrq,'mm') = 03 )t2 on T2.CXGJ = T1.cxgj group by t2.cxgj, t2.mm order by count(t2.cxgj) desc ) t union all select * FROM ( select count(t2.cxgj) as 出行次数, t2.cxgj as 出行工具, t2.mm as 月份 FROM ( select cxgj from SP_RKCXSJ group by cxgj ) t1 inner join ( select cxgj, 4 as mm from SP_RKCXSJ where to_char(cxrq,'mm') = 04 )t2 on T2.CXGJ = T1.cxgj group by t2.cxgj, t2.mm order by count(t2.cxgj) desc ) t union all select * FROM ( select count(t2.cxgj) as 出行次数, t2.cxgj as 出行工具, t2.mm as 月份 FROM ( select cxgj from SP_RKCXSJ group by cxgj ) t1 inner join ( select cxgj, 5 as mm from SP_RKCXSJ where to_char(cxrq,'mm') = 05 )t2 on T2.CXGJ = T1.cxgj group by t2.cxgj, t2.mm order by count(t2.cxgj) desc ) t union all select * FROM ( select count(t2.cxgj) as 出行次数, t2.cxgj as 出行工具, t2.mm as 月份 FROM ( select cxgj from SP_RKCXSJ group by cxgj ) t1 inner join ( select cxgj, 6 as mm from SP_RKCXSJ where to_char(cxrq,'mm') = 06 )t2 on T2.CXGJ = T1.cxgj group by t2.cxgj, t2.mm order by count(t2.cxgj) desc ) t union all select * FROM ( select count(t2.cxgj) as 出行次数, t2.cxgj as 出行工具, t2.mm as 月份 FROM ( select cxgj from SP_RKCXSJ group by cxgj ) t1 inner join ( select cxgj, 7 as mm from SP_RKCXSJ where to_char(cxrq,'mm') = 07 )t2 on T2.CXGJ = T1.cxgj group by t2.cxgj, t2.mm order by count(t2.cxgj) desc ) t union all select * FROM ( select count(t2.cxgj) as 出行次数, t2.cxgj as 出行工具, t2.mm as 月份 FROM ( select cxgj from SP_RKCXSJ group by cxgj ) t1 inner join ( select cxgj, 8 as mm from SP_RKCXSJ where to_char(cxrq,'mm') = 08 )t2 on T2.CXGJ = T1.cxgj group by t2.cxgj, t2.mm order by count(t2.cxgj) desc ) t union all select * FROM ( select count(t2.cxgj) as 出行次数, t2.cxgj as 出行工具, t2.mm as 月份 FROM ( select cxgj from SP_RKCXSJ group by cxgj ) t1 inner join ( select cxgj, 9 as mm from SP_RKCXSJ where to_char(cxrq,'mm') = 09 )t2 on T2.CXGJ = T1.cxgj group by t2.cxgj, t2.mm order by count(t2.cxgj) desc ) t union all select * FROM ( select count(t2.cxgj) as 出行次数, t2.cxgj as 出行工具, t2.mm as 月份 FROM ( select cxgj from SP_RKCXSJ group by cxgj ) t1 inner join ( select cxgj, 10 as mm from SP_RKCXSJ where to_char(cxrq,'mm') = 10 )t2 on T2.CXGJ = T1.cxgj group by t2.cxgj, t2.mm order by count(t2.cxgj) desc ) t union all select * FROM ( select count(t2.cxgj) as 出行次数, t2.cxgj as 出行工具, t2.mm as 月份 FROM ( select cxgj from SP_RKCXSJ group by cxgj ) t1 inner join ( select cxgj, 11 as mm from SP_RKCXSJ where to_char(cxrq,'mm') = 11 )t2 on T2.CXGJ = T1.cxgj group by t2.cxgj, t2.mm order by count(t2.cxgj) desc ) t union all select * FROM ( select count(t2.cxgj) as 出行次数, t2.cxgj as 出行工具, t2.mm as 月份 FROM ( select cxgj from SP_RKCXSJ group by cxgj ) t1 inner join ( select cxgj, 12 as mm from SP_RKCXSJ where to_char(cxrq,'mm') = 12 )t2 on T2.CXGJ = T1.cxgj group by t2.cxgj, t2.mm order by count(t2.cxgj) desc ) t ) t12 order by 出行工具,月份 ";


    var util = jsloader.resolve("freequery.common.util");
    var ret = util.remoteInvoke("DataSourceService", "getDataByQuerySql", ["DS.sparrow", sql, 0, 10000]);
    if (ret.succeeded && ret.result) {
    var data = ret.result.data; //结果集数据,返回一个二维数组
    return data;
    } else {

    var data2 = [];
    data2.push(11);
    data2.push(110);
    data2.push(71);
    data2.push(51);
    data2.push(11);
    data2.push(31);
    data2.push(11);

    return ret.result.data;
    }

    };

  • 相关阅读:
    2.Mysql集群------Mycat读写分离
    ASP.NET Core 认证与授权[4]:JwtBearer认证
    API做翻页的两种思路
    C# 8
    ASP.NET Core 认证与授权[2]:Cookie认证
    ASP.NET Core 认证与授权[1]:初识认证
    Asp.Netcore使用Filter来实现接口的全局异常拦截,以及前置拦截和后置拦截
    C#中out和ref的区别
    存储过程的优缺点
    存储过程的作用和意义,讲的很好
  • 原文地址:https://www.cnblogs.com/handsome1013/p/7827526.html
Copyright © 2020-2023  润新知