How to cause a chart to redraw

Charts that display data for a single record automatically redraw when the record is changed with new data. However, it is hard to get a chart to redraw that scans and gathers data across several records. For instance, I could not get a simple chart to refresh or redraw using the following chart formula:

Chart(ArraySelectedBuild(cr(), “”, {«Property» + tab() + «InPlacePUPY»}))

Implementing a ShowFields statement did not help. To make sure I had proper data in the text array, I set up a Text List Object using the same formula but without the Chart() function. To get the Text List Object to refresh I used the statement ObjectAction “MyList”, “FillList” where MyList is the name of my Text List Object. Is there a similar statement that would redraw my bar chart?

I was finally able to make the chart redraw by building a procedure that used the ArraySelectedBuild( function to create the contents of a variable, fgChart. The procedure also used the ShowFields statement. Then I inserted the fgChart variable in the Chart() function. Success! The procedure would make the chart redraw.

I think the problem was that all the fields and variables in your formula were named in quoted strings of text. They never appeared outside the quotes. To get a showvariables, or showfields command to see that a particular field or variable is part of a formula, it needs to appear unquoted in that formula.

Dave is correct. ShowFields will not work if the field is in a quoted formula. As far as the chart( function is concerned, Property and InPlacePUPY are just characters in a text constant, not fields.

An easy way to get around this is to use the catcherror( function with a dummy variable. The variable, which in this case I’ve called updateChart, doesn’t even need to exist.

catcherror("", updateChart)+chart(...

Whenever I want to update the chart, I just run this code.

showvariables updateChart

This trick isn’t limited to the chart function, it can be used in any situation where field names or variables are “hidden” inside a text string when using function like superlookup( or arraybuild(.

The chart( function is often used with the summarytable( or crosstab( functions. These functions essentially have the catcherror( function built in to them, using the sync parameter. See the sync parameter description in the documentation for these two functions, which is expressly designed to allow you to update a chart or list that uses the summary output.