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

developing Custom Visual with Table Data Binding

$
0
0

I am slightly struggling with custom visual development. Any help is very appreciated.

Also asked this on stackoverflow.

 

 

I am trying to change the sampleBarChart visual to use the "table" data binding instead of "categorical". My first aim is to have a simple table visual, with inputs "X", "Y" and "Value".

 

This wiki page describes the table data binding, though I cannot find any example visuals which use it and are based on the new API. 1) Are there any examples of such visuals?

 

---

 

The wiki link above shows that a table object has properties "rows", "columns", "totals" and "identities". So it looks like rows and columns are my indexes and totals are my values?

 

My data roles:

 

        {   "displayName": "Category1 Data",
            "name": "category1",
            "kind": 0},
	{   "displayName": "Category2 Data",
            "name": "category2",
            "kind": 0},
        {   "displayName": "Measure Data",
            "name": "measure",
            "kind": 1}

 

Current data view mapping:

"table": {
	"rows": {"for": {"in": "category1"}},
	"columns": {"for": {"in": "category2"}},
	"totals": {"select": [{"bind": {"to": "measure"}}]}
	}

 

Relevant parts of my visualTransform():

    ...
let category1 = categorical.rows;
let category2 = categorical.columns;
let dataValue = categorical.totals;
    ...
for (let i = 0, len = category1.length; i < len; i++) {
for (let j = 0, jlen = category2.length; j < jlen; j++) {
	{
		barChartDataPoints.push({
			category1: i,
			category2: j,
			value: dataValue[i,j],
			color: "#555555"//for now
		});
	}
    ...

Test data looks like this:

  1 2 31 4 4 32 4 5 53 3 6 7 (total = 41)

 

The code above fills barChartDataPoints with just six data points:

(1; 1; 41),

(1; 2; undefined),

(2; 1; 41),

(2; 2; undefined),

(3; 1; 41),

(3; 2; undefined).

Accessing zero indeces results in nulls.

2) What am I doing wrong?

 

---

 

I don't have a PowerBI account, so have to compile visuals with 

pbiviz package

and import in PowerBI desktop to test. As a result, it's very difficult to debug non-compiler errors - in that case PowerBI displays empty space no matter what data I assign to the visual. As a workaround, I display "window.alert()" and pass it text data I want to view, but this takes a long time and is very limited.

3) What are some good practices of debugging visuals based on the new API? (Without having access to powerbi developer tools)

The PowerBI visual playground project seems to be using the old API.

 

Thanks in advance.


Viewing all articles
Browse latest Browse all 17897

Trending Articles



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