"Graphic mode in Baserow" with python-baserow-client, plotly

Hey guys.

1. Disclaimer

1.1 I would like to contribute to this specific topic: View: Graphic mode - Graphic mode in Baserow. Initially, I thought I’d respond here instead of the topic, since I’d rather do an initial demo

1.2 Please, see this topic: python-baserow-client. Here is information on how to list the data stored in the baserow through the python-baserow-client library.

1.3 Maybe this request: (View: Graphic mode - Graphic mode in Baserow.) makes sense here: pyhton-baserow-client. Perhaps if someone creates an issue on GitHub of this open project it could be implemented or not this open feature. In my humble opinion, it would make sense to request a graphical rendering engine or mode in opensource libraries that uses baserow. But maybe I’m wrong in that remark here.

1.4 Maybe this can be easily solved with two libraries written in python: python-baserow-client, pyChart.js or plotly. In theory you can choose any rendering library in any programming language, as long as there is a library that communicates with the baserow.

2. Basic Algorithm

2.1. Select the library that communicates with baserow, there are several in nodejs, python or php. Here in my example, I selected the library baserow-python-client.

2.2. Select a graphics library in some programming language that you know. Here I selected the library plotly.

2.3. List the data and import it into an array. In computer science, an array is a data structure consisting of a collection of elements ( values or variables ), of same memory size, each identified by at least one array index or key.

2.4. View the listed data within an array

3. Idea or demo

In this basic algorithm, we use the baserow-python-client library with the plotly library to generate dynamic graphs. The purpose of this code is for demonstration only. Baserow is a great nocode openssource database tool as an alternative to Airtable and there are several libraries who communicate with baserow.

import plotly.express as px
from baserow.client import BaserowClient

client = BaserowClient('https://baserow.io', jwt='...')
# fig = px.bar(x=["a", "b", "c"], y=[1, 3, 2]) # fig.show()

for db in client.list_all_applications():
  px.bar(x=[t.name for t in db.tables], y=[db]).show()

Hope this helps :slight_smile:

Hello @anon59363363, wow, thank you for the contribution! It looks super useful, and building graphs using the Baserow data is a highly requested functionality. I believe a lot of people would benefit from this solution. :heart_hands:

I’m happy with your feedback. Something I noticed in the previous example is that the code I submitted is very simplified. Then, I recreated this same example, and use more stuff. For example, here I made an example from scratch without any external libraries.

import requests
import json 
import matplotlib.pyplot as plt

def Connect(add_id_table, add_token_baserow):
  return requests.get("https://api.baserow.io/api/database/rows/table/"+add_id_table+"/?user_field_names=true", headers={"Authorization": "Token "+add_token_baserow})

def listDatabase(add_property_name):
  viewList = json.loads(json.dumps(Connect('add_id_table','add_token_baserow').json()))
  return viewList[add_property_name]

def dataList(value):
  return enumerate(value)

testTitleName = []
testTitleLastName = []
for index, item in dataList(listDatabase('add_property_name')):
  testTitleName.append(item['testTitleName'])
  testTitleLastName.append(item['testTitleLastName']) 

plt.plot(testTitleName, testTitleLastName)
plt.xlabel('title')
plt.ylabel('dataTitle')
plt.title('My first graph with baserow-api, matplotlib, json, requests!')
plt.show()
Data I used were these This can generate something like

Don’t forget that the free plan has limitations
Please, see this: Baserow free tier limits
1.1 Maximum of 3.000 rows per group/workspace in free plan(Baserow)
1.2 Maximum of 2GB of storage in free plan(Baserow)
1.3 Maximum of 1.000 monthly API requests in free plan(Baserow)
1.4 Support via the community, tutorials, FAQ, user docs in free plan(Baserow)