Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/codemation/easycharts
Easily create data visualization of static or streaming data
https://github.com/codemation/easycharts
data-visualization easy fastapi graphs monitoring
Last synced: about 2 months ago
JSON representation
Easily create data visualization of static or streaming data
- Host: GitHub
- URL: https://github.com/codemation/easycharts
- Owner: codemation
- License: mit
- Created: 2021-06-18T10:07:59.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-10-09T08:06:42.000Z (about 3 years ago)
- Last Synced: 2024-10-12T18:59:43.617Z (3 months ago)
- Topics: data-visualization, easy, fastapi, graphs, monitoring
- Language: Python
- Homepage:
- Size: 440 KB
- Stars: 19
- Watchers: 3
- Forks: 2
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
![](images/logo.png)
##
Easily create data visualization of static or streaming data
## Get Started
```python
pip install easycharts
```## Create EasyCharts Server
```python
# charts.py
from fastapi import FastAPI
from easycharts import ChartServerserver = FastAPI()
@server.on_event('startup')
async def setup():
server.charts = await ChartServer.create(
server,
charts_db="test"
)await server.charts.create_dataset(
"test",
labels=['a', 'b', 'c', 'd'],
dataset=[1,2,3,4]
)
```
## Start Server```bash
uvicorn --host 0.0.0.0 --port 0.0.0.0 charts:server```
![](images/get-started-test.png)
## Update Data via API
In a separate window, access the OpenAPI docs to demonstrate dynanimc updates to the graph
```
http://0.0.0.0:8220/docs
```![](images/get-started-update.png)
## Line
![](images/get-started-test-1.png)## Bar
![](images/get-started-test-1-bar.png)## APIS
![](images/get-started-apis.png)
## Real World Usage - Resource Monitoring
```python
import datetime, psutil
import asyncio
from fastapi import FastAPI
from easycharts import ChartServer
from easyschedule import EasySchedulerscheduler = EasyScheduler()
server = FastAPI()every_minute = '* * * * *'
@server.on_event('startup')
async def setup():
asyncio.create_task(scheduler.start())
server.charts = await ChartServer.create(
server,
charts_db="charts_database",
chart_prefix = '/mycharts'
)await server.charts.create_dataset(
"test",
labels=['a', 'b', 'c', 'd'],
dataset=[1,2,3,4]
)# set initial sync time
label=datetime.datetime.now().isoformat()[11:19]
await server.charts.create_dataset(
'cpu',
labels=[label],
dataset=[psutil.cpu_percent()]
)
await server.charts.create_dataset(
'mem',
labels=[label],
dataset=[psutil.virtual_memory().percent]
)@scheduler(schedule=every_minute)
async def resource_monitor():
time_now=datetime.datetime.now().isoformat()[11:19]# updates CPU & MEM datasets with current time
await server.charts.update_dataset(
'cpu',
label=time_now,
data=psutil.cpu_percent()
)
await server.charts.update_dataset(
'mem',
label=time_now,
data=psutil.virtual_memory().percent
)
```![](images/resource-mon.png)