Apexchart legend units and duration settings

Hi, I have the following apex chart, and I have encountered two issues:

  1. The legend displays strange units (ms or minutes) – it should be in kWh.

type: custom:mod-card
card:
  type: vertical-stack
  cards:
    - type: custom:apexcharts-card
      apex_config:
        chart:
          height: 205px
          offsetX: -26
      experimental:
        color_threshold: true
      span:
        end: hour
      header:
        show: true
        show_states: false
        colorize_states: false
      yaxis:
        - min: 0
          decimals: 1
          apex_config:
            tickAmount: 5
      series:
        - entity: sensor.tpj4cjm04k_system_production_today_self_consumption_export_2
          show:
            header_color_threshold: true
            extremas: false
            as_duration: hour
            datalabels: false
          unit: ' kWh'
          color: green
          type: area
          color_threshold:
            - value: 0
              color: palegreen
          name: Solar
          group_by:
            func: diff
            duration: 2hour
        - entity: sensor.tpj4cjm04k_import_from_grid_today_load_2
          show:
            header_color_threshold: true
            extremas: false
            as_duration: hour
            datalabels: false
          type: line
          unit: ' kWh'
          color: firebrick
          name: Import
          group_by:
            func: diff
            duration: 2hour
      now:
        show: true
        color: 2eb9ff
        label: Now
  1. When I change the duration from 2hours to 1hour, the graph displays the wrong trend. (I need to set 2hours at least):

The original entity is updated every 30 minutes:

Thank you

Try removing the space.

unit: 'kWh'

Unfortunately, no change in the graph by removing the space.