oocharts将数组转换为字符串后无效的过滤器参数

时间:2013-11-13 09:40:52

标签: javascript google-analytics-api

我一直无法为oocharts设置动态过滤器。

我已经完成了一些事情,并创建了一个数组(scenefilters),我已经加入了这个数组。然后我尝试将其用作过滤器,它返回错误:

* JSONP.callbacks.request_63&& JSONP.callbacks.request_63({“error”:“无效的参数{filters}:过滤字符串的格式无效”}); *

现在,如果我将console.log变量'locationfilter2'并将其直接复制并粘贴到过滤器中,它可以正常工作 - 但它不适用于变量。我是否需要对变量执行其他操作以确保它是字符串?

    var locationfilter = scenefilters.join(",");
    var locationfilter2 = '"'+ locationfilter +'"';

    var visits = new oo.Metric("54190402", "12m");                  
    visits.setMetric("ga:visits");
visits.query.setFilter(locationfilter2);                                
    visits.draw(timeline);

修改

我已经尝试将变量输出到文本字段并从那里复制它,同样的事情。输出为“ga:pagePath = ~s101 $,ga:pagePath = ~s102 $,ga:pagePath = ~s103 $,ga:pagePath = ~s104 $,ga:pagePath = ~s105 $,ga:pagePath = ~s106 $,GA:PAGEPATH =〜S107 $,GA:PAGEPATH =〜S108 $,GA:PAGEPATH =〜S109 $,GA:PAGEPATH =〜S110 $,GA:PAGEPATH =〜S111 $,GA:PAGEPATH =〜S112 $, GA:PAGEPATH =〜S113 $,GA:PAGEPATH =〜S114 $,GA:PAGEPATH =〜S115 $,GA:PAGEPATH =〜S116 $,GA:PAGEPATH =〜S117 $,GA:PAGEPATH =〜S118 $,GA: PAGEPATH =〜S119 $,GA:PAGEPATH =〜S293 $,GA:PAGEPATH =〜S301 $“

如果我将其直接复制到过滤器中,即visits.query.setFilter(“ga:pagePath = ~s101 $,ga:pagePath = ~s102 $,ga:pagePath = ~s103 $,ga:pagePath =〜 S104 $,GA:PAGEPATH =〜S105 $,GA:PAGEPATH =〜S106 $,GA:PAGEPATH =〜S107 $,GA:PAGEPATH =〜S108 $,GA:PAGEPATH =〜S109 $,GA:PAGEPATH =〜S110 $ ,GA:PAGEPATH =〜S111 $,GA:PAGEPATH =〜S112 $,GA:PAGEPATH =〜S113 $,GA:PAGEPATH =〜S114 $,GA:PAGEPATH =〜S115 $,GA:PAGEPATH =〜S116 $,GA :PAGEPATH =〜S117 $,GA:PAGEPATH =〜S118 $,GA:PAGEPATH =〜S119 $,GA:PAGEPATH =〜S293 $,GA:PAGEPATH =〜S301 $“);

效果很好。但如果我使用变量,我会得到错误。任何想法?

1 个答案:

答案 0 :(得分:0)

好的傻瓜。删除了“”,它工作正常。