datacipen commited on
Commit
16e759f
1 Parent(s): cf0f5e2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -5
app.py CHANGED
@@ -874,7 +874,7 @@ def create_repartition(array_value, selectedData, theme):
874
  else:
875
  options = selectedData['points'][0]['y'][:-3]
876
  else:
877
- customEmplois = "Tous les emplois"
878
  options = df['intitule'].values.tolist()
879
  df = df[df['intitule'].isin(options)]
880
 
@@ -906,7 +906,7 @@ def create_repartition(array_value, selectedData, theme):
906
  }
907
  ],
908
  },font=dict(size=10),paper_bgcolor=paper_bgcolor,autosize=True,clickmode='event+select'
909
- ).add_annotation(x=0, y=-0.85, xanchor='left', yanchor='bottom',
910
  xref='paper', yref='paper', showarrow=False, align='left',
911
  text='La répartition géographique des emplois<br><b>{}</b>'.format(customEmplois),font=dict(size=12))
912
 
@@ -947,7 +947,7 @@ def create_repartition(array_value, selectedData, theme):
947
 
948
  return fig_localisation, fig_competences, fig_transversales, fig_niveau, fig_secteur
949
 
950
- def create_emploi(df, theme):
951
  if theme == "dark":
952
  template = "plotly_dark"
953
  paper_bgcolor = 'rgba(36, 36, 36, 1)'
@@ -960,7 +960,9 @@ def create_emploi(df, theme):
960
  df_intitule = df.groupby('intitule').size().reset_index(name='obs')
961
  df_intitule = df_intitule.sort_values(by=['obs'])
962
  df_intitule = df_intitule.iloc[-25:]
963
- fig_intitule = px.bar(df_intitule, x='obs', y='intitule', height=600, orientation='h', color='obs', template=template, title="Les principaux emplois", labels={'obs':'nombre'}, color_continuous_scale="Teal", text_auto=True).update_layout(font=dict(size=10),paper_bgcolor=paper_bgcolor,plot_bgcolor=plot_bgcolor,clickmode='event+select',autosize=True).update_traces(hovertemplate=df_intitule["intitule"] + ' <br>Nombre : %{x}', y=[y[:100] + "..." for y in df_intitule["intitule"]], showlegend=False)
 
 
964
 
965
  return fig_intitule
966
 
@@ -1071,11 +1073,13 @@ def create_tableau(df, theme):
1071
  def update_emploi(selectedData, array_value, theme):
1072
  options = []
1073
  if selectedData != None:
 
1074
  if type(selectedData['points'][0]['hovertext']) == str:
1075
  options.append(selectedData['points'][0]['hovertext'])
1076
  else:
1077
  options = selectedData['points'][0]['hovertext']
1078
  else:
 
1079
  options = ['01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','2A','2B','21','22','23','24','25','26','27','28','29','30','31','32','33','34','35','36','37','38','39','40','41','42','43','44','45','46','47','48','49','50','51','52','53','54','55','56','57','58','59','60','61','62','63','64','65','66','67','68','69','70','71','72','73','74','75','76','77','78','79','80','81','82','83','84','85','86','87','88','89','90','91','92','93','94','95','971','972','973','974']
1080
 
1081
  df_FT = API_France_Travail(array_value)
@@ -1088,7 +1092,7 @@ def update_emploi(selectedData, array_value, theme):
1088
  df.drop(df[df['lieuTravail'] == 'Bou'].index, inplace = True)
1089
  df.drop(df[df['lieuTravail'] == '976'].index, inplace = True)
1090
  df = df[df['lieuTravail'].isin(options)]
1091
- return create_emploi(df, theme)
1092
 
1093
  @callback(
1094
  Output(component_id='figContrats', component_property='figure'),
 
874
  else:
875
  options = selectedData['points'][0]['y'][:-3]
876
  else:
877
+ customEmplois = " "
878
  options = df['intitule'].values.tolist()
879
  df = df[df['intitule'].isin(options)]
880
 
 
906
  }
907
  ],
908
  },font=dict(size=10),paper_bgcolor=paper_bgcolor,autosize=True,clickmode='event+select'
909
+ ).add_annotation(x=0, y=0.5, xanchor='left', yanchor='bottom',
910
  xref='paper', yref='paper', showarrow=False, align='left',
911
  text='La répartition géographique des emplois<br><b>{}</b>'.format(customEmplois),font=dict(size=12))
912
 
 
947
 
948
  return fig_localisation, fig_competences, fig_transversales, fig_niveau, fig_secteur
949
 
950
+ def create_emploi(df, theme, customRepartition):
951
  if theme == "dark":
952
  template = "plotly_dark"
953
  paper_bgcolor = 'rgba(36, 36, 36, 1)'
 
960
  df_intitule = df.groupby('intitule').size().reset_index(name='obs')
961
  df_intitule = df_intitule.sort_values(by=['obs'])
962
  df_intitule = df_intitule.iloc[-25:]
963
+ fig_intitule = px.bar(df_intitule, x='obs', y='intitule', height=600, orientation='h', color='obs', template=template, labels={'obs':'nombre'}, color_continuous_scale="Teal", text_auto=True).update_layout(font=dict(size=10),paper_bgcolor=paper_bgcolor,plot_bgcolor=plot_bgcolor,clickmode='event+select',autosize=True).update_traces(hovertemplate=df_intitule["intitule"] + ' <br>Nombre : %{x}', y=[y[:100] + "..." for y in df_intitule["intitule"]], showlegend=False).add_annotation(x=0, y=0, xanchor='left', yanchor='bottom',
964
+ xref='paper', yref='paper', showarrow=False, align='left',
965
+ text='Les principaux emplois<br><b>{}</b>'.format(customRepartition),font=dict(size=12))
966
 
967
  return fig_intitule
968
 
 
1073
  def update_emploi(selectedData, array_value, theme):
1074
  options = []
1075
  if selectedData != None:
1076
+ customRepartition = selectedData['points'][0]['hovertext']
1077
  if type(selectedData['points'][0]['hovertext']) == str:
1078
  options.append(selectedData['points'][0]['hovertext'])
1079
  else:
1080
  options = selectedData['points'][0]['hovertext']
1081
  else:
1082
+ customRepartition = " "
1083
  options = ['01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','2A','2B','21','22','23','24','25','26','27','28','29','30','31','32','33','34','35','36','37','38','39','40','41','42','43','44','45','46','47','48','49','50','51','52','53','54','55','56','57','58','59','60','61','62','63','64','65','66','67','68','69','70','71','72','73','74','75','76','77','78','79','80','81','82','83','84','85','86','87','88','89','90','91','92','93','94','95','971','972','973','974']
1084
 
1085
  df_FT = API_France_Travail(array_value)
 
1092
  df.drop(df[df['lieuTravail'] == 'Bou'].index, inplace = True)
1093
  df.drop(df[df['lieuTravail'] == '976'].index, inplace = True)
1094
  df = df[df['lieuTravail'].isin(options)]
1095
+ return create_emploi(df, theme, customRepartition)
1096
 
1097
  @callback(
1098
  Output(component_id='figContrats', component_property='figure'),