Posted: 2011/04/24 Filed under: FormLis, Updates | Tags: Charts, FormLis, Updates
I've integrated plots into the system now. They are saved to the backend database, show up with their parent views in the view list, and have a save/edit/preview user interface cycle. So they're coming along pretty nicely.
This chart is part of a diet tracker. This chart is showing how much of each food group each person has eaten today. I don't render a legend yet… it's coming.
Posted: 2011/04/14 Filed under: FormLis, Forth, Programming, Updates | Tags: Charts, FormLis, Updates
I’ve been busy integrating charts into FormLis. Heres how they look together. Isn’t that lovely?
You generate charts from view data. In this case I used a food intake tracker that is helping people make sure they’re getting their recommended daily amounts. Here is the
relevant data — I’ve added the highlighting, column numbers and outlines — this is what the chart is seeing.
And here is the magic tying them together:
PLOT bar chart ;
ON “/*/” leaf-totals ;
LIMIT 1 ;
POINTS-PER-ROW 6 ;
X p# 0 case “Protein” ; then
1 case “Grains” ; then
2 case “Vegetables” ; then
3 case “Fruits” ; then
4 case “Milk” ; then
5 case “Fats” ; then ;
Y 5 p# + column ;
Plots describe how views are transformed into (X & Y) pairs. ON “/*/” leaf-totals ; slices the data up into multiple plots. In this case 1 plot per top level group (e.g. Tom, Peggy, etc). Its the pink boxes in the view above. I’m using the leaf-totals as data because they contain my daily sum (I’ve highlighted them in white). Leaf-totals means the same as the sub-sub-sub-sub-totals. I could have chosen to use the rows or the overall totals.
I want to restrict the plot to just todays data, which is the first row in each group, so I say LIMIT 1 ;.
Each of these rows will produce several (X &Y) pairs. For example Tom’s row will produce (“Protein” & 12), (“Grains” & 6), (“Vegatables” & 2.5) etc. So I say POINTS-PER-ROW 6 ;
Lastly, I have to tell FormLis how to compute the X & Y values. That’s what the X and Y functions above do. X says “take the point number (p#), if its zero -> Protein, if its 1 -> Grains, etc”. Y says take the point number, add 5, and use that column’s data.