Now that we have seen how easy it is to create a static chart, let's take a look at the process of creating a chart that updates in real time. Essentially, the process is the same, but we'll need to periodically update the chart's data series with fresh data. To demonstrate this, let's make a real-time CPU usage monitor.
Displaying real-time data
Building a CPU usage chart
Let's start our CPU monitor in a new class called CPUUsageView:
class CPUUsageView(qtch.QChartView):
num_data_points = 500
chart_title = "CPU Utilization"
def __init__(self):
super().__init__()
chart = qtch.QChart(title=self.chart_title)
self.setChart(chart)
Just as we did with our disk usage...