Not receiving dateRange objects via DSCC

I would like to use the dateRanges to limit the axis of my visual, but I am not receiving it.

According to the documentation, dscc subscribed data should have the following fields:

{ fields: object(fieldsByConfigId), style: object(styleById), interactions: object(interactionsById), theme: object(themeStyle), tables: object(tablesById), dateRanges: object(dateRangesById) }

When I check the object my custom visual is receiving, I do not get the dateRanges object. Anyone else having the same problem?

Upvotes: 1

Views: 62

Answers (1)

Andrey Ryzhkin
Andrey Ryzhkin

Reputation: 16

Pedro!

I just faced the same problem. This is absolutely crazy, but yes, by default we can't access "data ranges".

But the good news is that I found how to fix it!

We need to modify the code, that Google gives us with file dscc.min.js in their doc

I pushed the updated code and some explanations in my public repo here.

Or you can find this code:

...interactions: s(e)...`

and paste after it this:

...interactions: s(e), customDataRanges: Boolean(e.dataResponse.dateRanges) ? e.dataResponse.dateRanges : null

Pay attention, that you should do it twice:

  1. For objectTransform
  2. For tableTransform Or just take the file from my repo.

Pay attention 2, that you can access ranges with customDataRanges (not dataRanges), like this:

function drawViz(data) {
  console.log(data.customDataRanges);
}
dscc.subscribeToData(drawViz, { transform: dscc.tableTransform });

Hope my answer will help someone.

UPD: "Data Controls do not currently work with Community Visualizations", from here: https://developers.google.com/looker-studio/visualization/issues

Upvotes: 0

Related Questions