Google visualization 在谷歌图表中向下搜索

Google visualization 在谷歌图表中向下搜索,google-visualization,drilldown,Google Visualization,Drilldown,我正在尝试在饼图中实现钻取或向下钻取。实际上,我有一个向下展开的饼图,但是,当我更改集合的值时,它不起作用。我想知道是什么出了问题,因为我完全遵循了工作代码,只是替换了它的值。图表根本不显示,并且有一个错误:Uncaught error:Unknown header type:17format+en、default+en、ui+en、controls+en、corechart+en.I.js:191。我不确定这个错误是否与问题有关 Javascript: google.load(

我正在尝试在饼图中实现钻取或向下钻取。实际上,我有一个向下展开的饼图,但是,当我更改集合的值时,它不起作用。我想知道是什么出了问题,因为我完全遵循了工作代码,只是替换了它的值。图表根本不显示,并且有一个错误:
Uncaught error:Unknown header type:17format+en、default+en、ui+en、controls+en、corechart+en.I.js:191
。我不确定这个错误是否与问题有关

Javascript:

        google.load('visualization', '1', {packages: ['corechart', 'controls']});
        google.setOnLoadCallback(drawChart1);

        var index = 0;
        function drawChart1() {
            <%
                int aku = 0, cdu = 0, ls = 0, ptr = 0, rad = 0, oper = 0;
                int aku1 = 0, aku2 = 0, aku3 = 0, aku4 = 0, aku5 = 0;
                int cdu1 = 0, cdu2 = 0, cdu3 = 0, cdu4 = 0, cdu5 = 0, cdu6 = 0;
                int ls1 = 0, ls2 = 0, ls3 = 0, ls4 = 0, ls5 = 0, ls6 = 0, ls7 = 0, ls8 = 0, ls9 = 0, ls10 = 0;
                int ptr1 = 0, ptr2 = 0, ptr3 = 0, ptr4 = 0;
                int rad1 = 0, rad2 = 0, rad3 = 0;
                int oper1 = 0;
            %> //Dummy values

            //Main
            var main = [
                ['Artificial Kidney Unit', <%=aku%>],
                ['Cardiac Diagnostic Unit', <%=cdu%>],
                ['Laboratory Services', <%=ls%>],
                ['Physical Therapy and Rehabilitation', <%=ptr%>],
                ['Radiology', <%=rad%>],
                ['Operations', <%=oper%>]
            ];

            //Aku
            var akuu = [
                ['Hemodialysis', <%=aku1%>],
                ['Peritoneal Dialysis', <%=aku2%>],
                ['Continuous Renal Replacement Therapy', <%=aku3%>],
                ['Sustained Low Efficient Dialysis', <%=aku4%>],
                ['Private Dialysis Suite', <%=aku5%>]
            ];

            //Cdu
            var cduu = [
                ['Electrocardiography', <%=cdu1%>],
                ['Ambulatory Electrocardiography', <%=cdu2%>],
                ['Exercise Stress Test', <%=cdu3%>],
                ['2D Echo', <%=cdu4%>],
                ['Lower Extremity Arterial & Venous Color Duplex Scan', <%=cdu5%>],
                ['Carotid Artery Duplex Scan', <%=cdu6%>]
            ];

            //Ls
            var lss = [
                ['Hematology', <%=ls1%>],
                ['Blood Chemistry', <%=ls2%>],
                ['Immunology and Serology', <%=ls3%>],
                ['Clinical Microscopy', <%=ls4%>],
                ['Microbiology', <%=ls5%>],
                ['Blood Bank and Transfusion Services', <%=ls6%>],
                ['Drug Testing', <%=ls7%>],
                ['Parasitology', <%=ls8%>],
                ['Surgical Pathology', <%=ls9%>],
                ['Cytopathology', <%=ls10%>]
            ];

            //Ptr
            var ptrr = [
                ['Physical Therapy', <%=ptr1%>],
                ['Occupational Therapy', <%=ptr2%>],
                ['Ultrasound Diagnostic Therapy', <%=ptr3%>],
                ['Orthotics and Prosthetic Evaluation', <%=ptr4%>]
            ];

            //rad
            var radd = [
                ['X-ray', <%=rad1%>],
                ['Ultrasound', <%=rad2%>],
                ['CT Scan', <%=rad3%>]
            ];

            //oper
            var operr = [
                ['Surgery', <%=oper1%>]
            ];

            var collection = [];
            collection[0] = google.visualization.arrayToDataTable(main);
            collection[1] = google.visualization.arrayToDataTable(akuu);
            collection[2] = google.visualization.arrayToDataTable(cduu);
            collection[3] = google.visualization.arrayToDataTable(lss);
            collection[4] = google.visualization.arrayToDataTable(ptrr);
            collection[5] = google.visualization.arrayToDataTable(radd);
            collection[6] = google.visualization.arrayToDataTable(operr);

            var options1 = {
                title: 'Departments',
                animation: {'duration': 500, 
                    'easing': 'in'},
                action: function() {
                    button.onclick = function() {
                        recreateDashboard(0);
                    };
                }
            };

            var chart1 = new google.visualization.PieChart(document.getElementById('chart1'));

            google.visualization.events.addListener(chart1, 'select', drillIn);
            google.visualization.events.addListener(chart1, 'click', drillOut);

            chart1.draw(collection[0], options1);

            function drillIn() {
                var sel = chart1.getSelection();
                var row = chart1.getSelection()[0].row;
                options1['title'] = collection[index].getValue(sel[0].row, 0);

                if(index === 0) {
                    if(row === 0) {
                        index = 1;
                    }
                    if(row === 1) {
                        index = 2;
                    }
                    if(row === 2) {
                        index = 3;
                    }
                    if(row === 3) {
                        index = 4;
                    }
                    if(row === 4) {
                        index = 5;
                    }
                    if(row === 5) {
                        index = 6;
                    }
                }
                else if(index === 1 || index === 2 || index === 3 || index === 4 || index === 5 || index === 6) {
                    options1['title'] = '# of services rendered in <%=year%>';
                    index = 0;
                }

                chart1.draw(collection[index], options1);


            }

            function drillOut(e) {
                if(e.targetID === "title") {
                    if(index !== 0)
                        index--;
                    else if(index === 4 || index === 6 || index === 8)
                        index -= 2;
                    chart1.draw(collection[index], options1);
                }
            }
google.load('visualization','1',{packages:['corechart','controls']});
setOnLoadCallback(drawChart1);
var指数=0;
函数drawChart1(){
//虚拟值
//主要
var main=[
[‘人工肾单位’,],
[‘心脏诊断单元’,],
[‘实验室服务’,],
[‘物理治疗和康复’,],
[‘放射学’,],
[‘操作’,]
];
//阿库
var akuu=[
[血液透析',],
[‘腹膜透析’,],
[‘持续性肾脏替代疗法’,],
[‘持续低效透析’,],
[‘私人透析套房’,]
];
//基民盟
变量cduu=[
[‘心电图学’,],
[‘动态心电图’,],
[‘运动压力测试’,],
['2D Echo',],
[‘下肢动脉和静脉彩色双重扫描’,],
[‘颈动脉双重扫描’,]
];
//Ls
var lss=[
[血液学],],
[‘血液化学’,],
[‘免疫学和血清学’,],
[‘临床显微镜’,],
[微生物学],],
[‘血库和输血服务’,],
[‘药物测试’,],
[‘寄生虫学’,],
[‘外科病理学’,],
[‘细胞病理学’,]
];
//Ptr
var ptrr=[
[‘物理疗法’,],
[‘作业疗法’,],
[‘超声诊断治疗’,],
[‘矫形学和修复评估’,]
];
//拉德
var radd=[
[‘X光’,],
[超声波],],
[‘CT扫描’,]
];
//操作工
变量操作器=[
[‘手术’,]
];
var集合=[];
集合[0]=google.visualization.arrayToDataTable(主);
集合[1]=google.visualization.arrayToDataTable(akuu);
集合[2]=google.visualization.arrayToDataTable(cduu);
集合[3]=google.visualization.arrayToDataTable(lss);
collection[4]=google.visualization.arrayToDataTable(ptrr);
集合[5]=google.visualization.arrayToDataTable(radd);
集合[6]=google.visualization.arrayToDataTable(Oper);
变量选项1={
标题:"部门",,
动画:{'duration':500,
'放松':'在'},
行动:功能(){
button.onclick=函数(){
重新创建仪表板(0);
};
}
};
var chart1=新的google.visualization.PieChart(document.getElementById('chart1');
google.visualization.events.addListener(图表1,'select',drillIn);
google.visualization.events.addListener(图表1,'点击',钻取);
图表1.绘图(集合[0],选项1);
函数drillIn(){
var sel=chart1.getSelection();
var row=chart1.getSelection()[0]。行;
options1['title']=集合[index].getValue(sel[0]。行,0);
如果(索引==0){
如果(行===0){
指数=1;
}
如果(行===1){
指数=2;
}
如果(行==2){
指数=3;
}
如果(行===3){
指数=4;
}
如果(行===4){
指数=5;
}
如果(行===5){
指数=6;
}
}
否则如果(索引==1 | |索引==2 | |索引==3 | |索引==4 | |索引==5 | |索引==6){
选项1['title']='中提供的服务';
指数=0;
}
图表1.绘图(集合[索引],选项1);
}
功能钻取(e){
如果(如targetID==“标题”){
如果(索引!==0)
索引--;
else if(index==4 | | index==6 | | index==8)
指数-=2;
图表1.绘图(集合[索引],选项1);
}
}
Html:


我已经找出了错误。所有这些在输入值之前都需要一个标题

修订守则:

        //Main
        var main = [
            ['Department', 'Value'],
            ['Cardiac Diagnostic Unit', <%=cdu%>],
            ['Laboratory Services', <%=ls%>],
            ['Physical Therapy and Rehabilitation', <%=ptr%>],
            ['Radiology', <%=rad%>],
            ['Operations', <%=oper%>]
        ];

        //Aku
        var akuu = [
            ['Service', 'Value'],
            ['Hemodialysis', <%=aku1%>],
            ['Peritoneal Dialysis', <%=aku2%>],
            ['Continuous Renal Replacement Therapy', <%=aku3%>],
            ['Sustained Low Efficient Dialysis', <%=aku4%>],
            ['Private Dialysis Suite', <%=aku5%>]
        ];

        //Cdu
        var cduu = [
            ['Service', 'Value'],
            ['Electrocardiography', <%=cdu1%>],
            ['Ambulatory Electrocardiography', <%=cdu2%>],
            ['Exercise Stress Test', <%=cdu3%>],
            ['2D Echo', <%=cdu4%>],
            ['Lower Extremity Arterial & Venous Color Duplex Scan', <%=cdu5%>],
            ['Carotid Artery Duplex Scan', <%=cdu6%>]
        ];

        //Ls
        var lss = [
            ['Service', 'Value'],
            ['Hematology', <%=ls1%>],
            ['Blood Chemistry', <%=ls2%>],
            ['Immunology and Serology', <%=ls3%>],
            ['Clinical Microscopy', <%=ls4%>],
            ['Microbiology', <%=ls5%>],
            ['Blood Bank and Transfusion Services', <%=ls6%>],
            ['Drug Testing', <%=ls7%>],
            ['Parasitology', <%=ls8%>],
            ['Surgical Pathology', <%=ls9%>],
            ['Cytopathology', <%=ls10%>]
        ];

        //Ptr
        var ptrr = [
            ['Service', 'Value'],
            ['Physical Therapy', <%=ptr1%>],
            ['Occupational Therapy', <%=ptr2%>],
            ['Ultrasound Diagnostic Therapy', <%=ptr3%>],
            ['Orthotics and Prosthetic Evaluation', <%=ptr4%>]
        ];

        //rad
        var radd = [
            ['Service', 'Value'],
            ['X-ray', <%=rad1%>],
            ['Ultrasound', <%=rad2%>],
            ['CT Scan', <%=rad3%>]
        ];

        //oper
        var operr = [
            ['Service', 'Value'],
            ['Surgery', <%=oper1%>]
        ];
//Main
var main=[
[“部门”、“价值”],
[‘心脏诊断单元’,],
[‘实验室服务’,],
[‘物理治疗和康复’,],
[‘放射学’,],
[‘操作’,]
];
//阿库
var akuu=[
[‘服务’、‘价值’],
[血液透析',],
[‘腹膜透析’,],
        //Main
        var main = [
            ['Department', 'Value'],
            ['Cardiac Diagnostic Unit', <%=cdu%>],
            ['Laboratory Services', <%=ls%>],
            ['Physical Therapy and Rehabilitation', <%=ptr%>],
            ['Radiology', <%=rad%>],
            ['Operations', <%=oper%>]
        ];

        //Aku
        var akuu = [
            ['Service', 'Value'],
            ['Hemodialysis', <%=aku1%>],
            ['Peritoneal Dialysis', <%=aku2%>],
            ['Continuous Renal Replacement Therapy', <%=aku3%>],
            ['Sustained Low Efficient Dialysis', <%=aku4%>],
            ['Private Dialysis Suite', <%=aku5%>]
        ];

        //Cdu
        var cduu = [
            ['Service', 'Value'],
            ['Electrocardiography', <%=cdu1%>],
            ['Ambulatory Electrocardiography', <%=cdu2%>],
            ['Exercise Stress Test', <%=cdu3%>],
            ['2D Echo', <%=cdu4%>],
            ['Lower Extremity Arterial & Venous Color Duplex Scan', <%=cdu5%>],
            ['Carotid Artery Duplex Scan', <%=cdu6%>]
        ];

        //Ls
        var lss = [
            ['Service', 'Value'],
            ['Hematology', <%=ls1%>],
            ['Blood Chemistry', <%=ls2%>],
            ['Immunology and Serology', <%=ls3%>],
            ['Clinical Microscopy', <%=ls4%>],
            ['Microbiology', <%=ls5%>],
            ['Blood Bank and Transfusion Services', <%=ls6%>],
            ['Drug Testing', <%=ls7%>],
            ['Parasitology', <%=ls8%>],
            ['Surgical Pathology', <%=ls9%>],
            ['Cytopathology', <%=ls10%>]
        ];

        //Ptr
        var ptrr = [
            ['Service', 'Value'],
            ['Physical Therapy', <%=ptr1%>],
            ['Occupational Therapy', <%=ptr2%>],
            ['Ultrasound Diagnostic Therapy', <%=ptr3%>],
            ['Orthotics and Prosthetic Evaluation', <%=ptr4%>]
        ];

        //rad
        var radd = [
            ['Service', 'Value'],
            ['X-ray', <%=rad1%>],
            ['Ultrasound', <%=rad2%>],
            ['CT Scan', <%=rad3%>]
        ];

        //oper
        var operr = [
            ['Service', 'Value'],
            ['Surgery', <%=oper1%>]
        ];