ctkchart Library is a Python library that simplifies the process of creating line charts in customtkinter GUI applications.
Project description
🌟 Like what you see? Give us a star! 🚀 Thanks a bunch! 😄
# If you're using tkinter, I recommend checking out tkchart .
Contributing to ctkchart
Examples
https://github.com/Thisal-D/ctkchart/assets/93121062/8cdec09a-d5c1-458c-8575-39b0fbe4f21f
https://github.com/Thisal-D/ctkchart/assets/93121062/05d01144-ad3e-4d7c-aa61-df79acf2e1c7
https://github.com/Thisal-D/ctkchart/assets/93121062/6fb3cba4-909b-46bc-a259-17db5279a1e1
ctkchart - 0.0.2
You need to install & import package first
-
installation
-
pip install ctkchart
-
-
importing
-
import ctkchart
-
objects
- CTkLineChart
- CTkLine
To display data using CTkLineChart you need to do 3 main tasks
- Creating a CTkLineChart
- Creating a CTkLine
- Display of data
1 . Creating a CTkLineChart
linechart = ctkchart.CTkLineChart()
-
Attributes & Types & Values
Master Configuration
- master :
tkinter | customtkinter (Frame | Canvas | Tk)
Dimensions
- width :
int
- height :
int
- axis_size :
int
- x_space :
int
- y_space :
int
- line_width :
int | str
- "auto"
- 10
- pointer_size :
int
Value Configuration
- x_axis_section_count :
int
- y_axis_section_count :
int
- x_axis_label_count :
int
- y_axis_label_count :
int
- x_axis_display_values_indices :
tuple[int, ...]
- x_axis_data :
any
- y_axis_data :
any
- x_axis_values :
tuple[any, ...]
- ("2020 Year", "2021 Year", "2022 Year", "2023 Year", "2024 Year")
- (0.1, 0.2, 0.3, 0.4, 0.5)
- y_axis_values :
tuple[int | float, int | float]
- (0 ,1000)
- (-1000, 1000)
- y_axis_precision :
int
- pointing_values_precision :
int
y_axis_max_value: Deprecated
Color Configuration
- bg_color :
tuple[str, str] | str
- fg_color :
tuple[str, str] | str
- axis_color :
tuple[str, str] | str
- x_axis_font_color :
tuple[str, str] | str
- ("#ffffff", "#000000")
- ("white", "black")
- "white"
- "#ffffff"
- y_axis_font_color :
tuple[str, str] | str
- x_axis_data_font_color :
tuple[str, str] | str
- y_axis_data_font_color :
tuple[str, str] | str
- y_axis_section_color :
tuple[str, str] | str
- x_axis_section_color :
tuple[str, str] | str
- pointer_color :
tuple[str, str] | str
section_color: Deprecated
Font Configuration
- data_font_style :
tuple[str, int, str]
- ("arial", 10, "bold")
- ("arial", 20, "normal")
- axis_font_style :
tuple
Style Configuration
- x_axis_data_position :
str
- "top"
- "side"
- y_axis_data_position :
str
- x_axis_section_style :
str
- "normal"
- "dashed"
- y_axis_section_style :
str
- x_axis_section_style_type :
tuple[int, int]
- (50, 10)
- (10, 10)
- y_axis_section_style_type :
tuple[int, int]
Data Retrieval Configuration
- pointing_callback_function :
function
- function_name(*args)
- function_name(x: any, y: list)
- pointer_state :
str
- "enabled"
- "disabled"
- pointer_lock :
str
- "enabled"
- "disabled"
Recent Changes
-
y_axis_max_value :Deprecatedint | float
-
replaced with y_axis_values :
tuple[int | float, int | float]
The y_axis_values parameter is a tuple where the value at index 0 represents the starting value of the Y-axis, and the value at index 1 represents the ending value of the Y-axis.
-
-
section_color :Deprecatedtuple[str, str] | str
- replaced with x_axis_section_color :
tuple[str, str] | str
- replaced with y_axis_section_color :
tuple[str, str] | str
- replaced with x_axis_section_color :
- master :
-
Methods
-
configure :
use to change CTkLineChart attributes
Support parameters
- width
- height
- axis_size
- x_space
- y_space
- line_width
- pointer_size
- x_axis_section_count
- y_axis_section_count
- x_axis_label_count
- y_axis_label_count
- x_axis_display_values_indices
- x_axis_data
- y_axis_data
- x_axis_values
- y_axis_values
- y_axis_precision
- pointing_values_precision
- bg_color
- fg_color
- axis_color
- x_axis_font_color
- y_axis_font_color
- x_axis_data_font_color
- y_axis_data_font_color
- y_axis_section_color
- x_axis_section_color
- pointer_color
- data_font_style
- axis_font_style
- x_axis_data_position
- y_axis_data_position
- x_axis_section_style
- y_axis_section_style
- x_axis_section_style_type
- y_axis_section_style_type
- pointing_callback_function
- pointer_state
- pointer_lock
y_axis_max_value: Removedsection_color: Removed
-
show_data :
use to display data
Support parameters
- data :
list
- line :
ctkchart.CTkLine
- data :
-
place :
use to place LineChart
Support parameters
- x :
int
- y :
int
- rely :
float | int
- relx :
float | int
- anchor :
str
- x :
-
pack :
use to pack LineChart
Support parameters
- pady :
int
- padx :
int
- before :
widget
- after :
widget
- side :
str
- anchor :
str
- pady :
-
grid :
use to grid LineChart
Support parameters
- column :
int
- columnspan :
int
- padx :
int
- pady :
int
- row :
int
- rowspan :
int
- sticky :
str
- column :
-
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 lines
Support parameters
- state :
bool
- state :
-
hide :
use to hide a specific line
Support parameters
- line :
ctkchart.CTkLine
- state :
bool
- line :
-
reset :
use to reset chart
-
2 . Creating a CTkLine
line = ctkchart.CTkLine()
-
Attributes & Types & Values
- master :
ctkchart.CTkLineChart
- color :
tuple[str, str] | str
- ("#ffffff", "#000000")
- ("white", "black")
- "white"
- "#ffffff"
- size :
int
- style :
str
- "normal"
- "dashed"
- "dotted"
- style_type :
tuple[int, int]
- (5,10)
- (10,5)
- point_highlight:
str
- "disabled"
- "enabled"
- point_highlight_size:
int
- point_highlight_color:
tuple[str, str] | str
- master :
-
Methods
-
configure :
Support parametersuse to change CTkLine attributes
- size
- color
- style
- style_type
- point_highlight
- point_highlight_size
- point_highlight_color
-
line = ctkchart.CTkLine(master=linechart,
color="lightblue",
size=2,
style="dashed",
style_type=(4,10))
3 . Display of Data
import ctkchart
import customtkinter as ctk
from random import choices
root = ctk.CTk()
chart = ctkchart.CTkLineChart(master=root, pointer_state="enabled", width=900, x_axis_values=tuple([x for x in range(20)]),
pointer_lock="enabled", pointer_size=1)
chart.place(x=10,y=10)
line = ctkchart.CTkLine(master=chart)
def loop():
chart.show_data(line=line, data=(choices((range(0,11)),k=1)))
root.after(1000, loop)
loop()
root.mainloop()
Go to top
Contributing to ctkchart
Thank you for considering contributing to ctkchart! Please follow these guidelines to contribute effectively.
Getting Started
- Fork the repository.
- Clone your forked repository:
git clone https://github.com/Thisal-D/ctkchart.git
- Create a new branch for your changes:
git checkout -b feature-branch
Making Changes
- Make your changes and ensure they follow the project's coding standards.
- Test your changes locally.
- Commit your changes:
git commit -m "Brief description of your changes"
Submitting Changes
- Push your changes to your forked repository:
git push origin feature-branch
- Create a pull request on the main repository.
Code of Conduct
Please adhere to the Code of Conduct to maintain a respectful and inclusive community.
Issues and Discussions
If you encounter issues or have questions, please check the issue tracker or start a discussion in the GitHub Discussions section.
License
By contributing, you agree that your contributions will be licensed under the project's LICENSE.
Thank you for your contribution!
go to PyPi
-
PyPi.org : ctkchart
go to GitHub
-
GitHub.com : ctkchart
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
Built Distribution
File details
Details for the file ctkchart-0.0.2.tar.gz
.
File metadata
- Download URL: ctkchart-0.0.2.tar.gz
- Upload date:
- Size: 21.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3f80f173779217c7bb4060041e20c8efc1d6aa967745ac3b9ad6044eb6d7d9a8 |
|
MD5 | 037835f4f2abfdc57d0a3cddb3d04531 |
|
BLAKE2b-256 | 3bee7ab4417b59efed262d13197dd266a10fc000d420eae37ff8a651ee6a7693 |
File details
Details for the file ctkchart-0.0.2-py3-none-any.whl
.
File metadata
- Download URL: ctkchart-0.0.2-py3-none-any.whl
- Upload date:
- Size: 19.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2303622da86f6627b7f745b3c30872f9efccbdddffce30ea5fe39be2d060318b |
|
MD5 | 55e4005837cdd544cd28ab9e96cc86ae |
|
BLAKE2b-256 | 880ebfdad8412b6e2705405a34de8b9c27b8851741838389e7bcc131b9405062 |