Basic approaches to building graphs (and other windows?)

Hi All:

After reading Carl and Colby’s responses to the thread on assigning values to a variable in code, I think I have started to understand better how to use Factory PMI. It seems that most of what I’ve been trying to do in code can easily be done without any. Please comment on the following approach to building a chart:

  1. Create root container variables for anything that accepts user input (select boxes, check boxes, etc.) or is passed in on opening.
  2. Bind these variables to the input controls (drop downs, etc.)
  3. Create datasets as needed, using as parameters (if needed) the root container variables
  4. Bind the datasets to chart series.

To turn on or off a chart series, execute the following code on an itemStateChanged property of a checkbox:

isChecked = event.stateChange == event.SELECTED 
root = fpmi.gui.getParentWindow(event).rootContainer
chart = root.getComponent("Chart")
chart.setDatasetEnabled([i]SERIESNAMEHERE[/i], isChecked) 

Is there any advantage to putting datasets on the root as opposed to on the chart? Any gaps in this approach?

TIA D. Lewis

Yes, this is very true. We find that sometimes users (especially those that have used VB in the past) will automatically jump to scripting to accomplish tasks that could (should) be accomplished through binding. We coach people to always think “How could I do this using binding (property, expression, or SQL)” before they start writing a script. The result will be a much more elegant solution.

Your approach for building a chart window is good. Some comments:

If you have a parameter that can be passed in and controlled via a component at the same time, you need to bind the two properties to each other. (that is, bind the root container property to the relevant property on the component, and vise versa). This way, the component will always display the correct parameter, as well as control it.

I’m not sure what you mean about where to put the datasets. In order for data to be graphed, it needs to be a dataset of the chart. What did you mean by putting datasets on the root container?

Hope this helps,


I was recalling another window I made where the datasets for a grid are located on the root container. I used property binding to bind the data property of the grid to the dataset on the root container. I must admit I never did this with a chart, but I sort of assumed that the same flexibility I had with the data grid would also work with a chart – that is, the location of the dataset was not so important (could be on the root, could be a custom attribute of the component). I guess data grids and charts are not identical in this regard. D. Lewis


Ah, now I see what you are saying. You could put datasets on the root container, and then use a simple property binding to connect the chart’s dataset to the root container’s datasets, but there isn’t really any point to doing this (unless you wanted the dataset to be passed into the window as a parameter).

Hope that makes sense,