Google AnalyticsAPI - 是否有多个查询可能? [英] Google Analytics API - Are multiple queries possible?

查看:109
本文介绍了Google AnalyticsAPI - 是否有多个查询可能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想生成一个API调用,如下所示:

I would like to generate an API call that looks as follows:

var dataChart5 = new gapi.analytics.googleCharts.DataChart({
    query:
    [
        {
        metrics: 'ga:totalEvents',
        dimensions: 'ga:date',
        'start-date': beginDate,
        'end-date': endDate,
        filters: 'ga:eventAction==Search;ga:eventCategory==Company'
        },
        {
        metrics: 'ga:totalEvents',
        dimensions: 'ga:date',
        'start-date': beginDate,
        'end-date': endDate,
        filters: 'ga:eventAction==Search;ga:eventCategory==Accommodation'
        }
    ],
    chart: {
        container: 'chart5-container',
        type: 'LINE',
        options: {
            width: '100%'
        }
    }
});

您会注意到图表生成了两个查询。当我执行此操作时,不会呈现任何内容。这告诉我,语法是错误的,或者我试图做的不支持。是这样的吗?

You'll notice there are two queries being generated for the chart. When I execute this, nothing is rendered. This tells me either the syntax is wrong or what I'm trying to do isn't supported. Is something like this possible?

推荐答案

不,您要求的嵌入API无法实现。如果您检查文档, DataChart 组件,您将会看到 query 选项,其中 Object 不是一个数组

No, what you're asking is not possible with the Embed API. If you check the documentation for the DataChart component you'll see the query option takes an Object not an Array.

要做你想做的事,你必须使用 Data 组件,然后自己渲染图表。

To do what you want, you'd have to make two queries using the Data component and then render the chart yourself.

这篇关于Google AnalyticsAPI - 是否有多个查询可能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆