overthesun / simoc-web

This is the web interface to SIMOC
https://ngs.simoc.space/
Other
3 stars 0 forks source link

Make the graphs/panels more generic #164

Open ezio-melotti opened 2 years ago

ezio-melotti commented 2 years ago

The content of each panel depends on three things:

We already have separation between panels and graphs, and we merged some panels by adding a dropdown that lets you select the data being plotted, however we can generalize this further.

Currently we do something like this:

This means that the VersusGraph (which is just a line plot with two lines) can only be used to plot values from totalProduction/totalConsumption.


Instead of doing this, we should have generic panels and graphs that accept a path (as a string) that can be used by the graph to retrieve the data. For example, the above example could be rewritten to:

<LineGraph :datasets="datasets" />

where datasets could be defined as:

datasets = [`state.dashboard.totalConsumption.${currency}`,
            `state.dashboard.totalProduction.${currency}`]

with currency being the value selected from the dropdown.

The graph can then use the paths specified in datasets and plot a line for each dataset.

To retrieve the actual values from the path, we can use lodash.get or object-path.

ezio-melotti commented 1 year ago

See #334.