Forum Discussion
Problem using "d3-array".rollup (and it spread argument) in a Power BI Custom Visual
- 6 years ago
Hi Schizzomarino ,
Sorry, but I took a shot before trying it myself. But if I change the key attribute to ...key: any[] I can get your code working.
I do realise that the typing are a bit off now, but looks like TypeScript doesn't work correctly with this type of parameter binding.
But the most important thing: it compiles!
-JP
Hi Daniel dm-p ,
thanks for the reply. The reasons I don't do the grouping with dataViewMapping:
Reuse: The pbiviz libraries change so much with every new version, I prefer using d3's latest v5 version so I can reuse it in future projets while updating to the newest and best pbiviz library.
I would like to know how to remove limitations that d3V5 encounters in Power BI.
Many objects are needed as to animate the visual: This is only one of the many data munching processes I need to do, including ranking the data and creating before and after snapshots for animation. I fear using dataViewMapping would be a lot more complicated than 4 lines of code in d3.
Finally, I will be using this also on standalone webpage visualisations (to embed directly with data within webpages, with no Power BI) and would much rather use the same processes within the custom visualisation.
The output I am looking for here is an array of arrays, with the deepest arrays made up of a map (the original data:
[{"date":36526,"name":"Coca-Cola","category":"Beverages","value":72537},{"date": 36526,"name": "Microsoft","category": "Technology", "value":70196},...]
Should become, this (consider the date formatting here is of no consequence):
Thanks in advance for any guidance you may be able to provide
Dan
- v-evelk6 years agoMicrosoft Employee
Hi Dan,
"I would like to know how to remove limitations that d3V5 encounters in Power BI."
If you use the 3rd version of tools there cannot be any limitations for external libraries usage.
If you built your porject using the 2nd version of tools, there is an instruction how to migrate.
Kind Regards,
Evgenii Elkin,
Software Engineer
Microsoft Power BI Custom Visuals
[email protected]- Schizzomarino6 years agoAdvocate I
Thanks Evgenii v-evelk ,
I am using pbiviz 3.1.5 and have imported the rollup function from d3-array as such:
- import { rollup } from "d3-array"
(I have also installed the types for d3 and it)
- npm install --save @types/d3
- npm install --save @types/d3-array
And when only one key is used the rollup function works, it looks to me the problem resides in recognising and using the spread operator that is part of the arguments for rollup.
I am thinking it might be a typescript limitation rather than Power BI, but was hoping for a workaround that would allow me to use the data functions within d3 (rather than recoding them in typescript myself)
best,
Daniel
- jppp6 years agoContinued Contributor
Hi Schizzomarino ,
It looks to me that it is an issue with the current typedefinitions (@types/d3-array) as the current only accepts one key, see: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/cbcfdd4b12b863a82f5f1903c47fe22fa3b6975c/types/d3-array/index.d.ts#L245 There is already an issue reported, but with not much happening: https://github.com/DefinitelyTyped/DefinitelyTyped/issues/32162
This kind of errors are usually related to outdated typedefinitions used by TypeScript and you can easily update the current typedefiniton and add the missing '...'
-JP