Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
robbieinoz
Frequent Visitor

Programattically access custom theme json file from custom visual code

I'm hoping someone can help me.

 

I'm developing a custom visual and in the code of the custom visual, I'd like to be able to import a custom theme's json file. I'm trying to expose the custom theme's properties to my custom visual's code. But at the moment, I have no idea how to "find" or "access" the theme json file directly from the code in my custom visual. 

 

Anyone have any ideas how to do this? Thanks in advance!

5 REPLIES 5
dm-p
Super User
Super User

Hi @robbieinoz - just curious... why wouldn't you configure your theme file with your custom visual properties so you (or users) can style it the conventional way?





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!


My course: Introduction to Developing Power BI Visuals


On how to ask a technical question, if you really want an answer (courtesy of SQLBI)




Hi @dm-p
Fair question. I'm trying to hack together a better license validation method that enables validation at the report level. Essentially I'm trying to replicate the approach I assume zoom charts is using for license validation. They create a custom theme file for each account, then ask the user to import the custom theme file which then enables validation.

I'm unsure exactly how they do it but I assume they store license key/hash information in custom theme file properties, then somehow access these theme properties from the custom visual to validate the user's license against their license server.

So essentially, I'd like to store information in the theme json file that isn't theme related, and then access that information from a custom visual. It feels like a hacky way of license validation, but it at least allows keys to be entered at the report level rather than in each instance of the custom visual.

Any help is greatly appreciated! Thanks!

Hi @robbieinoz ,

That's a pretty cool idea, and I've often wondered how a few vendors do it...I've considered how to implement license generation/validation for visuals (I notice that Zebra BI don't validate against an external server either so they probably have a similar mechanism) but it's something that isn't easy to discover, so I'm sticking with doing mine as open source for now 😛

The theme file is quite an interesting idea, particularly to manage at a report level.

If I had to take a guess at it, they'll probably have one or more objects in the capabilities that are hidden when the visual objects are enumerated, but can still have a default value provided via theme config, and this is how it's managed. This could then be obtained from the visual settings in the usual way.

I'm doing a massive update to one of my visuals and have put some effort into figuring out how to add styling to the theme, which may give you some assistance. This page is still in progress in a dev branch, but it might give you some ideas on how to populate a property via styling by adding your visual's ID to the file.

Not sure if it'll help, but I hope it does. Good luck!

Daniel

EDIT: corrected link to actual page in repo

 

 

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!


My course: Introduction to Developing Power BI Visuals


On how to ask a technical question, if you really want an answer (courtesy of SQLBI)




Thanks @dm-p I think you're on the right track here. I'll have a play and see what I can figure out and report back if I get it to work. I'm very new to custom themes however so it might take me some time to stumble through!

Hi @robbieinoz - sounds good! Feel free to get in touch if you want me to take a look or get stuck and I'll see if I can offer any further help.

Cheers,

Daniel





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!


My course: Introduction to Developing Power BI Visuals


On how to ask a technical question, if you really want an answer (courtesy of SQLBI)




Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.