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

Chart widget don't support expressions #1102

Closed
Belgadon opened this issue Jun 12, 2021 · 8 comments · Fixed by #1649
Closed

Chart widget don't support expressions #1102

Belgadon opened this issue Jun 12, 2021 · 8 comments · Fixed by #1649
Labels
enhancement New feature or request main ui Main UI

Comments

@Belgadon
Copy link

Inside an oh-mark-area object the items doesn't get called from props. It only works when its hardcoded by its name.

I made a minimal example. See the last line - the item is not selected.
If I hardcode the item by its name its working, but thats not very flexible.
I tried =props.window_item and =items[props.window_item].

uid: test
tags: []
props:
  parameters:
    - context: item
      description: Window Sensor Item shown in chart
      label: Window Item
      name: window_item
      required: false
      type: TEXT 
component: f7-card
config:
  title: test
slots:
  default:
    - component: oh-chart
      config:
        label: test
        periodVisible: false
      slots:
        grid:
          - component: oh-chart-grid
            config:
              show: true
              left: 50
              right: 50
        xAxis:
          - component: oh-time-axis
            config:
              gridIndex: 0
        yAxis:
          - component: oh-value-axis
            config:
              gridIndex: 0
        series:
          - component: oh-time-series
            config:
              name: Fenster
              gridIndex: 0
              xAxisIndex: 0
              yAxisIndex: 0
              type: bar
              color: red
            slots:
              markArea:
                - component: oh-mark-area
                  config:
                    name: Fenster
                    item: =props.window_item #=items[props.window_item]
@ghys ghys changed the title [Wdidget] Item is not selected from props in widget Chart widget don't support expressions Jun 14, 2021
@ghys ghys added enhancement New feature or request main ui Main UI labels Jun 14, 2021
@arjan-io
Copy link

arjan-io commented Oct 22, 2022

This is also true for the label item in

- component: oh-chart
      config:
        label: test

It does not support expressions (ie label: =props.title).
It does work however in a oh-time-series like this:

- component: oh-time-series
      config:
        areaStyle:
          opacity: 0.2
        gridIndex: 0
        item: =props.hum
        name: Luchtovchtigheid
        service: rrd4j
        smooth: true
        type: line
        xAxisIndex: 0
        yAxisIndex: 1

(Different chart example)

@canufarm
Copy link

canufarm commented Nov 8, 2022

Inside an oh-mark-area object the items doesn't get called from props. It only works when its hardcoded by its name.

+1 from me.

Expressions also do not work with "period:". Most of the echart-settings are not supported by the chart widget. Would be great if all echart-settings could be used with expressions, because otherwise one has to build separate widget for each item, although the widgets are exact copies.

Thanks.

@crnjan
Copy link
Contributor

crnjan commented Jan 14, 2023

This is also true for the label item in

- component: oh-chart
      config:
        label: test

syntax is a bit different

    - component: oh-chart
      config:
        ...
      slots:
        title:
          - component: oh-chart-title
            config:
              text: =props.title

and i also evaluated (with #1638), FYI

@jlaba
Copy link

jlaba commented Feb 13, 2023

markPoint:
  data:
    - value: =Number.parseInt(items[props.wind_angle].state)

is also not supported (At least for gauge charts)

@crnjan
Copy link
Contributor

crnjan commented Feb 13, 2023

Which OH version did you test with? Can you please share a full example so I can try to reproduce locally?

@jlaba
Copy link

jlaba commented Feb 13, 2023

Thanks for the fast reply! I'm using openhab 3.3.0 (docker container)

uid: widget_gauge_markpoint_test
tags: []
props:
  parameters:
    - context: item
      description: Wind Angle
      label: Wind Angle
      name: wind_angle
      required: true
      type: TEXT
timestamp: Feb 13, 2023, 2:52:36 PM
component: f7-card
config:
  height: 40em
slots:
  default:
    - component: oh-chart
      slots:
        series:
          - component: oh-data-series
            config:
              data:
                - name: Test
                  value: 100
              markPoint:
                data:
                  - value: =Number.parseInt(items[props.wind_angle].state)
                    name: MP1
                    x: 200
                    y: 100
              type: gauge

@crnjan
Copy link
Contributor

crnjan commented Feb 13, 2023

fix is only available in latest oh 4 snapshots. will double check when i’m home for your case …

@crnjan
Copy link
Contributor

crnjan commented Feb 14, 2023

@jlaba - just tested (OH 4 build #3299) and works
Screenshot 2023-02-14 at 03 15 09

There is a CSS based widget I use to render wind direction that should probably work on OH 3.3.0 (not 100%), just FYI ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request main ui Main UI
Projects
None yet
6 participants