IMFS-MMB / mmb-gui-electron

Electron-vue based GUI of the Macroeconomic Model Database
http://www.macromodelbase.com
Other
7 stars 16 forks source link

Export Data .csv always 20 periods #137

Open AlexDece opened 3 years ago

AlexDece commented 3 years ago

When changing the time horizon of the simulation and exporting the results in csv, the default time horizon is shown in the csv file.

I was surprised someone would actually download the csv file :D I received this issue from external source, so I should take care of it. I scanned through the code, but I didn't find where this information is read in matlab. @j2L4e do you have any idea? Since the output.json has the correct time horizon, I assume I just didnt find the right spot in the code...

To Reproduce Steps to reproduce the behavior:

  1. Check any model with any policy rule and any shock/variables
  2. Change Horizon to e.g. 40 in the options block
  3. Run simulation
  4. Click on "Export data .csv"
  5. In the output.csv only 21 periods are shown, while the output.json 41 periods are shown

Expected behavior The csv file should contain 41 periods output

Screenshots error1 error2 error3

Desktop (please complete the following information):

j2L4e commented 3 years ago

Hi Alex,

CSV columns are hard-coded:

https://github.com/IMFS-MMB/mmb-gui-electron/blob/197f83037647176f6a75716dc900f20debf85340/src/renderer/components/SaveData.vue#L37

You should be able to get the chosen horizon from the store ...

computed: {
  ...mapGetters('options', ['horizon']),
}

... and use it to build the correct fields array:

const moreFields = new Array(this.horizon).fill().map((_, i) => String(i + 1));

// ...

fields: ['resulttype', 'rule', 'model', 'shock', 'variable', ...moreFields]

Sorry for the late response, was on vacation

AlexDece commented 3 years ago

Got it, thank you!