One way to handle this is to create the chart twice (or just once, and copy / paste.) Use the Layout tabs to set 'Conditional' to vAvgOrMedian = 'average' and vAvgOrMedian = 'median' respectively.
Then create a text object, select actions, go to 'external', and use 'set variable'. This will allow you to change the variable's value when the text object is clicked on.
There's a few different ways to handle this:
1) Just use a cyclic expression group - Write another expression that uses the median instead of the mean, and drag one on top of the other. In the chart, you'll see a circular arrow icon that you can click to switch between the two.
2) Make the expressions conditional, so that each one shows based on the value of a variable like vAverageOrMedian. (More on this below.)
3) As other_peoples_shoes said, you can create entirely separate objects and use a conditional show/hide in the Layout tab based on a variable as well.
For both (2) and (3), you can just do something like this:
Load _AverageOrMedian Inline[
And then create a list box with the "Always One Selected Value" box on the General tab checked. If you haven't already, be sure to add
Set HidePrefix = '_';
to your script, that'll keep the user from seeing the Average or Median selection in the Current Selections box.
Hope this helps!