Page 1 of 1

New widget - Chart linked to SFL grid?

Posted: Tue Feb 01, 2011 2:30 pm
by Bryan641
I'd love to be able to link my subfile grid to a chart such that when someone clicks on a column to sort, the chart would also update to show that column's values and sorted the same way.

Is there a way to achieve this effect now? Could you provide a chart that can be linked to a subfile? The chart labels would be taken from a specific column of the grid, but the values graphed would change when the grid columns are "clicked".

--Bryan

Re: New widget - Chart linked to SFL grid?

Posted: Tue Feb 01, 2011 3:42 pm
by David
It may be difficult to create a widget for this, but the behavior you're describing could be implemented today with existing features.

You could implemnt server-side record sorting for the subfile -- see the grid's "column sort response" properties for details on that.

An easy way to sort the records on the server-side would be to use an embedded SQL query with an ORDER BY clause.

You can then bind the "names" property of the chart to a field that you can use to feed in the chart element names from RPG.

You can also bind the "values" property on the chart to feed in the value for each element.

Does this help?

Re: New widget - Chart linked to SFL grid?

Posted: Tue Feb 01, 2011 5:57 pm
by Bryan641
I'm aware that I could handle it server side, but the response time for this program isn't all that great, because it's consolidating and sorting tens of thousands of records into just a few lines in the subfile grid. I guess I could retain the work file in QTEMP and sort that & reload. It would be just a little bit quicker that rebuilding it totally.

But the client-side subfile sort is nearly instantaneous, and refreshing the chart should be just as quick in this case.

If the subfile grid were a standard table element I could write some javascript to read the label column and the currently sorted value column (as long as I can tell which column was clicked on), create a large string of comma-separated values and set the chart data names & values parameters. Can I get to the subfile grid data in javascript? Can I tell which column it's currently sorted by in javascript?

--Bryan

Re: New widget - Chart linked to SFL grid?

Posted: Tue Feb 01, 2011 6:21 pm
by David
You can get (some of) the data from the grid using an API that we provide, but I don't think this will help you.

The grid widget in Profound UI uses virtual rendering, meaning that only the visible number of rows exist in the grid widget at any one time.

There is not currently a way to get at the other records using JavaScript.

Re: New widget - Chart linked to SFL grid?

Posted: Mon Mar 28, 2011 3:38 pm
by Bryan641
Sorry to resurrect this old thread, but I just wanted to point out that since you have sort capability on the grid columns, and an Excel export, you should be able to create a link from a chart to a grid to provide this functionality, since I can't get there with Javascript. I think this should be on your list of enhancements to implement, and even more so if it'd provide a way to handle multi-series charts without my having to code an RPGSP or other cgi-type program to generate XML.

--Bryan

Re: New widget - Chart linked to SFL grid?

Posted: Tue Apr 05, 2011 3:23 pm
by David
We will certainly take this into consideration.

In the meanwhile, though, it is possible to do advanced charting without having to write a CGI program.

You can bind the "chart url" property to an RPG field so that a dynamic XML file URL can be used. A standard non-CGI program could be used to "author" the XML file, (you'd probably need to give it a unique name based on user + timestamp or something) and then feed in the path to this property using field binding.

The program could even delete the file when the user exits the screen.

The only restriction here is that the file must be placed somewhere in the document root folder of the HTTP server.

Creating XML files on the IFS through RPG is not too difficult if you have some good examples to go by.

If you are not familiar with using the IFS from RPG, I would reccomend Scott Klement's IFS API tutorial which can be found on his website.