OCA reporting engine fork for dev and update.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
797 B

  1. Configure KPIs
  2. ~~~~~~~~~~~~~~
  3. #. Access `Dashboards > Configuration > KPI Dashboards > Configure KPI`
  4. #. Create a new kpi with widget `altair`
  5. You need to define a function like::
  6. import pandas
  7. import altair
  8. class Kpi(models.Model):
  9. _inherit = 'kpi.kpi'
  10. def test_demo_altair(self):
  11. source = pandas.DataFrame(
  12. {
  13. "a": ["A", "B", "C", "D", "E", "F", "G", "H", "I"],
  14. "b": [28, 55, 43, 91, 81, 53, 19, 87, 52],
  15. }
  16. )
  17. chart = altair.Chart(source).mark_bar().encode(x="a", y="b")
  18. return {"altair": json.loads(chart.to_json())}
  19. You can use `code` in a similar way, as `pandas` and `altair` are already defined
  20. when using `code` on an `altair` widget.