Group Abstract Group Abstract

Message Boards Message Boards

Update AppendTo when interacting with PopupMenu?

Posted 7 years ago
4 Replies

This one updates the degrees:

DynamicModule[{inputList, inputData = 0, plotData = {}, 
  dataSet3 = {0, 0, 0}, dataSet1, dataSet2, dataSet4},
 inputList = {{1, 5}, {2, 4}, {3, 8}};
 Dynamic@Column[{InputField[Dynamic[inputData]],
    Dynamic@Button["Plot",
      dataSet1 = Map[Norm, Differences[inputList]];
      dataSet2 = Exp[-N[Pi]*0.345*5*dataSet1/(10*2000)];
      dataSet3 = Quantity[FoldList[10 + (#1 - 10)*#2 &,
         inputData, dataSet2], "DegreesCelsius"];
      dataSet4 = Transpose[{inputList[[All, 1]], dataSet3}];
      AppendTo[plotData, dataSet4]],
    Spacer[5],
    PopupMenu[
     Dynamic[popupSelection], {"DegreesCelsius" -> "C", 
      "DegreesFahrenheit" -> "F"}], 
    ListPlot[
     plotData /. dgs_Quantity :> UnitConvert[dgs, popupSelection], 
     Joined -> True, ImageSize -> {300}, Frame -> True]}],
 SynchronousInitialization -> False]
POSTED BY: Gianluca Gorni

Gianluca thank you so much!!!

The UnitConvert is only done at the beginning. It is not dynamic.

POSTED BY: Gianluca Gorni

I tried including expression with UnitConvert inside the Button but the output was exactly the same, AppendTo didn't update when interacting with PopupMenu

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard