Create Line Charts in tkinter Guis...!
Project description
tkchart
Examples
tkchart - 1.0.6
you need to install & import package first
installation
pip install tkchart
importing
import tkchart
Mainly there are 2 objects.
- LineChart
- Line
To display data using LineChart you need to do 3 main tasks
- Create LineChart
- Create Line
- Display data
1 . Create LineChart
Create a LineChart
linechart = tkchart.LineChart()
-
Attributes & Types
master
: tkinter.widget (Frame, Canvas, Tk)
width
: int
height
: int
bar_size
: inty_sections_count
: int
x_sections_count
: int
y_labels_count
: int
x_labels_count
: inty_data
: str ,int, float
x_data
: str ,int, float
y_data_max
: int ,float
x_data_min_max
: touple(min ,max)
y_values_decimals
: int
x_values_decimals
: intsections_color
: str
y_values_color
: str
x_values_color
: str
y_data_color
: str
x_data_color
: str
bg_color
: str
chart_color
: str
bar_color
: strx_y_data_font
: tuple
x_y_values_font
: tuple
line_width_auto
: bool
line_width
: int -
Methods
1. configure
: use to change LineChart attributessupport **kwargs
width height bar_size y_sections_count x_sections_count y_labels_count x_labels_count y_data x_data y_data_max x_data_min_max y_values_decimals x_values_decimals sections_color y_values_color x_values_color y_data_color x_data_color bg_color chart_color bar_color x_y_data_font x_y_values_font line_width_auto line_width
2. show_data
: use to display data.support **kwargs
data line
3. place
: use to place same as tkinter place method..!support **kwargs
x y rely relx anchor
4. pack
: use to pack. same as tkinter pack method..!support **kwargs
pady padx before after side ipadx ipady ancho
5. grid
: use to grid. same as tkinter grid method..!support **kwargs
column columnspan ipadx ipady padx pady row rowspan sticky
6. place_forget
: use to place forget the chart7. pack_forget
: use to pack forget the chart8. grid_forget
: use to grid forget the chart9. place_back
: use to place chart in the old location after place forget10. pack_back
: use to pack chart in the old location after pack forget11. grid_back
: use to grid chart in the old location after grid forget12. hide_all
: use to hide all the linessupport **kwargs
state: Bool
13. hide
: use hide a specific linesupport **kwargs
line: tkchart.Line state: bool
linechart = tkchart.LineChart(master=root,
width=800,
height=400,
bar_size=5
)
linechart = tkchart.LineChart(master=root,
width=800,
height=400,
bar_size=5,
y_sections_count=5,
x_sections_count=5,
y_labels_count=5,
x_labels_count=5,
)
linechart = tkchart.LineChart(master=root,
width=800,
height=400,
bar_size=5,
y_sections_count=5,
x_sections_count=5,
y_labels_count=5,
x_labels_count=5,
y_data="GB",
x_data="S",
x_data_min_max=(20,60),
y_data_max=1000,
x_values_decimals=4,
y_values_decimals=5
)
linechart = tkchart.LineChart(master=root,
width=800,
height=400,
bar_size=5,
y_sections_count=5,
x_sections_count=5,
y_labels_count=5,
x_labels_count=5,
y_data="GB",
x_data="S",
x_data_min_max=(20,60),
y_data_max=1000,
x_values_decimals=4,
y_values_decimals=5,
sections_color="#404040",
y_values_color="#707070",
x_values_color="#707070",
x_data_color="lightblue",
y_data_color="lightblue",
bg_color="#202020",
chart_color="#202020",
bar_color="#707070"
)
linechart = tkchart.LineChart(master=root,
width=800,
height=400,
bar_size=5,
y_sections_count=5,
x_sections_count=5,
y_labels_count=5,
x_labels_count=5,
y_data="GB",
x_data="S",
x_data_min_max=(20,60),
y_data_max=1000,
x_values_decimals=4,
y_values_decimals=5,
sections_color="#404040",
y_values_color="#707070",
x_values_color="#707070",
x_data_color="lightblue",
y_data_color="lightblue",
bg_color="#202020",
chart_color="#202020",
bar_color="#707070",
x_y_data_font = ("Arial", 15,"bold"),
x_y_values_font = ("Arial", 10,"bold")
)
2 . Create Line
Create a Line
line = tkchart.Line()
-
Attributes & Types
master
: tkchart.LineChart
color
: str
size
: int
mode
: str
mode_style
: tuple -
Methods
1. configure
: use to change Line attributessize color mode mode_style
line = tkchart.Line(master=linechart,
color="lightblue",
size=2,
mode="dash",
mode_style=(4,10))
3 . Display Data
import tkchart
import customtkinter
root = customtkinter.CTk()
root.geometry("1048x599+442+239")
linechart = tkchart.LineChart(master=root,
width=800,
height=400,
bar_size=5,
y_sections_count=5,
x_sections_count=5,
y_labels_count=5,
x_labels_count=5,
y_data="GB",
x_data="S",
x_data_min_max=(20,60),
y_data_max=1000,
x_values_decimals=4,
y_values_decimals=5,
sections_color="#404040",
y_values_color="#707070",
x_values_color="#707070",
x_data_color="lightblue",
y_data_color="lightblue",
bg_color="#202020",
chart_color="#202020",
bar_color="#707070",
x_y_data_font = ("Arial", 15,"bold"),
x_y_values_font = ("Arial", 10,"bold")
)
linechart.pack(pady=100)
line = tkchart.Line(master=linechart,
color="lightblue",
size=2,
mode="dash",
mode_style=(4,10))
import random
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)
#calling to loop
loop()
root.mainloop()
output
click to play
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.