Skip to content
Snippets Groups Projects
Commit 531f6bcd authored by maxvaisto's avatar maxvaisto
Browse files

Added initial plot for Market Performance

parent 6dc602f9
No related branches found
No related tags found
No related merge requests found
...@@ -9,11 +9,13 @@ from dash_plot_generation.styles_and_handles import RATING_MIN_REVIEWS, RATING_S ...@@ -9,11 +9,13 @@ from dash_plot_generation.styles_and_handles import RATING_MIN_REVIEWS, RATING_S
DEV_AVERAGE_RATING_LABEL, DENSITY_LAYOUT_STYLE, WHITE_STEAM, TAB_COLOR, TAB_EDGE, \ DEV_AVERAGE_RATING_LABEL, DENSITY_LAYOUT_STYLE, WHITE_STEAM, TAB_COLOR, TAB_EDGE, \
TAB_HEADER_COLOR, DEVELOPER_DROPDOWN, DEV_TOP_GENRES_LABEL, DEV_CCU_LABEL, DEV_GAME_COUNT_LABEL, \ TAB_HEADER_COLOR, DEVELOPER_DROPDOWN, DEV_TOP_GENRES_LABEL, DEV_CCU_LABEL, DEV_GAME_COUNT_LABEL, \
DEV_REV_PER_GAME_LABEL, DEV_REVENUE_LABEL, DEV_TOP_GAMES, RATING_TABS, RATING_TABS_OUTPUT_AREA, \ DEV_REV_PER_GAME_LABEL, DEV_REVENUE_LABEL, DEV_TOP_GAMES, RATING_TABS, RATING_TABS_OUTPUT_AREA, \
GENRE_PREDICTION_GRAPH, GENRE_DROPDOWN, DEFAULT_PLOT_STYLE_DICT, GAMES_BY_DEV_GRAPH GENRE_PREDICTION_GRAPH, GENRE_DROPDOWN, DEFAULT_PLOT_STYLE_DICT, GAMES_BY_DEV_GRAPH, MARKET_PERFORMANCE_SCATTER, \
MP_COMPANY_TYPE_DROPDOWN, create_market_scatter_plot_style
from dash_plot_generation.utils import get_average_user_rating_label, get_game_count_label, get_top_revenue_game_labels, \ from dash_plot_generation.utils import get_average_user_rating_label, get_game_count_label, get_top_revenue_game_labels, \
get_total_revenue_label, get_top_genre_labels, get_ccu_label, get_average_game_rev_label get_total_revenue_label, get_top_genre_labels, get_ccu_label, get_average_game_rev_label
from visual_presentation.Annual_release_games import get_game_release_figure from visual_presentation.Annual_release_games import get_game_release_figure
from visual_presentation.Distribution_of_review_rating import get_rating_density_plot from visual_presentation.Distribution_of_review_rating import get_rating_density_plot
from visual_presentation.Market_performance_function import plot_market_performance
APP = dash.Dash( APP = dash.Dash(
name=__name__, name=__name__,
...@@ -140,6 +142,13 @@ def get_genre_prediction_table(genre, **kwargs): ...@@ -140,6 +142,13 @@ def get_genre_prediction_table(genre, **kwargs):
return fig return fig
@APP.callback(Output(MARKET_PERFORMANCE_SCATTER, "figure"),
Input(MP_COMPANY_TYPE_DROPDOWN, "value"))
def get_market_performance_scatter(company_type):
style = create_market_scatter_plot_style(company_type)
return plot_market_performance(FULL_DATA, company_type, 100, 0, **style)
if __name__ == "__main__": if __name__ == "__main__":
initialize_data() initialize_data()
APP.run_server(debug=True, host="0.0.0.0") APP.run_server(debug=True, host="0.0.0.0")
...@@ -137,6 +137,9 @@ body { ...@@ -137,6 +137,9 @@ body {
.dash-dropdown .Select-menu-outer { .dash-dropdown .Select-menu-outer {
background-color: var(--TAB_COLOR); background-color: var(--TAB_COLOR);
} }
.dash-dropdown {
color: var(--WHITE_STEAM);
}
.jsx-4017309047.tab-container{ .jsx-4017309047.tab-container{
border-bottom: 2px solid var(--TAB_EDGE); border-bottom: 2px solid var(--TAB_EDGE);
......
...@@ -7,11 +7,9 @@ from dash_plot_generation.styles_and_handles import RATING_MIN_REVIEWS, RATING_S ...@@ -7,11 +7,9 @@ from dash_plot_generation.styles_and_handles import RATING_MIN_REVIEWS, RATING_S
DEFAULT_PLOT_STYLE_DICT, WHITE_STEAM, TAB_COLOR, TAB_EDGE, DEVELOPER_DROPDOWN, \ DEFAULT_PLOT_STYLE_DICT, WHITE_STEAM, TAB_COLOR, TAB_EDGE, DEVELOPER_DROPDOWN, \
DEV_TOP_GENRES_LABEL, DEV_CCU_LABEL, DEV_GAME_COUNT_LABEL, DEV_REV_PER_GAME_LABEL, \ DEV_TOP_GENRES_LABEL, DEV_CCU_LABEL, DEV_GAME_COUNT_LABEL, DEV_REV_PER_GAME_LABEL, \
DEV_REVENUE_LABEL, DEV_TOP_GAMES, RATING_TABS, RATING_TABS_OUTPUT_AREA, GENRE_DROPDOWN, GENRE_PREDICTION_GRAPH, \ DEV_REVENUE_LABEL, DEV_TOP_GAMES, RATING_TABS, RATING_TABS_OUTPUT_AREA, GENRE_DROPDOWN, GENRE_PREDICTION_GRAPH, \
GAMES_BY_DEV_GRAPH GAMES_BY_DEV_GRAPH, MARKET_PERFORMANCE_SCATTER, MP_COMPANY_TYPE_DROPDOWN
from dash_plot_generation.data_store import FULL_DATA, OWNER_RANGE_PARTS_SORTED from dash_plot_generation.data_store import FULL_DATA, OWNER_RANGE_PARTS_SORTED
from dash_plot_generation.utils import get_all_genres, extract_unique_companies, split_companies, \
get_genre_popularity_counts
global APP, FULL_DATA global APP, FULL_DATA
...@@ -229,14 +227,27 @@ layout = html.Div( ...@@ -229,14 +227,27 @@ layout = html.Div(
children=[ children=[
html.Div( html.Div(
children=[ children=[
html.Div(id="Market performance_top", html.Div(children=[
children=[ html.Div(children=[dcc.Graph(id=MARKET_PERFORMANCE_SCATTER,
html.Div(children=[dcc.Graph()], figure=go.Figure(
style={"width": "60%", "display": "inline-block"}), layout=DEFAULT_PLOT_STYLE_DICT |
html.Div(children=[html.H5("First plot text")], dict(
style={"width": "30%", "display": "inline-block"}) title="Market performance",
] margin=dict(l=20, r=20,
), t=50,
b=20)))
)],
style={"width": "60%", "vertical-align": "top",
"display": "inline-block", "margin-right":"5%"}),
html.Div(children=[html.H5("First plot text"),
dcc.Dropdown(id=MP_COMPANY_TYPE_DROPDOWN,
className='dash-dropdown',
value="developer",
options=["developer", "publisher"])],
style={"width": "30%", "vertical-align": "top",
"display": "inline-block"})
], style={"display": "flex", "align-items": "flex-start", "margin-bottom":"50px"}
),
html.Div(id="Market performance_second", html.Div(id="Market performance_second",
children=[ children=[
html.Div(children=[dcc.Graph()], html.Div(children=[dcc.Graph()],
...@@ -265,7 +276,7 @@ layout = html.Div( ...@@ -265,7 +276,7 @@ layout = html.Div(
dcc.Dropdown(id=DEVELOPER_DROPDOWN, value="Valve", dcc.Dropdown(id=DEVELOPER_DROPDOWN, value="Valve",
options=[{"label": html.Span([developer], style={'color': WHITE_STEAM}), options=[{"label": html.Span([developer], style={'color': WHITE_STEAM}),
"value": developer} for developer in unique_developers], "value": developer} for developer in unique_developers],
style={'margin-top': '20px', 'color': WHITE_STEAM}, style={'margin-top': '20px'},
className='dash-dropdown', className='dash-dropdown',
), ),
html.Div(children=[ html.Div(children=[
......
# html handles # html handles
RATING_MIN_REVIEWS = "min_reviews_id" RATING_MIN_REVIEWS = "min_reviews_id"
RATING_SLIDER = "rating_slider" RATING_SLIDER = "rating_slider"
...@@ -24,7 +23,6 @@ GENRE_DROPDOWN = "genre_dropdown" ...@@ -24,7 +23,6 @@ GENRE_DROPDOWN = "genre_dropdown"
GENRE_PREDICTION_GRAPH = "Genre_prediction_graph" GENRE_PREDICTION_GRAPH = "Genre_prediction_graph"
GAMES_BY_DEV_GRAPH = "game_releases_by_dev_graph" GAMES_BY_DEV_GRAPH = "game_releases_by_dev_graph"
SPACE_NORMAL_ENTRY = 35 SPACE_NORMAL_ENTRY = 35
# Colors # Colors
...@@ -48,6 +46,18 @@ DEFAULT_PLOT_STYLE_DICT = dict( ...@@ -48,6 +46,18 @@ DEFAULT_PLOT_STYLE_DICT = dict(
DENSITY_LAYOUT_STYLE = DEFAULT_PLOT_STYLE_DICT | dict( DENSITY_LAYOUT_STYLE = DEFAULT_PLOT_STYLE_DICT | dict(
title='Distribution of Game Review Rating', title='Distribution of Game Review Rating',
xaxis_title="Game user rating", xaxis_title="Game User Rating",
yaxis_title="Proportion" yaxis_title="Proportion"
) )
\ No newline at end of file
MARKET_PERFORMANCE_SCATTER = "Market_performance_scatter"
MP_COMPANY_TYPE_DROPDOWN = "market_performance_company_type_dropdown"
def create_market_scatter_plot_style(company_type):
return {
**DEFAULT_PLOT_STYLE_DICT,
'title': f'Market Performance for {company_type} companies',
"xaxis_title": "Revenue",
"yaxis_title": "Number of Game Owners",
}
...@@ -7,7 +7,7 @@ from dash_plot_generation.utils import get_owner_means, convert_owners_to_limits ...@@ -7,7 +7,7 @@ from dash_plot_generation.utils import get_owner_means, convert_owners_to_limits
# The function to plot the bubble chart of market performance # The function to plot the bubble chart of market performance
def plot_market_performance(df, company_type: str, game_number_max: int, game_number_min: int): def plot_market_performance(df, company_type: str, game_number_max: int, game_number_min: int, **layout_arguments):
""" """
This function creates a bubble chart of market performance. This function creates a bubble chart of market performance.
...@@ -33,7 +33,7 @@ def plot_market_performance(df, company_type: str, game_number_max: int, game_nu ...@@ -33,7 +33,7 @@ def plot_market_performance(df, company_type: str, game_number_max: int, game_nu
# Bubble chart # Bubble chart
fig = px.scatter(filter_company_stats, x='revenue', y='owner_number', size='game_number', log_y=True, log_x=True,size_max = 40, fig = px.scatter(filter_company_stats, x='revenue', y='owner_number', size='game_number', log_y=True, log_x=True,size_max = 40,
hover_name='company_split', title=f'Market Performance of {company_type}') hover_name='company_split', title=f'Market Performance of {company_type}')
fig.update_layout(**layout_arguments)
return fig return fig
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment