Shellviz makes it easy to quickly create dashboards to visualize data. Here's an example of a quick dashboard for a sample e-commerce company, tracking purchases over the course of the day
The first step of the process is to figure out what you want to visualize. The easiest way to do this is to create an interactive terminal and start exploring your data.
Note: The code in this scenario examples a fictional Django web application written in Python, but everything shown here can also be done using Shellviz' Javascript library. Refer to the Docs for implementation details on each library
ipython
Once you are in your terminal, you create a new instance of Shellviz:
from shellviz import Shellviz
sv = Shellviz()
Now you can start exploring your data:
orders = Order.objects.all() # query the Order data model
sv.table(orders.values('amount', 'created_at', 'summary'))
This has potential, but maybe it makes sense to group the data by a specific date
orders = Order.objects.all() # query the Order data model
orders_by_date = orders.values('date').annotate(total=Sum('total'))
sv.table(orders_by_date)
Now let's turn it into a chart
sv.chart(orders_by_date)
Let's show how much we have collected today
today = datetime.date.today()
today_orders = orders.filter(date=today)
today_total = today_orders.aggregate(total=Sum('total'))['total']
sv.number(total_today)
Let's show a summary of the latest order
latest_order = orders.order_by('-created_at').first()
sv.text(latest_order.get_summary())
Now let's make this updatable. We will start by adding an id
value to each visualization, which will cause existing values to be updated:
sv.table(orders.values('amount', 'created_at', 'summary'), id='order_table')
sv.chart(orders_by_date, id='orders_by_date')
sv.number(total_today, id='total_today')
sv.text(latest_order.get_summary(), id='latest_summary)
And let's add an infinite loop and a delay so the dashboard updates every minute:
while True:
orders = Order.objects.all()
# ...
sv.table(orders.values('amount', 'created_at', 'summary'), id='order_table')
sv.chart(orders_by_date, id='orders_by_date')
sv.number(total_today, id='total_today')
sv.text(latest_order.get_summary(), id='latest_summary)
time.sleep(60) # wait 60 seconds before querying again
Now that you've come up with the visualizations, save this script as .py
file that we can run from the command line:
python dashboard.py