Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!
Hi,
I am working on a Custom Visual where I want to be able to select and apply a color for each category in my dataset. I managed to display ColorPalletes for each of the categories in the formatting options. After selecting colors in the ColorPalletes for the categories,
the color is not reflected immediately in the graph. I can see in the console output that the color selections are being saved in the viewmodel within the program but the colors do not change in the developer visual even though it is set on auto reload. I have to stop auto reload and reload again to see the new color selection I have made. I have added screenshots of the output and the code for reference.Capabilitites.json
Solved! Go to Solution.
Hi @Anonymous,
Your viewModel and property enumeration are both fine. The issue is that the selection.enter() method only works for elements that need to be added to the DOM. Reloading the visual will clear the DOM so the selection.enter() method has to run again and re-create, so your colour values will be correct in these cases.
You can resolve by adding a selection.update() method to your d3 data join, to ensure your viewModel is re-bound to existing elements when the visual's update method runs.
I'm on leave at present so not able to provide a specfic solution until next week sometime but you can check the approach we applied in this post, or look at the enter-update-exit pattern for d3 and this should provide examples that you could apply here.
Good luck!
Daniel
Proud to be a Super User!
On how to ask a technical question, if you really want an answer (courtesy of SQLBI)
Hi @Anonymous ,
Please review the following threads, hope they can help you resolve the problem.
.json and custom visuals with power bi theme possible?
Create Custom visuals - Set measure color
Best Regards
Thank you @Anonymous for your reply. I appreciate your help, but these threads do not quite address the problem I am facing. Thank you again.
Hi @Anonymous,
Your viewModel and property enumeration are both fine. The issue is that the selection.enter() method only works for elements that need to be added to the DOM. Reloading the visual will clear the DOM so the selection.enter() method has to run again and re-create, so your colour values will be correct in these cases.
You can resolve by adding a selection.update() method to your d3 data join, to ensure your viewModel is re-bound to existing elements when the visual's update method runs.
I'm on leave at present so not able to provide a specfic solution until next week sometime but you can check the approach we applied in this post, or look at the enter-update-exit pattern for d3 and this should provide examples that you could apply here.
Good luck!
Daniel
Proud to be a Super User!
On how to ask a technical question, if you really want an answer (courtesy of SQLBI)
The Power BI Data Visualization World Championships is back! It's time to submit your entry.
| User | Count |
|---|---|
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 1 |
| User | Count |
|---|---|
| 6 | |
| 5 | |
| 4 | |
| 4 | |
| 3 |