RomRider / apexcharts-card

📈 A Lovelace card to display advanced graphs and charts based on ApexChartsJS for Home Assistant
MIT License
1.08k stars 75 forks source link

Add documentation on tooltip float preciesion #659

Open DrBlokmeister opened 5 months ago

DrBlokmeister commented 5 months ago

This morning I spent over 30 minutes trying to find out how to change the float precision of a tooltip. I have the float precision set to 0 on all possible options, but still the tooltip sometimes displayed 10 decimal places! I use rounding, so I this amount of decimals is not surprising. However, it is not helpful for the overview.

Please add a line on documentation or an example on how to do rounding in the tooltip, and a usecase.

This is my usecase, if that is useful:

    - type: custom:apexcharts-card
      graph_span: 24h
      update_interval: 1m
      all_series_config:
        float_precision: 0
      apex_config:
        plotOptions:
          pie:
            donut:
              labels:
                show: true
                total:
                  show: true
                  label: Total
                  formatter: |
                    EVAL:function(w) {
                      return Math.round((w.globals.seriesTotals.reduce((a, b) => {return (a + b)} , 0)).toFixed(2)) + ' W';
                      }
                value:
                  show: true
                  formatter: |
                    EVAL:function(val) {
                      return Math.round(val) + ' W'
                    }
      chart_type: donut
      series:
        - entity: sensor.electricity_meter_power_consumption_phase_l1
          name: Phase 1
          transform: "return Math.round(x * 1000);"
          unit: W
          group_by:
            func: avg
            duration: 1min
        - entity: sensor.electricity_meter_power_consumption_phase_l2
          name: Phase 2
          transform: "return Math.round(x * 1000);"
          unit: W
          group_by:
            func: avg
            duration: 1min
        - entity: sensor.electricity_meter_power_consumption_phase_l3
          name: Phase 3
          transform: "return Math.round(x * 1000);"
          unit: W
          group_by:
            func: avg
            duration: 1min

image

github-actions[bot] commented 3 months ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 10 days.

DrBlokmeister commented 3 months ago

Still a valid request afaik.

github-actions[bot] commented 1 month ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 10 days.

DrBlokmeister commented 1 month ago

Still a valid request.