Don't miss your chance to take the Fabric Data Engineer (DP-700) exam on us!
Learn moreWe've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now
Im struggling to understand the following code because i dont know which function sends/gets which paramaters from where and why:
pbi.dsv (
function(letters) { x.domain(letters.map(function(d) { return d.letter; })); y.domain([0, d3.max(letters, function(d) { return d.frequency; })]); svg.append("g")
... }
);
The object:
var pbi = {
width:1200,
... ,
dsv:function(accessor, callback) {
data = [ ... ];
if (arguments.length > 2) {
callback=accessor,accessor = null;
} else {
data = data.map(function(d) {return accessor(d)});
}
callback(data);
}
}
So which function is called first?
I know that pbi.dsv(...) calls the function from the object pbi.dsv:function (accessor, callback) { ... } and also retrieves the data from it.
But from where the parameters accessor and callback are filled? Does it get the data from PowerBI itself?
What exactly happens in this step. Which data fills the variable letters? Is it the result of pbi.dsv:function (accessor, callback) { ... }?
pbi.dsv(function(letters) { ... });
I couldnt find any documentation which explains this kind of functions to me and how they exactly work. I only understand that this would for example show an alert with the message "Hello". But still doesnt get how they work when parameters are filled inside the functions head.
var obj = {
test: function() {
alert('Hello');
}
};
obj.test();
I would thank You very much if you can explain me the syntax or a good website which explains it.
Solved! Go to Solution.
The dsv function will execute accessor first for each item of original data array.
After that, the callback will be executed. The callback will receive the data array.
Ignat Vilesov,
Software Engineer
Microsoft Power BI Custom Visuals
The dsv function will execute accessor first for each item of original data array.
After that, the callback will be executed. The callback will receive the data array.
Ignat Vilesov,
Software Engineer
Microsoft Power BI Custom Visuals
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |