Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow data-f-foreach to have access to enumerated ranges for time-based models #99

Open
mmrj opened this issue Mar 16, 2017 · 2 comments
Assignees

Comments

@mmrj
Copy link
Contributor

mmrj commented Mar 16, 2017

it would be nice to have something similar allowed (syntax negotiable, etc.):

<table>
	<th>Initial Sales</th>
     <tbody data-f-foreach="r in region">
         <tr data-f-foreach="p in product">
             <td><%= r %></td><td><%= p %></td><td><%= Initial Sales[r,p] %></td>
         </tr>
     </tbody>
 </table>

for the case where /v2/model/introspect for this model returns

  "ranges": [
    {
      "indices": [
        "apple",
        "orange",
        "banana"
      ],
      "name": "product",
      "saved": false,
      "type": "Subscript Range"
    },
    {
      "indices": [
        "east",
        "west"
      ],
      "name": "region",
      "saved": false,
      "type": "Subscript Range"
    }
  ],
  "variables": [
    {
      "name": "Initial Sales",
      "saved": false,
      "subscripts": [
        "region",
        "product"
      ],
      "type": "Auxiliary"
    },
]

(currently, this only works if region and product are separately model variables)

@narenranjit
Copy link
Contributor

narenranjit commented Mar 17, 2017

@mmrj Haven't tried this, but shouldn't you be able to use the region[*] syntax here to loop through?

@mmrj
Copy link
Contributor Author

mmrj commented Mar 21, 2017

sample testing code, which doesn't work:


 <table>
 	<th>Initial Sales</th>
 	<tbody data-f-foreach="(region, rvalue) in Initial Sales[*,*]">
 		<tr data-f-foreach="(product, pvalue) in Initial Sales[<%= region %>,*]"><td> rvalue: <%= rvalue %>, pvalue: <%= pvalue %>, region: <%= region %>, product: <%= product %></td></tr>
 	</tbody>
 </table>

for reference,

GET https://api.forio.com/v2/run/mj-unittest/vensim_arrays/0000015af132af5966650d159232430b7524/variables/?include=Initial%20Sales[east,*]

returns

{"Initial Sales[east,*]":{"east":{"banana":[1050],"apple":[1000],"orange":[1100]}}}

however,

GET https://api.forio.com/v2/run/mj-unittest/vensim_arrays/0000015af132af5966650d159232430b7524/variables/Initial%20Sales[east,*]

returns

{
  "east": {
    "banana": [
      1050
    ],
    "apple": [
      1000
    ],
    "orange": [
      1100
    ]
  }
}

@narenranjit this matches what i expect from the Run API in both cases; but the data-f-foreach seems to be expecting the second one ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants