- 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.
- Dynamic Color Change: Dynamic Color Change for Dark & Light.
- Font Customization: Adjust fonts for text elements to enhance readability.
- Dimension Customization: Customize chart dimensions to fit various display sizes and layouts.
Check out what's new | Changes
-
Installation
pip install ctkchart -
Importing
import ctkchart
-
import package
import ctkchart
-
Create Line Chart and place the chart
chart = ctkchart.CTkLineChart( 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 = ctkchart.CTkLine(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) #call the loop as thead theading.Thread(target=loop).start()
import ctkchart # <- import the package
import tkinter
import random
import threading
import time
#create window
root = tkinter.Tk()
#create chart
chart = ctkchart.CTkLineChart(
master=root,
x_axis_values=("a", "b", "c", "d", "e", "f"),
y_axis_values=(100, 900)
)
chart.place(x=10, y=10) #place chrt
#create line
line = ctkchart.CTkLine(master=chart)
def loop():
while True:
random_data = random.choice(range(100, 900)) #get random data
chart.show_data(line=line, data=[random_data]) # <- display data using chart
time.sleep(1) #wait 1 sec
#call the loop as thead
threading.Thread(target=loop).start()
root.mainloop()- Documentation
- GitHub Repository : ctkchart