Call evalMetric from UI only if selected by User

#1

I have an UsageAndChart component that shows several metrics. Since one of those metric displays energy consumption for 15 mins interval I would like to avoid unusefull heavy call to this metric and evaluate it only when the user decides to click on the related label.
I know that there is an option “disabled” - but this only avoids to plot the metric result in the graph but in background the evalMetric is anyway executed as visible in Network panel.
Do we have a property that say run the evalMetric only when user click on it?

0 Likes

#2

The UsageAndChart component uses series that has a data field that I believe is nothing but a plain DataSource to populate the data points. You can try to set the autoLoad of your data source to false, like:

{
  "id": "SeriesId",
   "isTimeseries": true,
   "name": "SeriesName",
   "data": {
    "autoLoad" : false,
    "c3type": "EvalMetricTyoe",
    "c3function": "evalMetric",
    "c3arguments": {
      "spec": {
        "id": "{{params.id}}",
        "expression": "THE_EXPRESSION_TO_EVALUATE"
      }
    },
    "responseTransform": null,
    "collection": false
  },
  "color": "#f0a63a",
  "unit": "",
  "chartType": "line",
  "axis": "some label",
  "tooltipGroup": "group"
}
0 Likes

#3

just tested and “disabled”: true avoid the unuseful call of evalMetric

0 Likes