tkchart is a Python library for creating live updating line charts in tkinter.
Features
- Live Update: Display live data with line charts.
- Multiple Lines: Support for plotting multiple lines on the same chart for easy comparison.
- Color Customization: Customize colors to match your application's design or data representation.
- Font Customization: Adjust fonts for text elements to enhance readability.
- Dimension Customization: Customize chart dimensions to fit various display sizes and layouts.
Importing & Installation
-
Installation
pip install tkchart
-
Importing
import tkchart
Simple Guide
-
import package
import tkchart
-
Create Line Chart and place the chart
chart = tkchart.LineChart(
master=root,
x_axis_values=("a", "b", "c", "d", "e", "f"),
y_axis_values=(100, 900)
)
chart.place(x=10, y=10)
-
Create Line
line = tkchart.Line(master=chart)
-
Display Data
display data using a loop
def loop():
while True:
random_data = random.choice(range(100, 900))
chart.show_data(line=line, data=[random_data])
time.sleep(1)
theading.Thread(target=loop).start()
Full Code Example
import tkchart
import tkinter
import random
import threading
import time
root = tkinter.Tk()
chart = tkchart.LineChart(
master=root,
x_axis_values=("a", "b", "c", "d", "e", "f"),
y_axis_values=(100, 900)
)
chart.place(x=10, y=10)
line = tkchart.Line(master=chart)
def loop():
while True:
random_data = random.choice(range(100, 900))
chart.show_data(line=line, data=[random_data])
time.sleep(1)
threading.Thread(target=loop).start()
root.mainloop()
Links
Contributors