Quantcast
Channel: Developer topics
Viewing all articles
Browse latest Browse all 18142

Custom Visual dataViewMappings Setting Up

$
0
0

I'm working on a project to generate a custom visual that is a matrix with 2 groups (x, y) and 2 measures. Bascially it's a heatmap were the color value is measure2 while the display value is measure1. I've been able to get it working using the basic Value Data Role. But when I tried swap it out for XAxis, YAxis, Measure1, and Measure2 data roles I can't get it to work. Below is the capabilities.json file but I can't figurout the how to setup the dataViewMappings. 

 

Here is an example of the data:

XAxis         YAxis         Measure1         Measure2          

Product1   State1       300                    105

Product2   State1       256                     75

Product1   State2       50                       15

 

 

{
  "dataRoles": [
    {
      "displayName": "Display Values",
      "kind": "Measure",
      "name": "measure1"
    },
    {
      "displayName": "Heat Values",
      "kind": "Measure",
      "name": "measure2"
    },
    {
      "displayName": "X Axis.",
      "kind": "Grouping",
      "name": "xAxis"
    },
    {
      "displayName": "Y Axis.",
      "kind": "Grouping",
      "name": "yAxis"
    }
  ],
  "dataViewMappings": [
    {
      "conditions": [
        {
          "measure1": {
            "max": 1
          },
          "measure2": {
            "max": 1
          },
          "xAxis": {
            "max": 1
          },
          "yAxis": {
            "max": 1
          }
        }
      ],
      "scriptResult": {
        "dataInput": {
          "table": {
            "rows": {
              "select": [
                { "for": { "in": "measure1" } },
                { "for": { "in": "measure2" } },
                { "for": { "in": "xAxis" } },
                { "for": { "in": "yAxis" } }
              ],
              "dataReductionAlgorithm": {
                "top": {}
              }
            }
          }
        },
        "script": {
          "scriptProviderDefault": "R",
          "scriptOutputType": "html",
          "source": {
            "objectName": "rcv_script",
            "propertyName": "source"
          },
          "provider": {
            "objectName": "rcv_script",
            "propertyName": "provider"
          }
        }
      }
    }
  ],
  "objects": {
    "rcv_script": {
      "properties": {
        "provider": {
          "type": {
            "text": true
          }
        },
        "source": {
          "type": {
            "scripting": {
              "source": true
            }
          }
        }
      }
    }
  },
  "suppressDefaultTitle": true
}

 


Viewing all articles
Browse latest Browse all 18142

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>