Plot in a Jupyter notebook depending on a true/false checkbox - jupyter-notebook

I have an interactive notebook with a few widgets, that displays a plot (+other data) based on the information given by the widgets. The plot is only displayed if a Checkbox is checked.
Everything works well except one thing: the Checkbox has a True value by default. When loading the notebook for the first time, it appears as clicked but the plot is not displayed -- if I interact with the widgets in any other way (either by re-clicking this checkbox twice, or by modifying some of the other widgets), then the plot is displayed.
Is there a way to have the plot displayed at the beginning without waiting for the user to interact?

Start by creating your checkbox with the False value
cb = widgets.Checkbox(value=False)
Then, once you have set up your observse, in the code, change the value of the checkbox to True, and this should trigger your code.
cb.value = True

Related

Report Builder MAP Parameters

Good Afternoon,
So I have built a State Map in Report builder that is separated into Counties. I have been pretty successful, however there is one thing I cannot figure out. When I click on the county, is it possible to pass the county name that I clicked to a chart on the same report. I can pass it to another report via go to report, but I would like to have it on the same document.I also kept getting a Subreport not found when I attempted that method. Any help is greatly appreciated.
Thanks!
A basic rule of SSRS is that with very few exceptions, you cannot change the content of a report unless you refresh the report.
Bearing this in mind, you have a couple of options..
Call the same report again as a subreport.
Assuming you only want your map and a single dynamic chart.
Add a parameter to the report that defaults to specific value such as 'none'. Then you can decide what do show in your chart when the parameter = 'none' or you could choose the hide the chart if the parameter is 'none'.
In your map go to the map's polygon properties and assign an action.
Set the action to be Go to Report
Choose your report (so we get the report to call itself)
Add a parameter, choose the parameter you added a few steps earlier as the name and select the field that contains the state name or ID etc as the value.
Your Chart's dataset can then be updated to use the new parameter in the dataset query.
Create a chart for every State
The other option is to create a chart for every state, you can do this using a table or list control and a subreport containing your chart, so you design will not have to have lots of charts individually placed.
Each Chart can have a bookmark set (most objects have a bookmark property) that is the name or ID of the state it represents.
Then in your map, set the action properties in the polygon properties to 'Go to bookmark' and then use the state name or ID as the bookmark expression to go to.

How to force a widget (dropdown box) value programmatically?

I'm setting in place a visualization which data are driven by selections made through bokeh widgets (mainly dropdowns).
The dropdowns are linked (i.e: depending on dropdown 1 choice, dropdown2 will be filled with certain data, etc...)
I have 2 needs which tend to be the same:
I know I can get the value of a choice by using dropdown1.value (in an on_change callback) so:
How can I set the value of a dropdown (and force it to display this choice) ?
How can I reset all dropdowns to the default startup position?
Thanks for the help!
The Bokeh Dropdown widget doesn't support displaying the value that you clicked. You would need to use Select widget for that.
Then like bigreddot already said there is no tracking of default value but if you put your "default" value as first in the options attribute of your Select then you can do:
select.value = value to select/display a value
select.value = null (JS callback)
or
select.value = None (Python callback) to select/display the first value
In JavaScript, or Python:
widget.value = new_value
There's nothing that keeps track of the initial values you set. You will have to record them and set them as above when you want them to reset.

Google App Maker not reocognising some of its own widgets

In Google App Maker, I have several widgets on a page.
One of these widgets is called Label12 (shown in Screenshot 1).
It definitely exists and is also shown in the breadcrumb trail at the top of my screen.
However, when I attempt to reference Label12 in my code, it does not seem to exist.
If I use the ctrl+space code completion helper, the Label12 widget is not shown as an option (shown in screenshot 2).
When I attempt to code it manually (e.g. app.pages.Reconciliation_Details.descendants.Label12.visible) it returns the error "Cannot set property 'visible' of undefined".
Why can App Maker not see Label12?
Screenshot 1 showing Label12 on page:
Screenshot 2 showing absence of Label12 when coding:
App Maker can see Label12. The point is that the label is inside a table widget, hence according to the documentation:
Because a table is a collection of other widgets, you can't use the Widget API to interact with a table. However, you can use scripts to manipulate the individual widgets that make up a table.
The above statement makes sense because the amount of rows a table will display depends on the datasource items; i.e., the rows are dynamically created when the widget datasource is loaded in the ui. Therefore, in order to access the label you need to first access the children of the Table1Body, which is a collection of named values known as PropertyMap.
I believe you are trying to hide/show that specific label based on some logic. The correct way of doing it would be something like this:
var rows = app.pages.Reconciliation_Details.descendants.Table1Body.children._values;
for(var i=0; i<rows.length; i++){
var row = rows[i];
var label = row.descendants.Label12;
label.visible = true; // or false
}

Have Highcharts legend update shiny table

I have a shiny app with a sidebarLayout. The offer selection is a checkbox group in the side panel, the highchart is in the main panel with cumulative response rates over time by different offers and finally the table with the current response rate by offer is beneath both the offer checkbox group and cumulative response rate chart.
Ideally I would like to remove the checkboxGroupInput and have the legendItemClick in the highchart take over this functionality so that when a particular offer in the legend is clicked (and no longer visible on the chart) that the corresponding row in the shiny table is also hidden or removed.
I've tried tying the legend item to the checkbox in the shiny checkboxGroupInput, which works here in this JSFiddle, but it does not work with the shiny app.
p1$plotOptions(series=list(stickyTracking=F,
events=list(legendItemClick=paste("#!function(){
if (this.visible) {
$('input[value=",'"',"'+this.name+'",'"',"]').prop('checked',false);
} else {
$('input[value=",'"',"'+this.name+'",'"',"]').prop('checked',true);
}
}!#"))))
Any way I can do this?
Once again, ideally I'd like to replace the checkboxGroupInput with the legendItemClick to update my shiny table.

Issue in Conditional hiding in cognos report ver 10

I already have a conditional block which controls 10 charts like chart 1 .....chart 10 based on block variable called 'Chart' now I have to conditionally hide chart 3 , bcoz the design of chart 3 differs based on prompt value = complex.
So I tried using style variable and render variables to hide chart 3, I noticed the conditions works only if click on the submit button second time. during the first run its not rendering properly.
case when paramvalue='complex'
then 'Y'
else 'N'
end
If I try to pull the data item from query it throws error as its not referenced in the layout.
I tried many combinations but not working. Quick help is appreciated.
it throws error as its not referenced in the layout.
Normally you use the 'properties' property of the rendering object (i.e. list, singleton) to define query items that aren't in your list but need to be referenced.
This works for lists but generally does not work for charts or crosstabs. If you can somehow squeeze your query item on to the chart then this error will go away.

Resources