2013-10-11 3 views
0

'객체 유형이 열 유형과 일치하지 않습니다.'라는 오류가 발생하고 확실하지 않은 이유가 무엇인지 ... 확실하지 않습니다. 내 코드에 오류가 있거나 대시 보드. 내 오류는 데이터 소스와 관련이 있으며 스프레드 시트에서 데이터를 가져 오는 방법이라고 생각합니다.대시 보드에 StackPanel

function doGet() { 
    var app = UiApp.createApplication().setTitle('DHS: Kurzweil Calendar'); 

    //Create stack panel 
    var stackPanel = app.createStackPanel().setSize('100%', '100%'); 
    var info = about(app); 
    var p1 = app.createVerticalPanel().setId('vrtPanel1').add(info); 
    var cal = calendar(app); 
    var p2 = app.createVerticalPanel().setId('vrtPanel2').add(cal); 
    var form = formBuild(app); 
    var p3 = app.createVerticalPanel().setId('vrtPanel3').add(form); 

    //add widgets to each stack panel, and name the stack panel 
    stackPanel.add(p1, 'About the Lab'); 
    stackPanel.add(p2, 'Lab Calendar'); 
    stackPanel.add(p3, 'Lab Scheduling'); 

    //Add the panel to the application 
    app.add(stackPanel); 
    return app; 
} 

function about(app){ 
    return app.createHTML('<br />' + 
         '<p>The Kurzweil Lab at Davie High School supports <i>20 independent student workstations</i> and is designed for the specific use of Kurzweil software. The lab\'s main objective is to support students who have a Read-Aloud accommodation on their Individual Education Plan (IEP). If a student does not have a Read-Aloud accommodation, but has another accommodation like: Separate Setting, Extended Time, or English as a Second Language (ESL) then they are welcome in the lab as long as the lab is not full. If the lab reaches capacity and Read-Aloud students need to use Kurzweil, the student(s) without a Read-Aloud accommodation or who are refusing their Read-Aloud accommodation will be asked to go back to their classroom so that the teacher can make other arrangements for that student.</p>' + 
         '<p>During non-testing situations the Kurzweil Lab can be scheduled by EC teachers to help with study skills, individual projects, or other work that requires the use of a computer lab.</p>', true); 
} 

function calendar(app){ 
    // Create Data Source 
    var ss = SpreadsheetApp.openById('0Aur3owCpuUY-dGJIOGZ1LXhqT2FNMGVXSGNJazFnUmc'); 
    var datasource = ss.getSheetByName('Schedule').getRange(1,1,ss.getLastRow(),ss.getLastColumn()); 

    // Create Charts and Controls 
    var dateFilter = Charts.newCategoryFilter() 
     .setFilterColumnLabel("Date").build(); 
    var teacherFilter = Charts.newCategoryFilter() 
     .setFilterColumnLabel("Teacher").build(); 
    var subjectFilter = Charts.newCategoryFilter() 
     .setFilterColumnLabel("Subject").build(); 
    var periodFilter = Charts.newCategoryFilter() 
     .setFilterColumnLabel("Period").build(); 
    var typeFilter = Charts.newCategoryFilter() 
     .setFilterColumnLabel("Type").build(); 
    var tableChart = Charts.newTableChart().build(); 

    //Create and bind Dashboard 
    var dashboard = Charts.newDashboardPanel() 
     .setDataTable(datasource) 
     .bind([dateFilter, teacherFilter, subjectFilter, periodFilter, typeFilter], [tableChart]) 
     .build(); 

    //Create Application 
    dashboard.add(app.createVerticalPanel() 
       .add(app.createHorizontalPanel() 
        .add(dateFilter).add(teacherFilter).add(subjectFilter).add(periodFilter).add(typeFilter) 
        .setSpacing(70)) 
       .add(app.createHorizontalPanel() 
        .add(tableChart) 
        .setSpacing(10))); 

    //Add the panel to the application 
    app.add(dashboard); 
    return app; 
} 

답변

0

당신은 단순히 당신이 UI를 구축 모든 기능은 데이터를 반환 ... 당신이 your first post about stackPanels을 기억한다면 우리가

var p2 = app.createVerticalPanel().setId('vrtPanel2').add(cal); 
다음

var cal = calendar(app); 

에 전화를 변경하고 방식을 변경 잊었다

우리는 대가로 Ui 객체 (위젯)를 얻을 것으로 예상합니다.

당신은 간단하게 다음과 같이 function calendar(app){의 끝을 변경할 수 있습니다

... 
    dashboard.add(app.createVerticalPanel() 
       .add(app.createHorizontalPanel() 
        .add(dateFilter).add(teacherFilter).add(subjectFilter).add(periodFilter).add(typeFilter) 
        .setSpacing(70)) 
       .add(app.createHorizontalPanel() 
        .add(tableChart) 
        .setSpacing(10))); 

    //Add the panel to the application 
    return dashboard;// return the dashboard itself, not the app. 
} 

편집 :이 사실로 간단한에 확실히했다 ... 내 대답은 포함되지 않았다 분명 정확하지만, 대시 보드 건물 문제. 몇 가지 연구 후

(내가 전에 차트 서비스를 사용한 적이) 나는 오류를 생성하지 않습니다이 코드에 들어 왔지만 나는 확실히 당신이 원하는 것을 반환 모르겠어요 ...

그럼에도 불구하고

이 도움이 될 것입니다 너는 너의 길을 찾으러. 이 ;-) 잘 보이지 않는 경우 (저를 비난하지 않는다

function calendar(app){ 
    // Create Data Source 
    var ss = SpreadsheetApp.openById('0Aur3owCpuUY-dGJIOGZ1LXhqT2FNMGVXSGNJazFnUmc'); 
    var sh = ss.getSheetByName('Schedule'); 
    var datasource = sh.getRange(1,2,sh.getLastRow(),sh.getLastColumn()).getValues(); 
    Logger.log(datasource) 
    var dataTable = Charts.newDataTable(); 
    for(var j in datasource[0]){ 
    dataTable.addColumn(Charts.ColumnType.STRING, datasource[0][j]); 
    } 
    for(var i = 1; i < datasource.length; ++i){ 
    dataTable.addRow(datasource[i].map(String)); 
    } 
var dashboard = Charts.newDashboardPanel().setDataTable(dataTable); // Create Charts and Controls 
    var dateFilter = Charts.newCategoryFilter() 
     .setFilterColumnLabel("Date").setDataTable(dataTable).build(); 
    var teacherFilter = Charts.newCategoryFilter() 
     .setFilterColumnLabel("Teacher").setDataTable(dataTable).build(); 
    var subjectFilter = Charts.newCategoryFilter() 
     .setFilterColumnLabel("Subject").setDataTable(dataTable).build(); 
    var periodFilter = Charts.newCategoryFilter() 
     .setFilterColumnLabel("Period").setDataTable(dataTable).build(); 
    var typeFilter = Charts.newCategoryFilter() 
     .setFilterColumnLabel("Type").setDataTable(dataTable).build(); 
    var tableChart = Charts.newTableChart().setDimensions(1000, 600).setDataTable(dataTable).build(); 

    //Create and bind Dashboard 
    var dashboard = Charts.newDashboardPanel() 
     .setDataTable(dataTable) 
     .bind([dateFilter, teacherFilter, subjectFilter, periodFilter, typeFilter], [tableChart]) 
     .build(); 

    //Create Application 
    var dashBoardPanel = app.createVerticalPanel() 
    dashBoardPanel.add(app.createHorizontalPanel() 
        .add(dateFilter).add(teacherFilter).add(subjectFilter).add(periodFilter).add(typeFilter) 
        .setSpacing(30)); 
    dashBoardPanel.add(tableChart); 

    //Add the panel to the application 
    return dashBoardPanel; 
} 

편집 2 : 당신이 약간 dataTables을 채우는 for loops을 수정해야 할 날짜로 첫 번째 열을 얻을 수 두 번째 열에서만 문자열로 변환 할 수 있습니다.

나는 이런 식으로했다 ". 개체 유형은 열 유형과 일치하지 않습니다"

function calendar(app){ 
     // Create Data Source 
     var ss = SpreadsheetApp.openById('0Aur3owCpuUY-dGJIOGZ1LXhqT2FNMGVXSGNJazFnUmc'); 
     var sh = ss.getSheetByName('Schedule'); 
     var datasource = sh.getRange(1,1,sh.getLastRow(),sh.getLastColumn()).getValues(); 
     Logger.log(datasource) 
     var dataTable = Charts.newDataTable(); 
     dataTable.addColumn(Charts.ColumnType.DATE, datasource[0][1]); 
     for(var j=2 ;j< datasource[0].length ;++j){ 
     dataTable.addColumn(Charts.ColumnType.STRING, datasource[0][j]); 
     } 
     for(var i = 1; i < datasource.length; ++i){ 
     var datarow = []; 
     datarow.push(datasource[i][1]); 
     for(var j=2 ;j< datasource[0].length ;++j){ 
      datarow.push(datasource[i][j].toString()); 
     } 
     dataTable.addRow(datarow); 
     } 
     var dashboard = Charts.newDashboardPanel().setDataTable(dataTable); // Create Charts and Controls 
      ... 

enter image description here

+0

나는군요 동적 스프레드 시트의 모든 데이터를 반환하려면 어떻게해야합니까? –

+0

SS에 액세스 할 수 없기 때문에 더 테스트 할 수 없습니다. 아마 다른 유형의 데이터 나 차트 자체를 기대하는 필터 함수 일 수 있습니다. 아마도 데이터를 설명하고 보여줄 수 있습니까? ID가 0 인 문서를 열지 못했습니다. 0Aur3owCpuUY-dGJIOGZ1LXhqT2FNMGVXSGNJazFnUmc : 요청한 문서에 액세스 할 수있는 권한이 없습니다. –

+0

지금 접속할 수 있어야합니다 ... 알려주지 않으면 다른 것을 시도 할 것입니다. –

관련 문제