Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Dashboard and Fixed some eroor in Tier 1&2csv file #22

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
223 changes: 223 additions & 0 deletions Betterplayer.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,223 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"ename": "NameError",
"evalue": "name 'total_kills' is not defined",
"output_type": "error",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[1;31mNameError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[1;32mIn [4], line 106\u001b[0m\n\u001b[0;32m 87\u001b[0m kills_figure \u001b[39m=\u001b[39m {\n\u001b[0;32m 88\u001b[0m \u001b[39m'\u001b[39m\u001b[39mdata\u001b[39m\u001b[39m'\u001b[39m: [{\n\u001b[0;32m 89\u001b[0m \u001b[39m'\u001b[39m\u001b[39mtype\u001b[39m\u001b[39m'\u001b[39m: \u001b[39m'\u001b[39m\u001b[39mpie\u001b[39m\u001b[39m'\u001b[39m,\n\u001b[1;32m (...)\u001b[0m\n\u001b[0;32m 96\u001b[0m \n\u001b[0;32m 97\u001b[0m }\n\u001b[0;32m 99\u001b[0m \u001b[39m# Define Pie chart\u001b[39;00m\n\u001b[0;32m 100\u001b[0m pie_chart \u001b[39m=\u001b[39m dcc\u001b[39m.\u001b[39mGraph(\n\u001b[0;32m 101\u001b[0m \u001b[39mid\u001b[39m\u001b[39m=\u001b[39m\u001b[39m'\u001b[39m\u001b[39mpie-chart\u001b[39m\u001b[39m'\u001b[39m,\n\u001b[0;32m 102\u001b[0m figure\u001b[39m=\u001b[39m{\n\u001b[0;32m 103\u001b[0m \u001b[39m'\u001b[39m\u001b[39mdata\u001b[39m\u001b[39m'\u001b[39m: [\n\u001b[0;32m 104\u001b[0m go\u001b[39m.\u001b[39mPie(\n\u001b[0;32m 105\u001b[0m labels\u001b[39m=\u001b[39m[\u001b[39m'\u001b[39m\u001b[39mKills\u001b[39m\u001b[39m'\u001b[39m, \u001b[39m'\u001b[39m\u001b[39mDeaths\u001b[39m\u001b[39m'\u001b[39m],\n\u001b[1;32m--> 106\u001b[0m values\u001b[39m=\u001b[39m[total_kills, total_deaths],\n\u001b[0;32m 107\u001b[0m hoverinfo\u001b[39m=\u001b[39m\u001b[39m'\u001b[39m\u001b[39mlabel+value+percent\u001b[39m\u001b[39m'\u001b[39m,\n\u001b[0;32m 108\u001b[0m textinfo\u001b[39m=\u001b[39m\u001b[39m'\u001b[39m\u001b[39mlabel+value\u001b[39m\u001b[39m'\u001b[39m,\n\u001b[0;32m 109\u001b[0m textfont\u001b[39m=\u001b[39m\u001b[39mdict\u001b[39m(size\u001b[39m=\u001b[39m\u001b[39m20\u001b[39m),\n\u001b[0;32m 110\u001b[0m marker\u001b[39m=\u001b[39m\u001b[39mdict\u001b[39m(colors\u001b[39m=\u001b[39m[\u001b[39m'\u001b[39m\u001b[39mrgb(0, 153, 51)\u001b[39m\u001b[39m'\u001b[39m, \u001b[39m'\u001b[39m\u001b[39mrgb(255, 0, 0)\u001b[39m\u001b[39m'\u001b[39m])\n\u001b[0;32m 111\u001b[0m )\n\u001b[0;32m 112\u001b[0m ],\n\u001b[0;32m 113\u001b[0m \u001b[39m'\u001b[39m\u001b[39mlayout\u001b[39m\u001b[39m'\u001b[39m: {\n\u001b[0;32m 114\u001b[0m \u001b[39m'\u001b[39m\u001b[39mtitle\u001b[39m\u001b[39m'\u001b[39m: {\u001b[39m'\u001b[39m\u001b[39mtext\u001b[39m\u001b[39m'\u001b[39m: \u001b[39m'\u001b[39m\u001b[39mKills vs Deaths\u001b[39m\u001b[39m'\u001b[39m},\n\u001b[0;32m 115\u001b[0m \u001b[39m'\u001b[39m\u001b[39mshowlegend\u001b[39m\u001b[39m'\u001b[39m: \u001b[39mFalse\u001b[39;00m\n\u001b[0;32m 116\u001b[0m }\n\u001b[0;32m 117\u001b[0m }\n\u001b[0;32m 118\u001b[0m )\n\u001b[0;32m 119\u001b[0m \u001b[39m# Define Bar chart\u001b[39;00m\n\u001b[0;32m 120\u001b[0m bar_chart \u001b[39m=\u001b[39m dcc\u001b[39m.\u001b[39mGraph(\n\u001b[0;32m 121\u001b[0m \u001b[39mid\u001b[39m\u001b[39m=\u001b[39m\u001b[39m'\u001b[39m\u001b[39mbar-chart\u001b[39m\u001b[39m'\u001b[39m,\n\u001b[0;32m 122\u001b[0m figure\u001b[39m=\u001b[39m{\n\u001b[1;32m (...)\u001b[0m\n\u001b[0;32m 135\u001b[0m }\n\u001b[0;32m 136\u001b[0m )\n",
"\u001b[1;31mNameError\u001b[0m: name 'total_kills' is not defined"
]
}
],
"source": [
"import plotly.express as px\n",
"import dash\n",
"import dash_core_components as dcc\n",
"import dash_html_components as html\n",
"import pandas as pd\n",
"import plotly.graph_objects as go\n",
"\n",
"# Load the data into a Pandas dataframe\n",
"df = pd.read_csv('Datasets\\Tier1&2.csv')\n",
"\n",
"# Define the Dash app\n",
"app = dash.Dash(__name__)\n",
"\n",
"# Define layout\n",
"app.layout = html.Div([\n",
" html.H1(\"Player Stats Dashboard\"),\n",
" dcc.Dropdown(\n",
" id='player-dropdown',\n",
" options=[\n",
" {'label': 'Player 1', 'value': 'player1'},\n",
" {'label': 'Player 2', 'value': 'player2'}\n",
" ],\n",
" value='player1'\n",
" ),\n",
" html.Div([\n",
" dcc.Graph(\n",
" id='kills-indicator',\n",
" figure={\n",
" 'data': [{\n",
" 'type': 'pie',\n",
" 'hole': 0.4,\n",
" 'values': [100],\n",
" 'textinfo': 'none',\n",
" 'marker': {'colors': ['#636efa']}\n",
" }],\n",
" 'layout': {\n",
" 'title': {'text': 'Total Kills'},\n",
" 'annotations': [{\n",
" 'font': {'size': 30},\n",
" 'showarrow': False,\n",
" 'text': '250',\n",
" 'x': 0.5,\n",
" 'y': 0.5\n",
" }]\n",
" }\n",
" }\n",
" ),\n",
" dcc.Graph(\n",
" id='kd-ratio-indicator',\n",
" figure={\n",
" 'data': [{\n",
" 'type': 'pie',\n",
" 'hole': 0.4,\n",
" 'values': [100],\n",
" 'textinfo': 'none',\n",
" 'marker': {'colors': ['#ef553b']}\n",
" }],\n",
" 'layout': {\n",
" 'title': {'text': 'K/D Ratio'},\n",
" 'annotations': [{\n",
" 'font': {'size': 30},\n",
" 'showarrow': False,\n",
" 'text': '1.2',\n",
" 'x': 0.5,\n",
" 'y': 0.5\n",
" }]\n",
" }\n",
" }\n",
" )\n",
" ], style={'display': 'flex', 'justify-content': 'space-evenly'})\n",
"])\n",
"\n",
"\n",
"@app.callback(\n",
" [dash.dependencies.Output('kills-indicator', 'figure'),\n",
" dash.dependencies.Output('kd-ratio-indicator', 'figure')],\n",
" [dash.dependencies.Input('player-dropdown', 'value')]\n",
")\n",
"def update_indicators(player):\n",
" if player == 'player1':\n",
" kills = 250\n",
" kd_ratio = 1.2\n",
" else:\n",
" kills = 300\n",
" kd_ratio = 1.3\n",
" \n",
" kills_figure = {\n",
" 'data': [{\n",
" 'type': 'pie',\n",
" 'hole': 0.4,\n",
" 'values': [kills],\n",
" 'textinfo': 'none',\n",
" 'marker': {'colors': ['#636efa']}\n",
" }],\n",
" \n",
" \n",
" }\n",
"\n",
" # Define Pie chart\n",
"pie_chart = dcc.Graph(\n",
" id='pie-chart',\n",
" figure={\n",
" 'data': [\n",
" go.Pie(\n",
" labels=['Kills', 'Deaths'],\n",
" values=[total_kills, total_deaths],\n",
" hoverinfo='label+value+percent',\n",
" textinfo='label+value',\n",
" textfont=dict(size=20),\n",
" marker=dict(colors=['rgb(0, 153, 51)', 'rgb(255, 0, 0)'])\n",
" )\n",
" ],\n",
" 'layout': {\n",
" 'title': {'text': 'Kills vs Deaths'},\n",
" 'showlegend': False\n",
" }\n",
" }\n",
")\n",
"# Define Bar chart\n",
"bar_chart = dcc.Graph(\n",
" id='bar-chart',\n",
" figure={\n",
" 'data': [\n",
" go.Bar(\n",
" x=['Player 1', 'Player 2'],\n",
" y=[player1_kd_ratio, player2_kd_ratio],\n",
" marker=dict(color=['rgb(0, 153, 51)', 'rgb(255, 0, 0)'])\n",
" )\n",
" ],\n",
" 'layout': {\n",
" 'title': {'text': 'K/D Ratio'},\n",
" 'yaxis': {'title': 'K/D Ratio'},\n",
" 'showlegend': False\n",
" }\n",
" }\n",
")\n",
"\n",
"# Define Line chart\n",
"line_chart = dcc.Graph(\n",
" id='line-chart',\n",
" figure={\n",
" 'data': [\n",
" go.Scatter(\n",
" x=player1_age_rating['Age'],\n",
" y=player1_age_rating['Rating'],\n",
" mode='lines',\n",
" name='Player 1',\n",
" line=dict(color='rgb(0, 153, 51)')\n",
" ),\n",
" go.Scatter(\n",
" x=player2_age_rating['Age'],\n",
" y=player2_age_rating['Rating'],\n",
" mode='lines',\n",
" name='Player 2',\n",
" line=dict(color='rgb(255, 0, 0)')\n",
" )\n",
" ],\n",
" 'layout': {\n",
" 'title': {'text': 'Rating over Time'},\n",
" 'xaxis': {'title': 'Age'},\n",
" 'yaxis': {'title': 'Rating'},\n",
" 'showlegend': True\n",
" }\n",
" }\n",
")\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.0"
},
"orig_nbformat": 4,
"vscode": {
"interpreter": {
"hash": "369f2c481f4da34e4445cda3fffd2e751bd1c4d706f27375911949ba6bb62e1c"
}
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Binary file added Dashboard s1mple vs ZywOo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Dashboard.pbix
Binary file not shown.
Loading