Choose Language Hide Translation Bar
Level II

Problem using Graph Builder with Data Filter

Graph Builder works succussfully with the Data Filter adjusteing the plotted points properly when the Data Filter slider is moved. Also, the values of the statistics using the Caption Box adjust with the Data Filter slider as expected. So far, so good. Then I wanted to plot the mean of a column using 'Customize' and 'Y Function'. The following is the extracted script:

Add Graphics Script(


  Description( "Script" ),

  Y Function( Col Mean( :_columnexample_ ), x )


The desired mean line is plotted successsfully. However, the plotted line is unresponsive to the Data Filter slider.

How can I plot the column mean that works with the Data Filter?

Super User

Re: Problem using Graph Builder with Data Filter

The solution will probably be dependent upon whether you are using a Data Filter, or a Local Data Filter.  If you are using a Data Filter, you can apply a Row State Handler to the data table, that will redraw the Y Function.  If it is a Local Data Filter, the key will be in finding what is changed in the graph by the filter that one can trigger on, to redraw the Y Function.

If you can provide more details on the Data Filter you are using, I might be able to provide more of a solution

Level II

Re: Problem using Graph Builder with Data Filter

Thanks for the response.

Here's the script for the data filter, it's not local:

Current Data Table() << Data Filter(

Location( {325, 212} ),

Mode( Show( 1 ), Include( 1 ) ),

Add Filter( columns( :Bandmeter ), Where( :Bandmeter >= -100 & :Bandmeter <= -50 ) )


I'm guessing the problem lies with the Include(1) statement, perhaps it should be Exclude. My 30 day free trial just ended, so I'll have to wait to get a license to test it.

Some arbitrary initial values for the filter are included simply because I haven't figured out yet how to include all the rows of the current data table. It seemed to be a lesser issue at the moment, but I'm also presuming that it is not the cause for the difficulty in the use of the Data Filter with the Y Function.


Re: Problem using Graph Builder with Data Filter

Building on Jim's thought, here's one way (with the local data filter):


dt = Open("$SAMPLE_DATA/Big");

// Graph Builder

gb = dt << Graph Builder(

Show Control Panel( 0 ),

Lock Scales( 1 ),

Variables( X( :weight ), Y( :height ) ),

Elements( Points( X, Y, Legend( 6 ) ), Line Of Fit( X, Y, Legend( 8 ) ) ),


// Get a reference to the report

gbReport = gb << Report;

// Add a local data filter

ldf = gb << Local Data Filter( Add Filter( columns( :sex ) ) );

// Row state handler function that adds a horizontal line to Graph Builder at the mean of the current

// selection in the local data filter

addMeanYLine =

Function({x}, {Default Local},

// Get rows corresponding to the current selection

rows = ldf << getFilteredRows;

// Get the required mean value

mv = Mean((Column(dt, "height") << getValues)[rows]);

// Add the graphics script to the Graph Builder display box . . .

gFrames = gbReport << XPath( "//FrameBox" );

// Try to remove a graphics script that might already be there

Try(Send(gFrames[1], RemoveGraphicsScript(1)));

// Expression that will add the required graphics script

ags = Expr(Send(gFrames[1], AddGraphicsScript(PenColor("Red"); HLine(TBD))));

// 'Bake in' current mean value

SubstituteInto(ags, Expr(TBD), mv);

// Add the graphics script



// Assign the row state handler to the local data filter display box

rsh = gbReport[OutlineBox(1)] << MakeRowStateHandler(addMeanYLine);

Level II

Re: Problem using Graph Builder with Data Filter

Thank you Ian for answering. I have studied your script and see that it works. In my case, however, I need to keep the data filter global so that many graphs can be affected at once, and I haven't yet managed this.

Article Labels

    There are no labels assigned to this post.