tkchart Library is a Python library that simplifies the process of creating line charts in tkinter and customtkinter GUI applications.
Project description
tkchart
Examples
tkchart - 1.2.0
You need to install & import package first
-
installation
-
pip install tkchart
-
-
importing
-
import tkchart
-
objects
- LineChart
- Line
To display data using LineChart you need to do 3 main tasks
- Creating a LineChart
- Creating a Line
- Display of data
1 . Creating a LineChart
linechart = tkchart.LineChart()
-
Attributes & Types & Values
- master :
tkinter | customtkinter (Frame | Canvas | Tk) - width :
int - height :
int - axis_size :
int - y_axis_section_count :
int - x_axis_section_count :
int - y_axis_label_count :
int - y_axis_data :
str | int | float - x_axis_data :
str | int | float - y_axis_max_value :
int | float - x_axis_values :
List(str | float| str)- ["2020 Year", "2021 Year", "2022 Year", "2023 Year", "2024 Year"]
- y_axis_precision :
int - section_color :
str- "#ffffff"
- "white"
- y_axis_font_color :
str - x_axis_font_color :
str - y_axis_data_font_color :
str - x_axis_data_font_color :
str - bg_color :
str - fg_color :
str - axis_color :
str - data_font_style :
tuple- ("arial",10,"bold")
- ("arial",20,"normal")
- axis_font_style :
tuple - line_width :
int | str - y_space :
int - x_space :
int - x_axis_data_position :
str- "top"
- "side"
- y_axis_data_position :
str- "top"
- "side"
- master :
-
Methods
-
configure :
use to change LineChart attributesSupport parameters
- height
- axis_size
- y_axis_section_count
- x_axis_section_count
- y_axis_label_count
- y_axis_data
- x_axis_data
- y_axis_max_value
- x_axis_values
- y_axis_precision
- section_color
- y_axis_font_color
- x_axis_font_color
- y_axis_data_font_color
- x_axis_data_font_color
- bg_color
- fg_color
- axis_color
- data_font_style
- axis_font_style
- line_width
- y_space
- x_space
- x_axis_data_position
- y_axis_data_position
-
show_data :
use to display dataSupport parameters
- data :
int - line :
tkchart.Line
- data :
-
place :
use to place LineChartSupport parameters
- x
- y
- rely
- relx
- anchor
-
pack :
use to pack LineChartSupport parameters
- pady
- padx
- before
- after
- side
- ancho
-
grid :
use to grid LineChartSupport parameters
- column
- columnspan
- padx
- pady
- row
- rowspan
- sticky
-
place_forget :
use to place forget the chart -
pack_forget :
use to pack forget the chart -
grid_forget :
use to grid forget the chart -
place_back :
use to place chart in the old location after place forget -
pack_back :
use to pack chart in the old location after pack forget -
grid_back :
use to grid chart in the old location after grid forget -
hide_all :
use to hide all the linesSupport parameters
- state :
bool
- state :
-
hide :
use hide a specific lineSupport parameters
- line :
tkchart.Line - state :
bool
- line :
-
linechart = tkchart.LineChart(master=root,
width=800,
height=400,
axis_size=5
)
linechart = tkchart.LineChart(master=root,
width=800,
height=400,
axis_size=5,
y_axis_section_count=5,
x_axis_section_count=5,
y_axis_label_count=5,
)
linechart = tkchart.LineChart(master=root,
width=800,
height=400,
axis_size=5,
y_axis_section_count=5,
x_axis_section_count=5,
y_axis_label_count=5,
y_axis_data="GB",
x_axis_data="S",
x_axis_values=[1,2,3,4,5,6,7,8,9,10],
y_axis_max_value=1000,
y_axis_precision=5
)
linechart = tkchart.LineChart(master=root,
width=800,
height=400,
axis_size=5,
y_axis_section_count=5,
x_axis_section_count=5,
y_axis_label_count=5,
y_axis_data="GB",
x_axis_data="S",
x_axis_values=[1,2,3,4,5,6,7,8,9,10],
y_axis_max_value=1000,
y_axis_precision=5,
section_color="#404040",
x_axis_font_color="#707070",
y_axis_font_color="#707070",
x_axis_data_font_color="lightblue",
y_axis_data_font_color="lightblue",
bg_color="#202020",
fg_color="#202020",
axis_color="#707070"
)
linechart = tkchart.LineChart(master=root,
width=800,
height=400,
axis_size=5,
y_axis_section_count=5,
x_axis_section_count=5,
y_axis_label_count=5,
y_axis_data="GB",
x_axis_data="S",
x_axis_values=[1,2,3,4,5,6,7,8,9,10],
y_axis_max_value=1000,
y_axis_precision=5,
section_color="#404040",
x_axis_font_color="#707070",
y_axis_font_color="#707070",
x_axis_data_font_color="lightblue",
y_axis_data_font_color="lightblue",
bg_color="#202020",
fg_color="#202020",
axis_color="#707070",
data_font_style=("Arial", 15,"bold"),
axis_font_style=("Arial", 10,"bold")
)
linechart = tkchart.LineChart(master=root,
width=800,
height=400,
axis_size=5,
y_axis_section_count=5,
x_axis_section_count=5,
y_axis_label_count=5,
y_axis_data="GB",
x_axis_data="S",
x_axis_values=[1,2,3,4,5,6,7,8,9,10],
y_axis_max_value=1000,
y_axis_precision=5,
section_color="#404040",
x_axis_font_color="#707070",
y_axis_font_color="#707070",
x_axis_data_font_color="lightblue",
y_axis_data_font_color="lightblue",
bg_color="#202020",
fg_color="#202020",
axis_color="#707070",
data_font_style=("Arial", 15,"bold"),
axis_font_style=("Arial", 10,"bold"),
x_space=20,
y_space=20
)
linechart = tkchart.LineChart(master=root,
width=800,
height=400,
axis_size=5,
y_axis_section_count=5,
x_axis_section_count=5,
y_axis_label_count=5,
y_axis_data="GB",
x_axis_data="S",
x_axis_values=[1,2,3,4,5,6,7,8,9,10],
y_axis_max_value=1000,
y_axis_precision=5,
section_color="#404040",
x_axis_font_color="#707070",
y_axis_font_color="#707070",
x_axis_data_font_color="lightblue",
y_axis_data_font_color="lightblue",
bg_color="#202020",
fg_color="#202020",
axis_color="#707070",
data_font_style=("Arial", 15,"bold"),
axis_font_style=("Arial", 10,"bold"),
x_space=20,
y_space=20,
x_axis_data_position="side",
y_axis_data_position="size"
)
linechart.pack()
2 . Creating a Line
line = tkchart.Line()
-
Attributes & Types & Values
- master :
tkchart.LineChart - color :
str- "white"
- "#10f0f0"
- size :
int - style :
str- "line"
- "dashed"
- "dotted"
- style_type :
tuple(int, int)- (5,10)
- (10,5)
- master :
-
Methods
-
configure :
Support parametersuse to change Line attributes- size
- color
- style
- style_type
-
line = tkchart.Line(master=linechart,
color="lightblue",
size=2,
style="dashed",
style_type=(4,10))
3 . Display of Data
import customtkinter
import tkchart
import random
root = customtkinter.CTk()
linechart = tkchart.LineChart(master=root,
width=800,
height=400,
axis_size=5,
y_axis_section_count=5,
x_axis_section_count=5,
y_axis_label_count=5,
y_axis_data="GB",
x_axis_data="S",
x_axis_values=[1,2,3,4,5,6,7,8,9,10],
y_axis_max_value=1000,
y_axis_precision=5,
section_color="#404040",
x_axis_font_color="#707070",
y_axis_font_color="#707070",
x_axis_data_font_color="lightblue",
y_axis_data_font_color="lightblue",
bg_color="#202020",
fg_color="#202020",
axis_color="#707070",
data_font_style=("Arial", 15,"bold"),
axis_font_style=("Arial", 10,"bold"),
x_space=20,
y_space=20,
x_axis_data_position="side",
y_axis_data_position="size"
)
linechart.pack()
line = tkchart.Line(master=linechart,
color="lightblue",
size=2,
style="dashed",
style_type=(4,10))
data = [0,100,200,300,400,500,600,700,800,900,1000]
def loop():
linechart.show_data(data=[random.choice(data)], line=line)
root.after(250,loop)
loop()
root.mainloop()
Examples
go to GitHub
-
GitHub.com : tkchart
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
tkchart-1.2.0.tar.gz
(17.0 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
tkchart-1.2.0-py3-none-any.whl
(10.9 kB
view details)
File details
Details for the file tkchart-1.2.0.tar.gz.
File metadata
- Download URL: tkchart-1.2.0.tar.gz
- Upload date:
- Size: 17.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
53b08b2f39585c64e8c4931638dfa8d73305638a7efe66a7547cdecba1b4891f
|
|
| MD5 |
504fa0623293ccdce3d819d28466f389
|
|
| BLAKE2b-256 |
21869bcbb66be25100f60813db0657af27502d524567b22e25fcb96b3a4a5a22
|
File details
Details for the file tkchart-1.2.0-py3-none-any.whl.
File metadata
- Download URL: tkchart-1.2.0-py3-none-any.whl
- Upload date:
- Size: 10.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dbcf10e4382b3c86af6a9ff6550afe4ccec23e5e61419360fcd785d7083b9199
|
|
| MD5 |
f0db2b56571dc1fe2790121c1c7976ca
|
|
| BLAKE2b-256 |
9a414ce5b8cf9eeb86db8bf3ea2c843a4edb799185197263a25b32822b7cc3bc
|