Giter VIP home page Giter VIP logo

opjgraph's Introduction

OPJGraph - Easy charts for openHAB and MySQL

Requirements

  • Web server with PHP or PHP-Cli
  • GD support for PHP
  • JpGraph library
  • openHAB with MySQL Persistece

Features

  • View graphs as images directly in your browser or link them in your sitemap as image items.
  • Call "line.php" or "bar.php" from the command line to draw graphs straight to images in your desired location.
  • Call scripts through web page but draw them to file specified in configuration file

Line graph - line.php

  • Time frame is 24 hours.
  • Items with number values are drawn as line.
  • State (On/Off) items are drawn as a bar at the bottom of the graph.
  • Multiple graphs can be drawn under each other as a single image by specifying multiple [chart*] sections in configuration.
  • linegraph.php accepts GET parameter ?period=[today,last24h,yyyy-mm-dd]:
    • today - Today's data from 00:00:00 to 23:59:59.
    • last24h - Latest data to next full hour and 24 hours back.
    • *yyyy-mm-dd - Historical data of specified date e.g. 2018-08-25.

Bar graph - bar.php

  • Time frame is one week and is drawn as a grouped bar plot. One bar is an items average value per day.
  • Only number items are supported.

Web page - index.php + opjgraph.js + dates.php

  • Simple web page to show configured graphs and access historical data.
  • Selection elements for picking a date.
  • Selections are automatically generated from dates in your database. See Configuration - database.ini

Configuration

JpGraph

  • Install the JpGraph library as advised in documentation.
  • Remember to setup include_path for JpGraph in your php.ini.

Configuration file descriptions

Database - database.ini

Setting Example value Description
type mysql Type of database
host your.database.com:3306 Database host
name mydatabase Database name
uname user1 Database username
pw verysecretpassword Database password
timetable outdoortemp_001 Table name where to get all dates for saved data.
  • type - At this time only MySQL database is supported
  • timetable - This is only used for dates.php to get distinct dates from your database.

Line graph - line.ini

Setting Example value Description
title My chart title Title of your graph.
sizev 1000 Vertical size of image in pixels
sizeh 600 Horizonal size of image in pixels
showlegend true Wether to show legend box under chart
legendcols 4 How many columns to have in legend box
legendunit "°C" Text/unit to display after value in legend box
yaxistitle "Celsius" Title for Y-axis
drawtofile false / "imagename.png" Draw to a file.
items[yourlineitem] "line:blue:Outdoor temperature:°C" Number item with blue color and legend title Outdoor temperature.
items[yourstateitem] "state:green:Heat pump" State item with green color and legen title Heat pump.
  • items[yourlineitem] - Item name in the square brackets [ ] as it is in your database.

Bar graph - bar.ini

Setting Example value Description
title My chart title Title of your graph.
sizev 1000 Vertical size of image
sizeh 600 Horizonal size of image
period 7 How many days to show in chart
showlegend true Wether to show legend box under chart
legendcols 4 How many columns to have in legend box
yaxistitle "Celsius" Title for Y-axis
drawtofile false / "imagename.png" Draw to a file.
items[yourbaritem] "lightblue:Indoor temperature" Bar with lightblue color and legend title Indoor temperature
items[yourbaritem] "lightgreen:Outdoor temperature" Bar with lightgreen color and legend title Outdoor temperature
  • items[yourbaritem] - Item name in the square brackets [ ] as it is in your database.

Security

As database.ini file contains your database username and password remember to set up your web server not to allow direct view of .ini files.

For example here's Apache's configuration section to hide all .ini and .inc files:

<Files \*.in\*>
    Order deny,allow
    Deny from all
<\/Files>

License

Licensed under The MIT License (MIT). See LICENSE.txt

Changelog

Ver. 0.2.0 - 6.9.2018

  • Call graph scripts from command line

Ver. 0.1 - 5.9.2018

  • First beta release

Links

opjgraph's People

Contributors

gitmiguel avatar

Stargazers

 avatar

Watchers

 avatar

opjgraph's Issues

Run graph creation scripts from command line

Problem?
Scripts are only executed with web request.

Solution
Ability to run linegraph.php and bargraph.php through cli.

Additional context
Options:

  • Both .php scripts has their own section to handle command line execution and arguments.
  • Create new script e.g. "cli.php" to handle cli execution and call other scripts respectively.

Dates are not displayed in bar graph

The bug

Dates are not displayed in bar graph

To Reproduce

  1. Open browser and view graphs
  2. See error in bar graph

Expected behavior

Dates should be shown in graph.

Environment

  • Device: Desktop
  • OS: Debian 9
  • Browser: Firefox ESR
  • Version: 0.1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.