kalkih / mini-graph-card

Minimalistic graph card for Home Assistant Lovelace UI
MIT License
2.99k stars 233 forks source link

dynamic x-axis #1126

Closed ThimTT closed 1 month ago

ThimTT commented 1 month ago

Hi,

I have created a cashflow chart for my car. It will just accumulate whatever I am spending on it like initial cost, gas etc. I would love to have the x-axis dynamically adapt from some fixed date (date that I bought it) to now. I created a sensor that calculates the hours since, but the graph-card won't accept it as "hours-to-show".

am I doing it wrong, or is this not possible?

Thank you in advance!

sensor:
   - platform: template
     sensors:
       hours_since_specific_time:
         friendly_name: "Hours Since Specific Time"
         value_template: >
           {% set specific_time = as_timestamp(states('input_datetime.specific_time')) %}
           {% set current_time = as_timestamp(now()) %}
           {{ ((current_time - specific_time) / 3600) | round(2) }}
         unit_of_measurement: "hours"
`type: custom:mini-graph-card
entities:
  - entity: input_number.auto_cashflow_bmw_privat
    name: BMW
    color: red
  - entity: input_number.auto_cashflow_tesla_privat
    name: Tesla privat
    color: green
  - entity: input_number.auto_cashflow_tesla_firma
    name: Tesla firma
    color: lightgreen
name: Cashflow
hours_to_show: "{{ states('sensor.hours_since_specific_time') | int }}"
line_width: 2
font_size: 70
animate: true
show:
  name: true
  icon: false
  state: true
  legend: true
  fill: solid
  labels: true`
akloeckner commented 1 month ago

The mini graph card options do not accept home assistant jinja2 templates. You could use another custom card together with mini-graph-card: e.g. https://github.com/iantrich/config-template-card

ildar170975 commented 1 month ago

@ThimTT Please use Community or Discussions for questions. Not a bug or FR, closing.