How to toggle graph in streamlit? - dashboard

I have two kind of chart to display based on user selection that can be changed by user dynamically. I have two buttons female and male. If female button is clicked female data plot should be shown in the left column. And if the user clicks male button again the male data plot should be shown in the same place replacing previous plot. The plots are done in plotly. How to achieve this? ~Quite new to streamlit so please ignore mistakes

Since you didn't provide any code, the code below should give you the idea of how to work around it. But if this didn't solve your problem, provide some code, I am pretty sure once your question is clear someone can offer a better solution.
left_col, right_col = st.columns(2)
with left_col:
female_button = st.button("Female graph")
male_button = st.button("Male graph")
if female_button:
st.write(female_plot)
elif male_button:
st.write(male_plot)

Related

Displaying multiple colors on a single data bar

Okay I am going to try and be as clear as possible with my end goal here so I apologize if it does sound messy. I am trying to display a data bar that has a target of 10 for example. This data bar is displayed in grey. What I'd like to do is on the same data bar have the color green fill up as each target is completed. Here is a rough image of what I would like:
I'm trying to do this in ssrs within a matrix. If anyone could help I would greatly appreciate it or if anyone needs more detail please let me know.
Thanks in advance.
Right click on your column group and insert 'inside group'.
Drag and drop a Data Bar into your new cell.
Choose a stacked bar.
Click on the new chart, so that Chart Data appears.
Add your first value, the one you wish to be, for example, green.
Add a second value, adding the same value as before.
Change the expression on this second value to be 10 - 'Value'

Processing: Creating Buttons

I'm trying to create a program that creates three buttons on the right side of the screen.
When I press a button, the entire background will change color (each button will make the background a different color). Whenever the mouse is not pressed, the background will return to white. I'm having trouble understanding how to make the three rectangles into buttons.
THIS MUST BE DONE WITHOUT A SPECIAL BUTTON METHOD/LIBRARY
You need to break your problem down into smaller pieces.
Can you create a program that just shows a single button? Don't even worry about making it interactive yet. Just show a single button at hard-coded coordinates.
Now can you detect when the user clicks in that button? Just print something to the console. Get that working perfectly before moving on.
Now can you get multiple buttons working together? Again, just print somethign to the console, and make sure it works perfectly before moving on.
Finally, can you make it so pressing each button changes the background instead of printing something to the console?
If you get stuck on a specific step, you can post a MCVE along with a specific technical question. Stack Overflow really isn't designed for general "how do I do this" type questions. It's for specific "I tried X, expected Y, but got Z instead" type questions. So please try something and post an MCVE of a specific step you're stuck on. Good luck.
Check processing's documentation for mouseClicked() and mousePressed.
The former being a method called upon a click, and the later is a boolean that is constantly updated. (So you'd check for it in your draw())
You'd then want to check the mouseX and mouseY values to see if they are in your desired button's area. (Which would be displayed on screen using rect())

Eclipse generate many JFormattedTextField

I implemented Gauss Jordan Algorithm in eclipse and now I am trying to make it be a software, however I have no experience at all with GUI.
I have a window that asks for input of 2 things number of variables and number of equations and when user enters the numbers and presses submit button, second window opens.
In that second window I need certain number of textfields to appear itself, which will be dependent on the two variables mentioned above.
My question is there any way to grab the value from first class(first window where user entered variables which I stores in first class) pass it to second one(second window where the textfields will appear) to tell it how many rows and columns should be generated with textfields and then the program would generate it?
I tried looking up on youtube, because I do not understand documentations well, so any answer would be very appreciated!
Well the MVC pattern could help you to do this, check something like this:
http://www.austintek.com/mvc/

MATLAB: How to present multiple images/figures to user and wait for click on one of them?

all. I'm new to Matlab and I'm a bit stuck. The last piece of the puzzle to run my experiment is to get some human input (expert supervised system). As easy as this may sound, I just can't seem to figure this one out.
I need to display four images to the user, plus an additional fifth figure (button, or could even be another image, doesn't matter). The code should wait until the user clicks any one of those images/figures and should continue afterwards (closing the figures, too). Obviously, I'd need to know which figure was clicked.
GUI programming in Matlab doesn't seem to be documented clearly to me. Or perhaps it's just in a realm that I'm not talented with. It's definitely a lot more confusing than Visual Studio, that's for sure.
Thanks in advance for your time; I greatly appreciate it! :)
Could you make all five of the images into buttons? The 'CData' property of a button can be used to display an image on a MATLAB button. See the following links for an example and an explanation (that hopefully makes sense!).
http://www.mathworks.com/matlabcentral/fileexchange/2378-buttons/content/buttons.m
http://www.mathworks.com/support/solutions/en/data/1-16V03/
Use menu:
figure(1)
plot...
figure(2)
plot...
figure(3)
plot...
figure(4)
plot...
% this will create a menu of labeled buttons where the user can click
m = menu('Choose a figure','Figure 1','Figure 2','Figure 3','Figure 4','None');
% close all 4 figures
close(1:4) %will close figures 1 to 4
% --------- your program from here on ---------
if m == 5
display('You chose no Figure');
else
display(['You chose Figure:' num2str(m)]);
end
%---------
menu will return a number which corresponds to the option that the user clicked on.

Idioms for a three-state toggle?

I have a table column where each row has one of three states, and the purpose of the row is to offer manipulation AND display of this property with three states.
My current development view is to have three tightly packed radio buttons with labels at the head of the columns (and every 50 rows or so) and onClick they send an AJAX request and thar she blows.
This is fugly.
Is there a standard idiom for a control like this? I'm currently mocking up something similar to the iPhone on/off toggle, but with a "middle" state.
Any input would be welcome.
EDIT
A bit more clarification: I have a tool for confirming events. Each event is either "proposed", "cancelled", or "confirmed". They all default to "proposed" until someone explicitly confirms or cancels them. This is a thin front-end for a SQL table.
I've seen this handled with image buttons that remain "depressed" when you click while popping the other two out. They act like radio buttons except that the label and the state are merged. If your names are too lengthy to fit in a button, you can abbreviate them and provide a key. I'd also give each one a distinct color. For implementation just pop the value in a hidden form field on click.
These are called "Toggle Buttons" in some other UI's:
http://java.sun.com/products/jlf/ed2/book/HIG.Controls2.html
http://msdn.microsoft.com/en-us/library/dd940509%28VS.85%29.aspx
http://developer.gnome.org/projects/gup/hig/2.0/controls-toggle-buttons.html
The standard mechanization for things like this in military avionics, where screen space is always at a premium,and so are buttons, is a "rotary". Each time you click it, it steps to the next value in sequence, wrapping around.
As an example, a device with a cryogenic cooler might have three states: OFF, WARM, and COOL. Initially, the device is OFF: no power applied. Click it, and it switches to WARM, meaning power is applied, but no cooling. Click it again, and it starts the cooler. (Since cooling in this kind of thing is usually supplied by a gas bottle with a strictly limited capacity, you don't want to cool the device until you are getting ready to party.) Click it again, and it shuts the device OFF.
You could also do this with buttons or hyperlinks. In a big table, hyperlinks will probably look best.
In the Proposed state, your cell could look something like this (with underlined links, but the editor won't let me):
Proposed Confirm Cancel
In the Confirmed state:
Confirmed Undo
In the Cancelled state:
Cancelled Undo
This will take two clicks to get from Confirmed to Cancelled and vice versa, but I assume that this operation is rarer than switching between Proposed and one of the other two.
Perhaps display arrows on either side to change the state:
(Cancelled) <| Proposed |> (Confirmed)
These may or may not 'wrap' depending on how well that suits the values and how important it is to saving a click when transitioning from value 1 to value 3 (or vice-versa).
As an alternative to you radio buttons, you could consider a drop-down list with three options. The disadvantage is, of course, that two clicks are needed to change the value.
Maybe use a slider with three states? (It really depends on the exact situation!)
Consider a fixed-position slider with three positions, such as offered by jQueryUI: http://jqueryui.com/demos/slider/#steps
I am reminded of the permissions button in SQL - it has multiple states; green check, red x, no setting, and clicking on them cycles through the three states. Its ok but annoying if you want to change a bunch to the state reached second, and if you click too many times you have to go through it all again. Left click - cycle forward; right click - cycle backward might work but certainly has no basis in UI expectations.
Idiomatically, I would say a Stop Light (red/yellow/green). They could behave like radio buttons; darker toned for 'off' and lighter tones for 'on', and since the color gives a cue you can move the description to a mouseover label. Of course, it isn't RG Colorblind kosher, so depending on your application that may be a deal breaker. (also, it may be confusing on Mac where the minimize/close etc buttons are the same color scheme).
Why not use three boxes that look like the "Questions", "Tags", "Users", ... boxes on this page (could be implemented as links, buttons or whatever)?

Resources