sjoerdtilmans / sjvisualizer Goto Github PK
View Code? Open in Web Editor NEWLibrary to make animated data visualizations from time series data
Home Page: https://www.sjdataviz.com/software
License: MIT License
Library to make animated data visualizations from time series data
Home Page: https://www.sjdataviz.com/software
License: MIT License
The number of decimal places for the bar_race is set on the canvas
from sjvisualizer import DataHandler, Canvas, BarRace, StaticImage, PieRace
import json
EXCEL_FILE = "/Users/mbp/Desktop/R/Data/data on stock price.xlsx"
EXCEL_FILE_1 = "/Users/mbp/Desktop/R/Data/data on stock volume.xlsx"
FPS = 60
data on stock price.xlsx
data on stock volume.xlsx
DURATION = 0.5
df = DataHandler.DataHandler(excel_file=EXCEL_FILE, number_of_frames=FPSDURATION60).df
df_1 = DataHandler.DataHandler(excel_file=EXCEL_FILE_1, number_of_frames=FPSDURATION60).df
canvas = Canvas.canvas()
bar_chart = BarRace.bar_race(df=df, canvas=canvas.canvas,x_pos=500)
pie_chart = PieRace.pie_plot(df=df_1, canvas=canvas.canvas,x_pos=40,y_pos=200, height = 600, width = 600)
canvas.add_sub_plot(bar_chart)
canvas.add_sub_plot(pie_chart)
numbers and names are overlapping with the pie chart, percentage is not showing for the desirable number of variables. I would say try to make like PieFight(a python library). PieFight looks very beautiful and shows percentage very beautifully far away from per chart.
Check if data is inside a folder or not.
there is no option to add images to the line chart so that we can add a logo or image to accompany the line chart
(https://github.com/SjoerdTilmans/sjvisualizer/assets/98657606/db4ed9ea-c36c-4ecc-a829-0fa2d925b83d)
When I use record=True the fps drops between 1 and 5.
With record=False, we have 30 fps.
Can the increments in the years in the animation be based on the next year in line in the excel and not just increase by 1 always.
For example if the years in my excel are 1990, 1995, 1998, 2004, 2007.... , is it possible to introduce a parameter to set to determine which is the next year (in this case move from 1990 to 1995 to 1998 to 2004 to 2007 etc.) for the animation instead of moving from (1990 to 1991 to 1992 to 1993 etc) which may have no data and will just increase the time for the animation.
In other words, can the year increment factor be made dynamic and not set to 1.
This is in relation to the Bar race which I have been working on, not sure if this issue applies to the other graphs.
Thanks!
AttributeError: module 'ctypes' has no attribute 'windll'
This error is produced when we try to execute ctypes.windll
in a machine with macOS because windll is only available for Windows machine.
Need to use os to find the system's OS and find the Scale Factor accordingly.
It would be great if there could be a new class called a racing stacked horizontal bar chart. The below is a rough example that does not benefit from the better features in the sjvisualizer code.
`import tkinter as tk
import time
import random
import pandas as pd
data = []
categories = ['A', 'B', 'C', 'D']
num_data_points = 300 # Updated to 300 data points
for category in categories:
category_data = {'Category': category}
for value_label in ['Value1', 'Value2', 'Value3']:
value_data = [random.randint(10, 300) for _ in range(num_data_points)] # Updated data range
category_data[value_label] = value_data
data.append(category_data)
interpolated_data = []
num_interpolated_points = 1000 # Number of interpolated points between each original data point
for row in data:
category = row['Category']
interpolated_category_data = {'Category': category}
for value_label in ['Value1', 'Value2', 'Value3']:
original_data = row[value_label]
interpolated_values = []
for i in range(len(original_data) - 1):
for j in range(num_interpolated_points + 1):
interpolated_value = original_data[i] + (original_data[i + 1] - original_data[i]) * j / num_interpolated_points
interpolated_values.append(int(interpolated_value))
interpolated_category_data[value_label] = interpolated_values
interpolated_data.append(interpolated_category_data)
root = tk.Tk()
root.title("Smooth Racing Horizontal Stacked Bar Chart")
canvas_width = num_data_points * 3 # Adjust this value as needed
canvas_height = 400
canvas = tk.Canvas(root, width=canvas_width, height=canvas_height)
canvas.pack()
def update_chart(frame):
bar_height = 30
bar_spacing = 10
x_start = 50
y_start = 50
update_speed = 0.0001 # Smaller value for smoother animation
for row in interpolated_data:
x = x_start
y = y_start
for value_label in ['Value1', 'Value2', 'Value3']:
value = row[value_label][frame]
x2 = x + value
if value_label == 'Value1':
fill_color = 'blue'
elif value_label == 'Value2':
fill_color = 'green'
else:
fill_color = 'orange'
canvas.create_rectangle(x, y, x2, y + bar_height, fill=fill_color)
# Add text labels inside each bar
text_x = (x + x2) / 2
text_y = y + bar_height / 2
canvas.create_text(text_x, text_y, text=str(value), fill='white', font=('Helvetica', 10))
x = x2
y_start += bar_height + bar_spacing
canvas.create_text(x_start - 10, y_start - bar_spacing - bar_height / 2, text=row['Category'], anchor='e')
root.update()
time.sleep(update_speed)
canvas.delete('all')
num_frames = len(interpolated_data[0]['Value1'])
for frame in range(num_frames):
for _ in range(10): # Incremental steps within each frame
update_chart(frame)
root.mainloop()
`
Is there a way to save the generated output, as a .gif or any other format? @SjoerdTilmans
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.