'Google Data Studio - Creating your own visualization - config.json problem

My problem is the index.json

{
  "data": [
    {
      "id": "concepts",
      "label": "Fields",
      "elements": [
        {
          "id": "dim",
          "label": "label, quadrant, ring, link, active, moved",
          "type": "DIMENSION",
          "options": {
            "min": 6,
            "max": 6
          }
        }
      ]
    }
  ],
  "style": [

    ...here is unrelated code...

    {
      "id": "offsets",
      "label": "Legend-Offset in pixel",
      "elements": [
        {
          "id": "offset_0",
          "label": "Offset_0 (-500 to 500)",
          "type": "INTERVAL"
        },
        {
          "id": "offset_1",
          "label": "Offset_1 (-500 to 500)",
          "type": "INTERVAL"
        },
        {
          "id": "offset_2",
          "label": "Offset_2 (-500 to 500)",
          "type": "INTERVAL"
        },
        {
          "id": "offset_3",
          "label": "Offset_3 (-500 to 500)",
          "type": "INTERVAL"
        }
      ]
    }
  ]
}

In the config reference it's said, that an interval needs to have this form:

  • INTERVAL Renders an interval selector. Values are integers. NUMBER NUMBER 0

And should have an options object.

This means the elements of style should look like that:

{
          "id": "offset_3",
          "label": "Offset_3 (-500 to 500)",
          "type": "INTERVAL", 
          "defaultValue": 0,
          "options": {
             "min": -500,
             "max": 500
          }
}

And that is how the dscc-scripts validation wants it to look like:

{
      "id": "offset_3",
      "label": "Offset_3 (-500 to 500)",
      "defaultValue": "0",
      "type": "TEXTINPUT"
}

Sadly doing the "should be" blows up the dscc-scripts, with errors telling me, that there should be no options and that defaultValue needs to be a string.

Well, doing it as seen in the last code snip fixes this problem and I can indeed build and push my code to the google storage bucket, sadly that won't help me at all as now Data Studio (Browser) blows out errors, telling me that "interval" values need to be of type numbers.

Any idea as how to fix that?



Solution 1:[1]

You can add widgets (and layouts) dynamically to any layout. Just create instance and call addWidget()

button = QPushButton()
ui.some_layout.addWidget(button)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 mugiseyebrows