Skip to content
Snippets Groups Projects
Commit 8981205d authored by Max Väistö's avatar Max Väistö
Browse files

Added slider for revenue in revenue statistics

parent 531f6bcd
No related branches found
No related tags found
No related merge requests found
...@@ -10,7 +10,7 @@ from dash_plot_generation.styles_and_handles import RATING_MIN_REVIEWS, RATING_S ...@@ -10,7 +10,7 @@ from dash_plot_generation.styles_and_handles import RATING_MIN_REVIEWS, RATING_S
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, MARKET_PERFORMANCE_SCATTER, \ 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 MP_COMPANY_TYPE_DROPDOWN, create_market_scatter_plot_style, REVENUE_COMPANY_GAME_COUNT
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
...@@ -143,10 +143,12 @@ def get_genre_prediction_table(genre, **kwargs): ...@@ -143,10 +143,12 @@ def get_genre_prediction_table(genre, **kwargs):
@APP.callback(Output(MARKET_PERFORMANCE_SCATTER, "figure"), @APP.callback(Output(MARKET_PERFORMANCE_SCATTER, "figure"),
Input(MP_COMPANY_TYPE_DROPDOWN, "value")) Input(MP_COMPANY_TYPE_DROPDOWN, "value"),
def get_market_performance_scatter(company_type): Input(REVENUE_COMPANY_GAME_COUNT, "value"))
def get_market_performance_scatter(company_type, company_game_onwer_range):
style = create_market_scatter_plot_style(company_type) style = create_market_scatter_plot_style(company_type)
return plot_market_performance(FULL_DATA, company_type, 100, 0, **style) return plot_market_performance(df=FULL_DATA, company_type=company_type, game_number_min=company_game_onwer_range[0],
game_number_max=company_game_onwer_range[1], **style)
if __name__ == "__main__": if __name__ == "__main__":
......
...@@ -7,9 +7,10 @@ from dash_plot_generation.styles_and_handles import RATING_MIN_REVIEWS, RATING_S ...@@ -7,9 +7,10 @@ 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, MARKET_PERFORMANCE_SCATTER, MP_COMPANY_TYPE_DROPDOWN GAMES_BY_DEV_GRAPH, MARKET_PERFORMANCE_SCATTER, MP_COMPANY_TYPE_DROPDOWN, REVENUE_COMPANY_GAME_COUNT
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_cumulative_owner_game_count_limits_for_dev_and_pub
global APP, FULL_DATA global APP, FULL_DATA
...@@ -34,7 +35,10 @@ max_reviews = numpy.nanmax(FULL_DATA.apply(lambda x: x["positive"] + x["negative ...@@ -34,7 +35,10 @@ max_reviews = numpy.nanmax(FULL_DATA.apply(lambda x: x["positive"] + x["negative
owner_range_dict = {index: val_str for (index, (val, val_str)) in enumerate(OWNER_RANGE_PARTS_SORTED)} owner_range_dict = {index: val_str for (index, (val, val_str)) in enumerate(OWNER_RANGE_PARTS_SORTED)}
min_owner = min(owner_range_dict.keys()) min_owner = min(owner_range_dict.keys())
max_owner = max(owner_range_dict.keys()) max_owner = max(owner_range_dict.keys())
cumulative_owner_ranges = get_cumulative_owner_game_count_limits_for_dev_and_pub(FULL_DATA)
cum_range_limits = {
"min": min(cumulative_owner_ranges["developer"]["min"], cumulative_owner_ranges["publisher"]["max"]),
"max": max(cumulative_owner_ranges["developer"]["max"], cumulative_owner_ranges["publisher"]["max"])}
layout = html.Div( layout = html.Div(
children=[ children=[
html.Div(className="row", children=[ html.Div(className="row", children=[
...@@ -237,16 +241,29 @@ layout = html.Div( ...@@ -237,16 +241,29 @@ layout = html.Div(
t=50, t=50,
b=20))) b=20)))
)], )],
style={"width": "60%", "vertical-align": "top", style={"width": "80%", "vertical-align": "top",
"display": "inline-block", "margin-right":"5%"}), "display": "inline-block", "margin-right": "5%"}),
html.Div(children=[html.H5("First plot text"), html.Div(children=[html.H5("Filters"),
dcc.Dropdown(id=MP_COMPANY_TYPE_DROPDOWN, dcc.Dropdown(id=MP_COMPANY_TYPE_DROPDOWN,
className='dash-dropdown', className='dash-dropdown',
value="developer", value="developer",
options=["developer", "publisher"])], options=["developer", "publisher"]),
style={"width": "30%", "vertical-align": "top", dcc.RangeSlider(id=REVENUE_COMPANY_GAME_COUNT,
min=cum_range_limits["min"],
max=cum_range_limits["max"],
step=cum_range_limits["min"],
value=[cum_range_limits["min"],
cum_range_limits["max"]],
marks=None,
tooltip={"placement": "right",
"always_visible": True},
vertical=True,
verticalHeight=200),
],
style={"width": "15%", "vertical-align": "top",
"display": "inline-block"}) "display": "inline-block"})
], style={"display": "flex", "align-items": "flex-start", "margin-bottom":"50px"} ], style={"display": "flex", "align-items": "flex-start",
"margin-bottom": "50px"}
), ),
html.Div(id="Market performance_second", html.Div(id="Market performance_second",
children=[ children=[
......
...@@ -42,6 +42,7 @@ DEFAULT_PLOT_STYLE_DICT = dict( ...@@ -42,6 +42,7 @@ DEFAULT_PLOT_STYLE_DICT = dict(
template="plotly_dark", template="plotly_dark",
plot_bgcolor=TAB_COLOR, plot_bgcolor=TAB_COLOR,
paper_bgcolor=TAB_COLOR, paper_bgcolor=TAB_COLOR,
margin=dict(l=20, r=20, t=50, b=20)
) )
DENSITY_LAYOUT_STYLE = DEFAULT_PLOT_STYLE_DICT | dict( DENSITY_LAYOUT_STYLE = DEFAULT_PLOT_STYLE_DICT | dict(
...@@ -60,4 +61,8 @@ def create_market_scatter_plot_style(company_type): ...@@ -60,4 +61,8 @@ def create_market_scatter_plot_style(company_type):
'title': f'Market Performance for {company_type} companies', 'title': f'Market Performance for {company_type} companies',
"xaxis_title": "Revenue", "xaxis_title": "Revenue",
"yaxis_title": "Number of Game Owners", "yaxis_title": "Number of Game Owners",
} }
REVENUE_COMPANY_GAME_COUNT = "revenue_slider_company_popularity"
...@@ -203,15 +203,26 @@ def get_average_game_rev_label(data): ...@@ -203,15 +203,26 @@ def get_average_game_rev_label(data):
dev_game_revenue_per_game = " ".join(["", dev_game_revenue_per_game_row]) dev_game_revenue_per_game = " ".join(["", dev_game_revenue_per_game_row])
return dev_game_revenue_per_game return dev_game_revenue_per_game
def get_all_genres(df): def get_all_genres(df):
unique_genres = set() unique_genres = set()
try: try:
for index, row in df.iterrows(): for index, row in df.iterrows():
if not isinstance(row.genres, str): if not isinstance(row.genres, str):
continue continue
fully_split = row.genres.split(", ") fully_split = row.genres.split(", ")
unique_genres.update(fully_split) unique_genres.update(fully_split)
except Exception as ex: except Exception as ex:
pass pass
return unique_genres return unique_genres
def get_cumulative_owner_game_count_limits_for_dev_and_pub(df):
owner_cum_sums_dev = df[["developer"]].value_counts()
min_owner_dev = 1
max_owner_dev = owner_cum_sums_dev.iloc[0]
owner_cum_sums_pub = df[["publisher"]].value_counts()
min_owner_pub = 1
max_owner_pub = owner_cum_sums_pub.iloc[0]
return {"developer": {"min": min_owner_dev, "max": max_owner_dev},
"publisher": {"min": min_owner_pub, "max": max_owner_pub}}
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