I sent Travis an email requesting that he contact you to show you how this works. Selecting pens at runtime isn’t immediately intuitive for our new users, but it’s relatively simple and very flexible once you get the hang of it! If you find yourself using any scripting or overly complex queries, there’s probably an easier way. As an aside, creating a tutorial is on my “to do” list.
The key to Selecting pens at runtime is storing your pen configuration in a table in your SQL database. Choose the pen options that interest you from the available list below. Each will be a column in your pens table with the same name. In your case, you will also want to add an area column.
Add a dropdown list to the window with the Easy Chart. Bind its Data property to the following query:
SELECT DISTINCT area FROM pens
Bind the Easy Chart’s Where Clause property to an expression that generates “WHERE area = selected_area”. It should look something like this:
Viola, you should be done. The Easy Chart will automatically let the user choose relevant pens for that area. A few ideas to get fancier:
[li]Store the areaid and area description separately - your JOINs could be useful there. [/li]
[li]See the demo project for how to add a dropdown that allows the user to change the graph mode between historical/realtime.[/li][/ul]
Here are the (optional) pen columns:
Technical Note (once you get the first part): In this case your graph options were defined at design time. You knew which pens belonged to which area and didn’t want to change that. The more general technique builds pen configuration tables using the same principals as described above. Users choose pens to be stored in their profile, which are stored in a database table. The charts pens property is bound to a query that reads this configuration. You will often use objects on the screen (like the list box) to allow users to change to change the WHERE clause of pens query, like to select an area or profile.
Let me know if I’m going too quickly over the deep end. It’s really not bad once you get comfortable with how databinding works. You are dealing with the 2nd most complex task that I can think of in FactoryPMI behind some of the more custom scripting applications.