I have a Manipulate function that has two other functions inside of it, it has two sliders that each take in a value and show a bar on a graph from each input. Each value is shown on the chart as part of the maximum value. So the first bar shows maximum - value1
, the second bar shows maximum - (value1 - value2)
. The output from the second inner function changes if either value changes, but the value from the first inner function only changes if the first value changes.
In my code, when I change the value on the first slider it works as expected (first image), but when I change the value on the second slider, the bar for that value disappears, and the function doesn't seem to be running because if I am outputting the value of the function as a label, it changes to the function name (second image). (In my code example below, sometimes it works as expected, sometimes one bar disappears, sometimes both bars disappear)
Here is a simplified example of the code structure. The differences with my full code is that the inner functions run the number through a trained neural net to give their output, and the there's stylistic design around it. However, removing the code from all style information did not make a difference.
Manipulate[
(* functions *)
f1[x_Integer] := x;
f2[x_Integer] := x - f1val;
(* display *)
BarChart[
{{f1[f1val], 25 - f1[f1val]}, {f2[f2val], 25 - f2[f2val]}},
ChartLayout -> "Stacked"
],
(* sliders *)
{{f1val, 7}, 0, 25, 1},
{{f2val, 12}, 0, 25, 1}
]
I used this code last fall (November, I think) and it was working as expected, both bars were updating when I updated the related slider(s). Now when I run the code, I'm having this problem. I've tried on multiple computers, and the code ran on both these computers previously, so I don't think the issue is the computer. I cannot update this particular code to version 12 because some things I used in other parts of the code have changed too much to make it plausible. Any suggestions of what's going wrong and/or how to fix it?