Hide points on button click

Hello, is there a way to hide graphed points when a button is clicked? I have 3 tables of values and three buttons. Each button graphs the values from a specific table. I have figured out how to make each button plot the points from the table. However, is it possible to have the button first clear the graph before plotting the points?

For example, button 1 plots points from table 1. When they press button two, can it clear the plotted points from the first button press before plotting the points from table 2?

Do you care about the order the buttons are pressed in?

Could the kids want to plot table 3 before table 1?


The order doesn’t matter. Conceivably, the students could press the buttons in any order.

The hard part is figuring out which button was the last one pushed, especially if you don’t want to care about how long it takes.

I think this does what you want, but it’s ugly

Lt me know if y9u want it commented for explanatiiona.

Thank you! This is exactly what I’m looking for. I appreciate your offer to add commented explanations, but that sounds like a lot of extra work. You’ve already helped a ton and hopefully, I can figure out what the code does using the CL documentation.


I want to make sure I’m understanding the code correctly.

Action button “b1”:

capture(“b1”): numericValue("${b1.pressCount}+1") #this store the b1 button count + 1 in variable b1
capture(“b2”): b2.pressCount #this stores the b2 button count in variable b2
capture(“b3”): b3.pressCount #this stores the b3 button count in variable b3

In the graph,

c11=when isDefined(b1.lastValue(“b1”)) b1.lastValue(“b1”) otherwise 0
c12=when isDefined(b2.lastValue(“b1”)) b2.lastValue(“b1”) otherwise 0
c13=when isDefined(b3.lastValue(“b1”)) b3.lastValue(“b1”) otherwise 0

This is the section I’m less sure about. Am I right in assuming that when I press a button, the “b1” variable from the other buttons no longer exists? From reading the CL documentation, isDefined is basically a True/False situation. So, I think this section checks if the “b1” variable exists for each button. If it does, it assigns a 1 to that c variable (either c11, c12, or c13) if it doesn’t exists, then it assigns a 0 to that c variable. Since button b1 is the only one that should have the lastValue in variable b1, c11 is the only variable of those 3 that gets assigned 1.

Is my understanding correct? Or am I missing something?

Again, thank you so much for your help!

Each button press stores the count of all the button presses. The +1 is because the variable is polled before it is updated - the +1 is to include the current button press.

Only the most recent button pressed will have the correct history, so it is the only one that has more button presses recorded for itself than by either of the other two buttons.

The isDefined is because if the button has never been pressed, the count is undefined rather than zero, and the comparisons will fail. That just fixes that problem.

the 0 and 1 is put into variables in the graph that are used for conditionals to display a group of points.

Ah, that makes sense. I didn’t realize that the first time you press the button, the pressCount is recorded as 0. Now I think I understand everything. Again, thank you for taking the time to help me!

The pressCount is 1 after the button press, but if you try to capture your own pressCount, it’s not.

In further consideration, you probably don’t have to capture your own - you could just use the pressCount. You’d still have to convert undefs to 0s, though, so that the comparison would work.

I’ve updated my example to do this.

Instead of using a bunch of buttons, you could use a Multiple Choice/Checkboxes. Maybe have variables a, b, and c for each of your tables. You might want notes as titles for students.

number("a") = when yourMultiSelectName.isSelected(1) 1 otherwise 0
number("b") = when yourMultiSelectName.isSelected(2) 1 otherwise 0
number("c") = when yourMultiSelectName.isSelected(3) 1 otherwise 0

Then for points in the graph from table A include {a=1} within the point for it to display when the first choice is selected. Similar for other tables.

Use Checkboxes if you want to be able to display all tables simultaneously, Multiple Choice if one table at a time.

1 Like