Skip to main content

Create Line Charts in tkinter Guis...!

Project description

tkchart - 1.0.1



you need to import package first

import tkchart

Mainly there are 2 objects.

  • LineChart
  • Line

To display data using LineChart you need to do 3 main tasks

  1. Create LineChart
  2. Create Line
  3. 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 : int

    y_sections_count : int
    x_sections_count : int
    y_labels_count : int
    x_labels_count : int

    y_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 : int

    sections_color : str
    y_values_color : str
    x_values_color : str
    y_data_text_color : str
    x_data_text_color : str
    bg_color : str
    chart_color : str
    bar_color : str

    x_y_data_font : tuple
    x_y_values_font : tuple
    line_width_auto : bool
    line_width : int

  • Methods

    1. configure: use to change LineChart attributes

    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_text_color 
    x_data_text_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
    
linechart = tkchart.LineChart(master=root,
                            width=1000, 
                            height=600,
                            bar_size=5
                            )

Example Image

linechart = tkchart.LineChart(master=root, 
                            width=1000, 
                            height=600,
                            bar_size=5,

                            y_sections_count=5,
                            x_sections_count=5,
                            y_labels_count=5,
                            x_labels_count=5
                            )

Example Image

linechart = tkchart.LineChart(master=root, width=1000, 
                            height=600,
                            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,
                            )

Example Image

linechart = tkchart.LineChart(master=root, width=1000, 
                            height=600,
                            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="#ffffff",
                            y_values_color="#ffffff",
                            x_values_color="#ffffff",
                            x_data_text_color="#00ffff",
                            y_data_text_color="#ff00ff",
                            bg_color="#202020",
                            chart_color="#101010",
                            bar_color="#909090"
                            )

Example Image

linechart = tkchart.LineChart(master=root, 
                            width=1000, 
                            height=600,
                            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="#505050",
                            y_values_color="#bbbbbb",
                            x_values_color="#bbbbbb",
                            x_data_color="#00ffff",
                            y_data_color="#ff00ff",
                            bg_color="#202020",
                            chart_color="#101010",
                            bar_color="#cccccc",
                            
                            x_y_data_font = ("Arial", 15,"bold"),
                            x_y_values_font = ("Arial", 10,"bold")
                            )

Example Image



1 . Create Line

Create a Line

line = tkchart.Line()

  • Attributes & Types

    master : tkchart.LineChart
    color : str
    size : int

  • Methods

    1. configure: use to change Line attributes

    size 
    color 
    
line = tkchart.Line(master=linechart,
                color="#ffff00",
                size=5)

Example Image

line_width is not a attributes of Line. Its a attribute of LineChart object..!



1 . Display Data

import tkinter
import tkchart
import random #for get random value

#create root 
root = tkinter.Tk()
root.minsize(1200,800)

#create LineChart
linechart = tkchart.LineChart(master=root, 
                            width=1000, 
                            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="#707070",
                            y_values_color="#bbbbbb",
                            x_values_color="#bbbbbb",
                            x_data_color="#00ff00",
                            y_data_color="#00ff00",
                            bg_color="#202020",
                            chart_color="#101010",
                            bar_color="#cccccc",
                            
                            x_y_data_font = ("Arial", 15,"bold"),
                            x_y_values_font = ("Arial", 10,"bold"),
                            )
#place LineChart
linechart.place(x=50 ,y=150)


#Create Line
line = tkchart.Line(master=linechart,
                color="#cccccc",
                size=3)

displayed = 0
max_support = 50 #60-50
data = [0,100,200,300,400,500,600,700,800,900,1000]
start = (20,60)
def loop():
    global displayed
    global start
    linechart.show_data(data=[random.choice(data)], line=line)
    displayed+=1
    if displayed>40:
        start = (start[0]+1,start[1]+1)
        linechart.configure(x_data_min_max=((start[0],start[1])))
    root.after(250,loop)
#calling to loop
loop()

root.mainloop()

output

click to play

Watch the video

For more details

Github.com : tkchart

Project details


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.0.1.tar.gz (11.9 kB view hashes)

Uploaded Source

Built Distribution

tkchart-1.0.1-py3-none-any.whl (8.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page