Forum Discussion

ShivGC's avatar
ShivGC
Helper I
3 years ago
Solved

Deneb Visual Zooming

Hi,  I required some help with making my non-linear regression graph, zoom-able.  I am using the deneb visual app on power bi and I have managed to create a scatterplot using the X Field and Y ...
  • ShivGC's avatar
    3 years ago

    I have Figured out the solution to this and will paste the code below for anyone who would like to try mimic this.

    Essentially, you are able to make a regression graph and make it zoomable but you just have to code within the same Layer ("layer" function). Please take a look below, at the code:

    {
      "data": {"name": "dataset"},
      "layer": [
        {
          "mark": {
            "type": "point",
            "filled": true
          },
          "encoding": {
            "x": {
              "field": "X FIELD",
              "type": "quantitative",
              "axis": {"format": "%"}
            },
            "y": {
              "field": "Y FIELD",
              "type": "quantitative",
              "axis": {"format": "%"}
            },
            "color": {
              "field": "CLIENT COLOUR FIELD - IF THIS IS NOT APPLICABLE TO YOU, PLEASE TAKE IT OUT",
              "type": "nominal",
              "legend": null,
              "scale": {
                "range": [
                  "#006D9E",
                  "#A6E2EF"
                ]
              }
            }
          }
        },
        {
          "mark": {
            "type": "line",
            "color": "black"
          },
          "transform": [
            {
              "regression": "Y FIELD",
              "on": "X FIELD",
              "method": "pow"
            }
          ],
          "encoding": {
            "x": {
              "field": "X FIELD",
              "type": "quantitative"
            },
            "y": {
              "field": "Y FIELD",
              "type": "quantitative"
            }
          }
        },
        {
          "transform": [
            {
              "regression": "Y FIELD",
              "on": "X FIELD",
              "params": true,
              "method": "pow"
            }
          ],
          "mark": "circle",
          "encoding": {
            "x": {
              "field": "X FIELD",
              "type": "quantitative"
            },
            "y": {
              "field": "Y FIELD",
              "type": "quantitative"
            }
          },
          "params": [
            {
              "name": "grid",
              "select": "interval",
              "bind": "scales"
            }
          ]
        }
      ]
    }