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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Marco57
Helper III
Helper III

BUG Clone visual API does not create independent visual

Hello all,

 

I need to clone an existing empty visual instead of creating a new one as we are limited on what we can customize as visual properties from the API side (can't change data color for instance).

I need to clone multiple versions of this visual with different filters/properties.

 

My issue is that each time I clone the visual and modify its dataFields, previously cloned visuals are also having those dataFields added. Actually this means clone method is not making a deep copy but only a shallow copy which is not the behaviour desscribed in the documentation:

https://github.com/Microsoft/PowerBI-JavaScript/wiki/Clone-Visual

"Use clone visual API to clone a specific visual into active page. It's helpful when you want to create copies of one visual with different filters or different layout."

 

This is very limiting as this is the only way for me to create visuals that would be customized upfront to compensate for lack of properties available from the API side.

 

Am I missing something? Is there any workaround?

 

Many thanks in advance.

Rgds,

Marc.

 

5 REPLIES 5
Anonymous
Not applicable

HI @Marco57,

As the document mentioned, this clone function will receive the filter effects and visual layout(size, locations). It did not directly get the corresponding data fields that use in target visual designs.

According to your descriptions, it seems like you want to get different filter effects to dynamically change the visual designs.

For this requirement, I think you need to do some customization with its render to initiation function to force refresh the current layout and render new styles if possible. (BTW, I check the document but found they are packaged functions and not support any parameters so you can't custom their processing)

Regards,
Xiaoxin Sheng

Hi @Anonymous ,

 

Thanks for your answer. The clone function is indeed not expecting dataFields input but its aim is to be able to clone separate visuals so you could modify them independently. It is not explained by the documentation that all the cloned visuals would effectively be sharing all same dataFields.

 

It is very limiting that cou can't edit your visual once cloned, it is one of the purpose of cloning actually.

 

From your last part, should I get that there are actually no means at all to clone a visual and customize it expcet regarding it filters and layout? ( which is very poor to be honest from an API point of view).

 

Thanks,

Rgds.

Marc.

Anonymous
Not applicable

Hi @Marco57,

>>From your last part, should I get that there are actually no means at all to clone a visual and customize it expcet regarding it filters and layout? ( which is very poor to be honest from an API point of view).

It sounds like my description makes you confused with use these functions. They mean the 'render'/'onload' functions not include parameters, so you can't directly send parameters to them. 

It does not mean you can't interact with them, you can refer to the following link to add some processing to do custom after the function finished.

How to handle events 

report.on('loaded', function(event)
{
    reportPages = await report.getPages();
});

The clone visual contents are processed by clone function internal, I haven't found they share any official interface or parameters of 'visual object' that allow you to customize. (so if these visual objects are designed with singleton mode, it may cause the issue that you mention)

For this scenario, maybe you need to check the visual class and manually to processing with its contents.

Visual class | Microsoft Docs

Regards,

Xiaoxin Sheng

@Anonymous 

Thanks for the follow up.

 

I understand there are no means/workaround to duplicate a visual and edit it by our means except when this editing concerns filtered content/layout.

 

Well this is awfully limiting its usage, on the desktop you can simply do ctrl+c, ctrl+v and with the full API this is even not possible.

 

Thanks.

Rgds,

Marc.

Anonymous
Not applicable

Hi @Marco57,

Yes, current APIs not released some interfaces so they may limit the advanced operations and usages.
Maybe you can submit the idea to add more features that allow advanced operations with API and power bi contents.
Regards,

Xiaoxin Sheng

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.