• # Stacked area chart howto?

Hello,

I would like to build a stacked area chart in DGLux from a number of data points (a dozen or so), graphed over time.

I have seen Joel's video where he [url=http://forum.infiniteautomation.com/forum/posts/list/1192.page;jsessionid=01F574F0AE2AB9E9E04EDDA1D05AC671]makes a stacked bar chart but can't see how it can be applied to an area or line graph.
Any ideas?

Here's an example of a stacked area chart:

Thanks!

• Hi Jeremy,

The basic idea is make four (edit: oops, five) value queries, compose a table of all four, and compute columns 1, 1+2, 1+2+3, 1+2+3+4, then chart those series.

Step 1. Get the data
In a table dynamic property (preferably of a script element, as may be needed in step 2) make four sheets that query the four data points you're interested in.

Step 2. Compose the table
Do all four series have the same timestamps for their data?
a. If so, create a binding column (columns are created in the bottom left of a sheet) for each series on the sheet with query 1, and bind in those columns. The easiest way to do this is to bind the table in the dynamic properties list to the field labelled 'source table' and use the drop downs.
b. If not, consider writing a script to transpose the values to the correct rows in a fifth table. You can do this by getting the table rows, as documented at dglogik's wiki: http://wiki.dglogik.com/dglux_v2_wiki:dgscript, looping and doing the summing/transposing. I can provide more detail if necessary.

Step 3. Compute
Create three formula columns, and use these to sum the values appropriately. For a formula column script, the name of the column corresponds to the value in that column in that row. So, your scripts will look like "return A+B;" and return "A+B+C" although you may need the parseFloat() function.

Step 4. Chart
Click, drag and bind each data series to the chart. Configure their colors and tooltips so that you know which is which, and be sure to give each series a meaningful label. If they are ordered improperly, and one of the larger sums is displayed on top, you can re-order the series in the 'special' subdivision of each 'series' group on a chart element.

Hope that helps :D

• Thanks Phil, for the very detailed and thorough explanation. I understand the concept now.

I was hoping it would be a bit easier to implement, so I will have to leave it to later, when I'm a bit more experienced with DGLux and after I have implemented some other, more pressing things.
In the meantime I have emailed a feature request to DGLux. I will update if they reply (judging by the number of views this topic got in a short amount of time, it must be of interest to others)

Cheers
Jeremy

(DGLogik)
May 14 10:46

Hi Jeremy,

You can create stacked area chart in DGLux.

Here is the demo for how to create the stack column/bar chart. This functionality applies to all charts.
http://www.screencast.com/users/DGLogik/folders/Jing/media/e10d2e1e-7363-4d78-a96e-cdfdd55eb62c

I tried it in area chart and it works. Please give a try from your end and let me know if any question.

Regards,

• Thanks for sharing!

• .. I feel like a bit of a dunce for asking, but could someone briefly outline the steps required to create the table as shown in the demo?

I can create the blank table OK, but get stuck when trying to add the columns for each datapoint. I am trying to do it by adding a column, selecting type 'binding', then dropping a datapoint onto the binding type.
It populates each row with the same (current) value.

Thanks

• You can only make one query per sheet. The icon controlling queries is on the right side of the table (above or below depending on version), and you're trying to do history queries. You could use binding columns to bring the value columns from each querying sheet into the same sheet.

If their instructions work, you may not need to use binding columns at all. Just have a sheet for each series, bind them to the chart, and then tie them all together in the 'special' submenu.

Posts 8Views 2992