Skip to content

Commit fc1d75b

Browse files
committed
Docuemnted the API reference
1 parent ad411ed commit fc1d75b

1 file changed

Lines changed: 62 additions & 4 deletions

File tree

README.md

Lines changed: 62 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,66 @@ yourself with the `gapi.analytics` namespace.
133133

134134
#### Props
135135

136-
| Name | Type | Default | Optional | Description |
137-
| ------------------ | ------ | --------- | -------- | --------------- |
138-
| `accessToken` | string | undefined | No\* | Access token to |
139-
| authroize the user |
136+
| Name | Type | Default | Optional | Description |
137+
| ------------------------ | -------------------- | --------- | -------- | ------------------------------------------------------------------------------------- |
138+
| `accessToken` | string | undefined | No\* | Access token to authroize the user |
139+
| `onReady` | callback, `()=>void` | undefined | Yes | Fired once the Google platform script loaded and gapi is ready to use. |
140+
| `onAuthenticated` | callback, `()=>void` | undefined | Yes | Fired once the Google Analytics API authenticated the access token |
141+
| `scopes` | array, `string[]` | undefined | Yes | Additional scopes to include |
142+
| `overwriteDefaultScopes` | boolean | false | Yes | Overwrite the scopes passed when generating the access token with the provided scopes |
143+
| `children` | `JSX.Element` | N/A | No | Child elements of the application to render inside the provider |
144+
145+
### ViewSelector
146+
147+
This is the react implementation of the [View
148+
Selector](https://developers.google.com/analytics/devguides/reporting/embed/v1/component-reference#viewselector).
149+
Users can select their Google Analytics view from the select boxes. Then
150+
you will be notified by the `onChange` callback.
151+
152+
#### Props
153+
154+
| Name | Type | Default | Optional | Description |
155+
| ----------- | ----------------------------- | --------- | -------- | --------------------------------------------------------------------------------------------------------------------------------- |
156+
| `onChange` | callback, `(string)=>void` | undefined | Yes | Fired at the component initialization time and the user changed the view. The first argument is the view id in `ga:xxxxx` format. |
157+
| `children` | `JSX.Element` | undefined | Yes | An optional placeholder to show until the gapi is being ready |
158+
| `style` | object, `React.CSSProperties` | undefined | Yes | CSS styles to pass to the container element. |
159+
| `className` | string | undefined | Yes | Class name to pass to the container element |
160+
161+
### DataChart
162+
163+
`GoogleAnalyticsLineChart`, `GoogleAnalyticsBarChart`,
164+
`GoogleAnalyticsColumnChart`, `GoogleAnalyticsGeoChart`,
165+
`GoogleAnalyticsPieChart` , `GoogleAnalyticsTable` components will help
166+
you to visualize the Google Analytics Data by using the
167+
`google.visualization` API. All of those components extended to the same
168+
`DataChart` component and the props are common for all components.
169+
170+
#### Props
171+
172+
| Name | Type | Default | Optional | Description |
173+
| ----------- | ------------------------------ | --------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
174+
| `query` | object, `gapi.analytics.Query` | N/A | No | Refer the [Google Core Reporting API](https://developers.google.com/analytics/devguides/reporting/core/v3/reference#q_summary) for more details about the properties and filterations. |
175+
| `children` | `JSX.Element` | undefined | Yes | An optional placeholder to show until the gapi is being ready |
176+
| `style` | object, `React.CSSProperties` | undefined | Yes | CSS styles to pass to the container element. |
177+
| `className` | string | undefined | Yes | Class name to pass to the container element |
178+
| `onSuccess` | callback, `(object)=>void` | undefined | Yes | Fired when the chart successfully rendered and the Reporting API call success. First argument is a response object that returning from Reporting API. Check this [page](https://developers.google.com/analytics/devguides/reporting/core/v3/reference#data_response) for more details. |
179+
| `onError` | callback, `(object)=>void` | undefined | Yes | Fired when an error occured during the rendering the chart or a error response received from the Reporting API. The first argument contains the error object. Refer this [page](https://developers.google.com/analytics/devguides/reporting/core/v3/errors) for more details about error response object. |
180+
| . . . | object | undefined | Yes | Google Chart options depending on the chart type. Refer the [Google Charts Guides](https://developers.google.com/chart/interactive/docs) to get a knowledge about options needed for different chart types. |
181+
182+
### Data
183+
184+
This is the implementation for
185+
[Data](https://developers.google.com/analytics/devguides/reporting/embed/v1/component-reference#data)
186+
component. We implemented it as a helper method to fetch Reporting data
187+
manually.
188+
189+
```
190+
fetchData(query: Query): Promise<SuccessResponse>
191+
```
192+
193+
This method will return a Promise which resolve when the Reporting API
194+
returned a [success response](https://developers.google.com/analytics/devguides/reporting/core/v3/reference#data_response).
195+
And it will be rejected if the Reporting API returned an [error
196+
response](https://developers.google.com/analytics/devguides/reporting/core/v3/errors).
197+
This method will take a [query](https://developers.google.com/analytics/devguides/reporting/core/v3/reference#q_summary) as the only argument.
140198

0 commit comments

Comments
 (0)