-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
264 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
"""Testing""" | ||
from steam_stats import get_recently_played_games | ||
import pygal | ||
|
||
|
||
def generate_svg_for_recently_played_games(player_data): | ||
"""Generate SVG for Recently Played Games in Steam in the last 2 weeks""" | ||
bar_chart = pygal.HorizontalBar( | ||
legend_at_bottom=True, rounded_bars=15, show_legend=True) | ||
bar_chart.title = "Playtime in the Last Two Weeks (hours)" | ||
|
||
# Add data to the chart | ||
if player_data and "response" in player_data and "games" in player_data["response"]: | ||
for game in player_data["response"]["games"]: | ||
if "name" in game and "playtime_2weeks" in game: | ||
playtime_minutes = game["playtime_2weeks"] | ||
playtime_hours = playtime_minutes / 60 # Convert minutes to hours for plotting | ||
|
||
# Determine the label based on the original playtime in minutes | ||
if playtime_minutes >= 60: | ||
# Display in hours if 60 mins or more | ||
label = f"{game["name"]} ({playtime_hours:.2f} hrs)" | ||
else: | ||
# Display in minutes if less than 60 | ||
label = f"{game["name"]} ({playtime_minutes} mins)" | ||
|
||
# Add to chart using the hours value for consistency in scaling | ||
bar_chart.add(label, playtime_hours) | ||
else: | ||
print("No game data available to display") | ||
|
||
# Render the chart to an SVG file | ||
|
||
bar_chart.render_to_file('recently_played_games.svg') | ||
|
||
# Optionally, return the SVG data as a string to embed directly in HTML or Markdown | ||
return bar_chart.render(is_unicode=True) | ||
|
||
|
||
if __name__ == "__main__": | ||
steam_player_data = get_recently_played_games() | ||
generate_svg_for_recently_played_games(steam_player_data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
from steam_workshop import fetch_workshop_item_links, fetch_all_workshop_stats | ||
from main import STEAM_ID | ||
import pygal | ||
|
||
|
||
def generate_svg_for_steam_workshop(total_stats): | ||
"""Generates SVG Card for retrieved Workshop Data using Pygal Radar Chart""" | ||
# Create a Radar chart instance | ||
radar_chart = pygal.Radar( | ||
fill=True, show_legend=True, legend_at_bottom=True) | ||
radar_chart.title = 'Steam Workshop Stats' | ||
|
||
# Define the fields and their respective values | ||
|
||
# Set the labels for the axes | ||
radar_chart.x_labels = ['Total Favorites', | ||
'Total Subscribers', 'Total Unique Visitors'] | ||
|
||
# Add data to the radar chart | ||
radar_chart.add('Total Favorites', total_stats["total_current_favorites"]) | ||
radar_chart.add('Total Subscribers', | ||
total_stats["total_current_subscribers"]) | ||
radar_chart.add('Total Unique Visitors', | ||
total_stats["total_unique_visitors"]) | ||
|
||
# Render the chart to an SVG file | ||
radar_chart.render_to_file('steam_workshop_stats.svg') | ||
|
||
# Optionally, return the SVG data as a string to embed directly in HTML or Markdown | ||
return radar_chart.render(is_unicode=True) | ||
|
||
|
||
def generate_svg_for_steam_workshop_funnel(total_stats): | ||
"""Generates SVG Card for retrieved Workshop Data using Pygal Funnel Chart""" | ||
# Create a Funnel chart instance | ||
funnel_chart = pygal.Funnel(legend_at_bottom=True) | ||
funnel_chart.title = 'Steam Workshop Stats' | ||
|
||
# funnel_chart.x_labels = ['Total Favorites','Total Subscribers', 'Total Unique Visitors'] | ||
|
||
# Add data to the radar chart | ||
funnel_chart.add('Total Subscribers', | ||
total_stats["total_current_subscribers"]) | ||
funnel_chart.add('Total Favorites', total_stats["total_current_favorites"]) | ||
funnel_chart.add('Total Unique Visitors', | ||
total_stats["total_unique_visitors"]) | ||
|
||
# Render the chart to an SVG file | ||
funnel_chart.render_to_file('steam_workshop_stats.svg') | ||
|
||
# Optionally, return the SVG data as a string to embed directly in HTML or Markdown | ||
return funnel_chart.render(is_unicode=True) | ||
|
||
|
||
if __name__ == "__main__": | ||
links = fetch_workshop_item_links(STEAM_ID) | ||
workshop_data = fetch_all_workshop_stats(links) | ||
generate_svg_for_steam_workshop_funnel(workshop_data) |