RamezIssac / django-slick-reporting

The Reporting Engine for Django. Create dashboards and standalone Reports and Charts.
https://django-slick-reporting.com/
BSD 3-Clause "New" or "Revised" License
550 stars 44 forks source link

How to plot a simple model field #98

Open ramiboutas opened 9 months ago

ramiboutas commented 9 months ago

How to plot a simple model field using chartjs?

I have the folllowing model:

class RoomValue(models.Model):
    time = models.DateTimeField(auto_now_add=True)
    temperature = models.FloatField()
    humility = models.FloatField()
    light = models.FloatField()

I would like just to plot time vs temperature. How can I do that?

I tried the following:

class RoomTemperatures(ReportView):
    report_model = RoomValue
    date_field = "time"
    chart_engine = "chartsjs"

    chart_settings = [
        Chart(
            "Room temperature",
            Chart.LINE,
            data_source=["temperature"],
            title_source=["time"],
            plot_total=True,
        ),
    ]

Thank you very much!

ramiboutas commented 9 months ago

I am trying to use this package in my site:

https://ramiboutas.com/stats/

RamezIssac commented 9 months ago

Hello @ramiboutas :wave: I just want to acknowledge the receipt... I will get back to you soon