cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
jgreg14 Visitor
Visitor

Custom Layout Live Demo - Hiding Visuals

Hi all,

 

Looking to see if anyone can help with hiding visuals using checkboxes as per:

https://microsoft.github.io/PowerBI-JavaScript/demo/v2-demo/index.html#

 

I have it up and running so that the checkbox changing triggers an event which triggers the following code. However the new values for the displaystate is not passed in when using the updatesettings()

 

What am i missing to enable the visuals to hide.

 

thanks

 

 

//render the values
function renderVisuals() {

// render only if report and visuals initialized
if (!report || !layoutVisuals)
return;

// Get models. models contains enums that can be used

 

// Filter the visuals list to display only the checked visuals
let checkedVisuals = layoutVisuals.filter(function (visual) { return visual.checked; });
let uncheckedVisuals = layoutVisuals.filter(function (visual) { return visual.unchecked; });
//console.log(layoutVisuals);
//console.log(checkedVisuals);
//console.log(uncheckedVisuals);
let visualsLayout = {};

 

//for (let i = 0; i < checkedVisuals.length; i++) {
//visualsLayout[uncheckedVisuals[i].name] = {
//displayState: {

// Change the selected visuals display mode to visible
//mode: models.VisualContainerDisplayMode.Hidden
//}
//}
//}

for (let i = 0; i < uncheckedVisuals.length; i++) {
visualsLayout[uncheckedVisuals[i].name] = {
//layout: {
x: 10,
y: 10,
//}
//displayState: {

//Change the selected visuals display mode to visible
//mode: models.VisualContainerDisplayMode.Hidden
//}

}
console.log(visualsLayout[uncheckedVisuals[i].name]);
}
console.log('visualsLayout')
console.log(visualsLayout)
console.log(currentPage)

// Building pagesLayout object
let pagesLayout = {};
pagesLayout[currentPage]= {
defaultlayout: {
displayState: {

// Default display mode for visuals is hidden
mode: models.VisualContainerDisplayMode.Hidden

}

},
visualsLayout: visualsLayout
};

// Building settings object
let settings = {
//pagesLayout: pagesLayout
//filterPaneEnabled: true,
layoutType: models.LayoutType.Custom,
//customLayout: {
//displayOption: models.DisplayOption.FitToPage,
pagesLayout: pagesLayout,
//filterPaneEnabled: true,

//}

 

};


// Call updateSettings with the new settings object

console.log('refreshing');
console.log(settings);

report.updateSettings(settings)
.catch(function (error) { console.log(error); });


currentPage.getVisuals().then(function (visuals) {
console.log('final')
console.log(visuals);

});

 

Helpful resources

Announcements
Exclusive LIVE Community Event #3 – Ask Arun Anything

Exclusive LIVE Community Event #3 – Ask Arun Anything

Join us in the third Triple A event!

Meet the 2020 Season 1 Power BI Super Users!

Meet the 2020 Season 1 Power BI Super Users!

It’s the start of a new Super User season! Learn all about the new Super Users and brand-new tiered recognition system.

Super User Challenge: Can You Solve These?

Super User Challenge: Can You Solve These?

We're celebrating the start of the New Super User season with our first ever Super User 'Can You Solve These?' challenge.

Power BI Desktop Update - February 2020

Power BI Desktop Update - February 2020

We are super excited for our update this month, as we are releasing two of our top community requests!

Power Platform Online Conference

Power Platform Online Conference

Join us for the first ever Power Platform Online Conference!

Top Solution Authors
Top Kudoed Authors