GithubHelp home page GithubHelp logo

sjoerdtilmans / sjvisualizer Goto Github PK

View Code? Open in Web Editor NEW
156.0 156.0 21.0 208.39 MB

Library to make animated data visualizations from time series data

Home Page: https://www.sjdataviz.com/software

License: MIT License

Python 100.00%
animation animation-library data time-series time-series-analysis

sjvisualizer's People

Contributors

lucky-p-air avatar sjoerdtilmans avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

sjvisualizer's Issues

I have issue relating to DataHandler. I create 2 DataHandler with 2 different dataset but it only recognizes the first dataset.

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

load the data into a data frame

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

creating the canvas

canvas = Canvas.canvas()

adding the racing bar chart

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)

Issue with piechart for styling

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.

Can year increments be based on years in the excel and not just increase by 1

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!

A few questions and requests

hello sj
I am a fan of sjvisualizer.

I have a few questions and requests.

  1. Is it possible to sort the bar chart order? (descending or ascending order)

  2. I want to display the total amount

image

  1. Is there an option to show/not see vertical lines?

  2. Request the line chart racing feature.

thank you

Error while setting SCALEFACTOR in macOS

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.

Update For Stacked Bar Chart

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

Generate random data with 300 data points for each value (updated)

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)

Create a new larger data frame with interpolated values

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)

Create a Tkinter window

root = tk.Tk()
root.title("Smooth Racing Horizontal Stacked Bar Chart")

Adjust the canvas width to accommodate the larger data points

canvas_width = num_data_points * 3 # Adjust this value as needed
canvas_height = 400

Create a canvas for drawing the chart

canvas = tk.Canvas(root, width=canvas_width, height=canvas_height)
canvas.pack()

Function to update the racing bar chart for a specific frame

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')

Determine the number of frames based on the length of the data

num_frames = len(interpolated_data[0]['Value1'])

Start the racing chart for all frames with incremental changes

for frame in range(num_frames):
for _ in range(10): # Incremental steps within each frame
update_chart(frame)

Close the window when done

root.mainloop()
`

Line Chart Suggestion

I often find it useful to find the difference between two points on a line chart. Something like that would be nice to have the option to enable.

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.