From 2d882e5c7d0e7755ad96a2ea6b4494984d9a2924 Mon Sep 17 00:00:00 2001 From: Michael Moen Date: Wed, 25 Sep 2024 14:24:58 -0500 Subject: [PATCH 1/3] Modify plotly figure rendering --- src/python/speedrun.ipynb | 85 ++++++++++++++++++--------------------- 1 file changed, 40 insertions(+), 45 deletions(-) diff --git a/src/python/speedrun.ipynb b/src/python/speedrun.ipynb index 6c3e5ce..d1f7322 100644 --- a/src/python/speedrun.ipynb +++ b/src/python/speedrun.ipynb @@ -16,33 +16,25 @@ "\n", "The Speedrun\\.com API is licensed under [CC BY-NC 4.0](https://creativecommons.org/licenses/by-nc/4.0/), allowing its data to be shared and adapted for non-commercial purposes as long as proper attribution is given. \n", "\n", - "#### Key Features of the Speedrun\\.com API:\n", + "Key Features of the Speedrun\\.com API:\n", "\n", - "1. **Game Information:**\n", - " - Retrieve detailed information about various games available on Speedrun\\.com, including game titles, release dates, and associated categories.\n", + "1. **Game Information:** Retrieve detailed information about various games available on Speedrun\\.com, including game titles, release dates, and associated categories.\n", "\n", - "2. **Category Data:**\n", - " - Access information about different speedrunning categories for each game. Categories define specific rules and objectives for speedruns, such as \"Any%\", \"100%\", or unique challenges like \"16 Star\" in Super Mario 64.\n", + "2. **Category Data:** Access information about different speedrunning categories for each game. Categories define specific rules and objectives for speedruns, such as \"Any%\", \"100%\", or unique challenges like \"16 Star\" in Super Mario 64.\n", "\n", - "3. **Leaderboards:**\n", - " - Fetch leaderboard data to see the top-performing speedruns for a particular game and category. This includes detailed run information, such as the runner, completion time, and submission date.\n", + "3. **Leaderboards:** Fetch leaderboard data to see the top-performing speedruns for a particular game and category. This includes detailed run information, such as the runner, completion time, and submission date.\n", "\n", - "4. **Run Details:**\n", - " - Obtain comprehensive data about individual speedrun attempts, including player information, run times, and dates. This allows for in-depth analysis and tracking of speedrun progress and history.\n", + "4. **Run Details:** Obtain comprehensive data about individual speedrun attempts, including player information, run times, and dates. This allows for in-depth analysis and tracking of speedrun progress and history.\n", "\n", - "5. **User Profiles:**\n", - " - Access user profile data to get information about speedrunners, including their usernames, social media links, and their submitted runs and achievements.\n", + "5. **User Profiles:** Access user profile data to get information about speedrunners, including their usernames, social media links, and their submitted runs and achievements.\n", "\n", - "6. **Platform and Region Information:**\n", - " - Retrieve data related to the platforms (e.g., PC, console) and regions (e.g., NTSC, PAL) used for specific runs, providing context for different versions and conditions under which the runs were performed.\n", + "6. **Platform and Region Information:** Retrieve data related to the platforms (e.g., PC, console) and regions (e.g., NTSC, PAL) used for specific runs, providing context for different versions and conditions under which the runs were performed.\n", "\n", - "#### Rate Limiting and Usage:\n", + "Rate Limiting and Usage:\n", "\n", - "- **Rate Limit:**\n", - " - *Each IP address is allowed to perform a maximum of 100 requests per minute.* This rate limit ensures fair usage and prevents abuse of the API.\n", + "- **Rate Limit:** *Each IP address is allowed to perform a maximum of 100 requests per minute.* This rate limit ensures fair usage and prevents abuse of the API.\n", "\n", - "- **Authentication:**\n", - " - While some endpoints are publicly accessible, certain actions and higher rate limits may require users to authenticate using their personal API keys, which can be obtained by registering on Speedrun\\.com.\n", + "- **Authentication:** While some endpoints are publicly accessible, certain actions and higher rate limits may require users to authenticate using their personal API keys, which can be obtained by registering on Speedrun\\.com.\n", "\n", "*These recipes were tested on September 18, 2024.*" ] @@ -70,7 +62,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 21, "metadata": {}, "outputs": [], "source": [ @@ -79,7 +71,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 22, "metadata": {}, "outputs": [], "source": [ @@ -97,7 +89,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 23, "metadata": {}, "outputs": [], "source": [ @@ -122,7 +114,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 24, "metadata": {}, "outputs": [ { @@ -164,7 +156,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 25, "metadata": {}, "outputs": [ { @@ -173,7 +165,7 @@ "2610" ] }, - "execution_count": 5, + "execution_count": 25, "metadata": {}, "output_type": "execute_result" } @@ -192,7 +184,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 26, "metadata": {}, "outputs": [ { @@ -227,7 +219,7 @@ " 'values': {'e8m7em86': '9qj7z0oq', 'kn04ewol': '4qyxop3l'}}}" ] }, - "execution_count": 6, + "execution_count": 26, "metadata": {}, "output_type": "execute_result" } @@ -239,7 +231,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 27, "metadata": {}, "outputs": [ { @@ -250,7 +242,7 @@ " 'uri': 'https://www.speedrun.com/api/v1/users/zxzk1q9x'}]" ] }, - "execution_count": 7, + "execution_count": 27, "metadata": {}, "output_type": "execute_result" } @@ -270,7 +262,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 28, "metadata": {}, "outputs": [ { @@ -279,7 +271,7 @@ "'ikori_o'" ] }, - "execution_count": 8, + "execution_count": 28, "metadata": {}, "output_type": "execute_result" } @@ -298,7 +290,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 29, "metadata": {}, "outputs": [ { @@ -346,7 +338,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 30, "metadata": {}, "outputs": [ { @@ -380,7 +372,7 @@ " 'values': {'e8m7em86': '9qj7z0oq', 'kn04ewol': '4qyxop3l'}}" ] }, - "execution_count": 10, + "execution_count": 30, "metadata": {}, "output_type": "execute_result" } @@ -402,7 +394,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 31, "metadata": {}, "outputs": [], "source": [ @@ -417,7 +409,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 32, "metadata": {}, "outputs": [ { @@ -532,7 +524,7 @@ "12 46.466667 2023-12-09" ] }, - "execution_count": 12, + "execution_count": 32, "metadata": {}, "output_type": "execute_result" } @@ -559,7 +551,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 33, "metadata": {}, "outputs": [ { @@ -604,7 +596,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 34, "metadata": {}, "outputs": [ { @@ -654,7 +646,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 35, "metadata": {}, "outputs": [], "source": [ @@ -670,7 +662,7 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 36, "metadata": {}, "outputs": [ { @@ -695,7 +687,7 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 37, "metadata": {}, "outputs": [ { @@ -704,7 +696,7 @@ "{'xqk9zzn1': 'No Skips', '81p4xxg1': 'Skips'}" ] }, - "execution_count": 17, + "execution_count": 37, "metadata": {}, "output_type": "execute_result" } @@ -716,7 +708,7 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 38, "metadata": {}, "outputs": [], "source": [ @@ -733,7 +725,7 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 39, "metadata": {}, "outputs": [], "source": [ @@ -790,7 +782,7 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 42, "metadata": {}, "outputs": [ { @@ -1705,6 +1697,9 @@ " yaxis=dict(showgrid=True) # Enable gridlines for the y-axis\n", ")\n", "\n", + "# Write the plot to an HTML file for offline viewing or sharing\n", + "fig.write_html(\"figures/mkw-speedrun-plot.html\")\n", + "\n", "# Display the plot in the notebook (if working in a Jupyter notebook)\n", "fig.show()" ] From 27609b3cc8acabe50b586ec9dabff3bec0c510c3 Mon Sep 17 00:00:00 2001 From: Michael Moen Date: Wed, 25 Sep 2024 14:38:27 -0500 Subject: [PATCH 2/3] Modify plotly rendering --- src/python/speedrun.ipynb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/python/speedrun.ipynb b/src/python/speedrun.ipynb index d1f7322..ac3fce0 100644 --- a/src/python/speedrun.ipynb +++ b/src/python/speedrun.ipynb @@ -782,7 +782,7 @@ }, { "cell_type": "code", - "execution_count": 42, + "execution_count": 48, "metadata": {}, "outputs": [ { @@ -1700,8 +1700,8 @@ "# Write the plot to an HTML file for offline viewing or sharing\n", "fig.write_html(\"figures/mkw-speedrun-plot.html\")\n", "\n", - "# Display the plot in the notebook (if working in a Jupyter notebook)\n", - "fig.show()" + "# Display figure\n", + "fig" ] } ], From fcdebe8d4c613c9e9e3931fd0636c14325459464 Mon Sep 17 00:00:00 2001 From: Michael Moen Date: Wed, 25 Sep 2024 14:40:11 -0500 Subject: [PATCH 3/3] Add JS rendering support for plotly graphs --- _config.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/_config.yml b/_config.yml index e280da1..8ebde9e 100644 --- a/_config.yml +++ b/_config.yml @@ -37,3 +37,7 @@ launch_buttons: binderhub_url: "" jupyterhub_url: "" +sphinx: + config: + html_js_files: + - https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.4/require.min.js