Refreshing a Chart that no view parameter changed

I am just changing the isTotalHidden value, to show and hide it.
The only way I know of at this moment to get the chart to refresh is with viewparameter.RefreshAlladapters()
so my code looks like this:

var parentView = this.parentView;
var viewParameters = parentView.control.viewParameters;
var viewParameter = this.parentView.control.getViewParameterByName("viewParameter1");
if (chart1.isTotalHidden == false)
{
	chart1.isTotalHidden = true;
  	button1.text = "Show Totals";
}
else
{
 	chart1.isTotalHidden = false;
  	button1.text = "Hide Totals";
}
viewParameter.invalidateParameterValueLastModifiedTime();
viewParameter.refreshAllAdapters();

Is there a refresh or reload chart?

Try chart1.loadData();

Not sure if it will reset your totalHidden or not though

It did not, I think I tried it before posting but I just tried it again.

Yes you can call loadData on any control adapter to directly ask it to reload its data. isTotalHidden is a saved user-set property (available through the Properties panel) and won’t get reset on you.

I am setting it in the script and loadData will not make it go away or come back after setting it in the script, unless I do the clunky parameter refresh. is there a simpler way?

I’m not sure what you mean, but this script for example is enough to toggle totals on or off and refresh the data to see the result:

chart1.isTotalHidden = !chart1.isTotalHidden;
chart1.loadData();

If it’s not working, there may be something else going on such as some other call to refresh data made before you changed isTotalHidden.

Something must have been going on because before it was not working. I moved it over to the dev server and tested it again and now it is working. I hope it continues when i move it back to production, other wise there something there that interfering with it.

Maybe something was cached from my other attempt to try and have it on change parameter?

any hoo it does work just dont know why it wasnt before, I had even tried loadData before asking.