Javascript 谷歌数据视图过滤

Javascript 谷歌数据视图过滤,javascript,google-visualization,Javascript,Google Visualization,我想建立一个网站,让用户输入他们想如何过滤谷歌可视化数据视图。除了输入,我所有的东西都在工作。用户输入他们希望如何将数据过滤到HTML输入框中,JavaScript接受输入并使用 new Function(input) input是包含用户输入的字符串的变量 前 此函数被放入setRows方法中。这就是它中断的地方,因为出于某种原因,求值字符串返回未定义的。 我的代码的外观示例: function filter(t) { //instantiate data view var

我想建立一个网站,让用户输入他们想如何过滤谷歌可视化数据视图。除了输入,我所有的东西都在工作。用户输入他们希望如何将数据过滤到HTML输入框中,JavaScript接受输入并使用

new Function(input)
input是包含用户输入的字符串的变量

此函数被放入setRows方法中。这就是它中断的地方,因为出于某种原因,求值字符串返回未定义的。 我的代码的外观示例:

function filter(t) {
    //instantiate data view
    var view = new google.visualization.DataView(data);

    // if query not empty, pass into 'new Function()' and then into 'setRows'
    // if I don't add "view" argument, it tells me that view is undefined if you have it in the query like the example
    if (t.rowQuery.value) {
        var rowQuery = new Function("view", t.rowQuery.value.split('/'));
        view.setRows(rowQuery(view));
    }

    // draw data view
    chart.draw(view, {allowHtml: true, showRowNumber: true});
}
我原本想使用谷歌的查询,但除了谷歌电子表格,我无法让它在任何其他来源上运行

function filter(t) {
    //instantiate data view
    var view = new google.visualization.DataView(data);

    // if query not empty, pass into 'new Function()' and then into 'setRows'
    // if I don't add "view" argument, it tells me that view is undefined if you have it in the query like the example
    if (t.rowQuery.value) {
        var rowQuery = new Function("view", t.rowQuery.value.split('/'));
        view.setRows(rowQuery(view));
    }

    // draw data view
    chart.draw(view, {allowHtml: true, showRowNumber: true});
}