Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # bar graph gen
- itemnames = ["a", "b", "c"]
- itemvalues = [10, 10, 100]
- highest = max(itemvalues)
- from tkinter import *
- root = Tk()
- canvas = Canvas(root, width=600, height=600)
- canvas.pack()
- hline = canvas.create_line(50, 550, 600, 550)
- vline = canvas.create_line(50, 550, 50, 0)
- vscale = highest/10
- bottom = canvas.create_text(42, 10, text="{}".format(highest))
- ts = 0
- for i in range(int(vscale)):
- ts += 10
- positiony = 550/vscale
- canvas.create_text(42, positiony*(i+1), text="{}".format((highest-(ts))))
- fvlog = []
- for i in range(int(len(itemnames))):
- positionx = 550/len(itemnames)
- fvlog.append(positionx*(i+1))
- canvas.create_text(positionx*(i+1), 558, text="{}".format(itemnames[i]))
- barwidth = ((positionx/3))
- toscale = highest
- for i in range(len(itemvalues)):
- barheight = ?????????????????????
- bar = canvas.create_line(fvlog[i], 550, fvlog[i], barheight, width=barwidth, fill='red')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement