-
Notifications
You must be signed in to change notification settings - Fork 463
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.
For a definition of IFilter please see Filters Wiki page. For a definition of IVisualLayout please see Custom layout Wiki page.
interface ICloneVisualRequest {
// The filters which will be applied to the new visual. Default: source visual filters.
filters?: IFilter[];
// The layout which will be applied to the new visual.
// Default: a best effort to put a new visual in an empty space on the canvas.
layout?: IVisualLayout;
// Focus on the new visual after creation.
// Default: true.
autoFocus?: boolean;
}
interface ICloneVisualResponse {
// New visual name
visualName: string;
}
Visual object has a method called clone which is defined as:
clone(request: models.ICloneVisualRequest = {}): Promise<ICloneVisualResponse>
To get a list of visual on a report please see Get-Visuals Wiki.
Clone a visual as is. The new position and size of the new visual will be a best effort to put a visual on an empty space on the canvas. If you want a specific position and size, please see second example.
visual.clone()
.then(function (result) {
console.log(result.name);
})
.catch(function (errors) {
console.log(errors);
});
Clone a visual with new layout without focusing on it.
let cloneRequest = {
layout: { x: 150, y: 250 },
autoFocus: false
};
visual.clone(cloneRequest)
.then(function (result) {
console.log(result.name);
})
.catch(function (errors) {
console.log(errors);
});
Clone a visual with new layout and a new list of visual level filters.
const basicFilter: pbi.models.IBasicFilter = {
$schema: "http://powerbi.com/product/schema#basic",
target: {
table: "Store",
column: "Count"
},
operator: "In",
values: [1,2,3,4],
filterType: pbi.models.FilterType.BasicFilter
};
let cloneRequest = {
layout: { x: 150, y: 250 },
filters: [basicFilter]
};
visual.clone(cloneRequest)
.then(function (result) {
console.log(result.name);
})
.catch(function (errors) {
console.log(errors);
});
-
You can clone a visual only if the report is fully rendered. That means you need to wait on 'rendered' event before calling clone visual API.
-
You can clone a visual from any page in the report to the active page.