|
import pandas as pd |
|
import matplotlib.pyplot as plt |
|
from collections import Counter |
|
import matplotlib.ticker as ticker |
|
|
|
def category_chart(file_path): |
|
plt.close('all') |
|
|
|
expert_specialties = { |
|
"mireille": "Security Trust", |
|
"khawla": "Network Security", |
|
"guillaume": "Distributed Networks", |
|
"vincent": "USIM Management", |
|
"pierre": "Eco-Design", |
|
"ly-thanh": "Trend Analysis", |
|
"nicolas": "Satellite Networks", |
|
"dorin": "Emergency Communication" |
|
} |
|
|
|
|
|
data = pd.read_excel(file_path) |
|
|
|
|
|
|
|
experts = data['Expert'].dropna() |
|
|
|
|
|
specialties = experts.apply(lambda expert: expert_specialties.get(expert.strip(), "Other")) |
|
|
|
|
|
specialty_counts = specialties.value_counts() |
|
|
|
|
|
specialty_counts_df = specialty_counts.reset_index() |
|
specialty_counts_df.columns = ['Specialty', 'Count'] |
|
|
|
|
|
|
|
fig, ax = plt.subplots(figsize=(14, 14)) |
|
ax.set_facecolor('#222c52') |
|
fig.patch.set_facecolor('#222c52') |
|
|
|
|
|
colors = ['#08F7FE' if i % 2 == 0 else '#FE53BB' for i in range(len(specialty_counts_df))] |
|
specialty_counts_df.plot(kind='bar', x='Specialty', y='Count', ax=ax, color=colors, edgecolor=colors, alpha=0.5, linewidth=5, legend=None) |
|
|
|
|
|
ax.xaxis.label.set_color('white') |
|
ax.yaxis.label.set_color('white') |
|
ax.tick_params(axis='x', colors='white', labelsize=12, direction='out', length=6, width=2, rotation=42) |
|
ax.tick_params(axis='y', colors='white', labelsize=12, direction='out', length=6, width=2) |
|
ax.set_title('Most Used Expert Specialties', color='white', fontsize=16) |
|
ax.set_xlabel('Specialty', fontsize=14) |
|
ax.set_ylabel('Count', fontsize=14) |
|
ax.grid(True, which='both', axis='y', color='gray', linestyle='-', linewidth=0.5, alpha=0.5) |
|
ax.set_axisbelow(True) |
|
|
|
for spine in ax.spines.values(): |
|
spine.set_color('white') |
|
spine.set_linewidth(2) |
|
ax.spines['right'].set_visible(False) |
|
ax.spines['top'].set_visible(False) |
|
|
|
return fig |
|
|
|
|
|
|
|
|
|
def status_chart(file_path): |
|
|
|
plt.close('all') |
|
data = pd.read_excel(file_path) |
|
|
|
|
|
status_counts = data['Status'].value_counts() |
|
|
|
|
|
colors = ['#08F7FE80', '#FE53BB80', |
|
'#fff236de', '#90ff00bf'] |
|
|
|
|
|
fig, ax = plt.subplots() |
|
fig.patch.set_facecolor('#222c52') |
|
ax.set_facecolor('#222c52') |
|
wedges, texts, autotexts = ax.pie(status_counts, autopct='%1.1f%%', startangle=90, colors=colors, |
|
wedgeprops=dict(edgecolor='white', linewidth=1.5)) |
|
|
|
|
|
ax.legend(wedges, status_counts.index, title="Document Status", loc="center left", bbox_to_anchor=(1, 0, 0.5, 1)) |
|
|
|
ax.set_ylabel('') |
|
ax.set_title('Document Status Distribution', color='white') |
|
|
|
plt.setp(autotexts, size=8, weight="bold", color="white") |
|
|
|
return fig |
|
|
|
|
|
|
|
def plot_glowing_line_with_dots_enhanced(ax, x, y, color, label, glow_size=10, base_linewidth=3, markersize=8): |
|
for i in range(1, glow_size + 1): |
|
alpha_value = (1.0 / glow_size) * (i / (glow_size / 2)) |
|
if alpha_value > 1.0: |
|
alpha_value = 1.0 |
|
linewidth = base_linewidth * i * 0.5 |
|
ax.plot(x, y, color=color, linewidth=linewidth, alpha=alpha_value * 0.1) |
|
ax.plot(x, y, color=color, linewidth=base_linewidth, marker='o', linestyle='-', label=label, markersize=markersize) |
|
|
|
def company_document_type(file_path, company_names): |
|
plt.close('all') |
|
|
|
if isinstance(company_names, str): |
|
company_names = [name.strip() for name in company_names.split(',')] |
|
|
|
df = pd.read_excel(file_path) |
|
|
|
fig, ax = plt.subplots(figsize=(14, 8)) |
|
ax.set_facecolor('#222c52') |
|
fig.patch.set_facecolor('#222c52') |
|
|
|
colors = ['#08F7FE', '#FE53BB', '#fff236'] |
|
|
|
max_count = 0 |
|
for index, company_name in enumerate(company_names): |
|
df_company = df[df['Source'].str.contains(company_name, case=False, na=False)] |
|
document_counts = df_company['Type'].value_counts() |
|
all_document_types = df['Type'].unique() |
|
document_counts = document_counts.reindex(all_document_types, fill_value=0) |
|
|
|
x_data = document_counts.index |
|
y_data = document_counts.values |
|
ax.fill_between(x_data, y_data, -0.2, color=colors[index % len(colors)], alpha=0.1) |
|
plot_glowing_line_with_dots_enhanced(ax, x_data, y_data, colors[index % len(colors)], company_name, base_linewidth=4) |
|
|
|
if max_count < max(y_data): |
|
max_count = max(y_data) |
|
|
|
ax.set_xticks(range(len(all_document_types))) |
|
ax.set_xticklabels(all_document_types, rotation=45, fontsize=12, fontweight='bold') |
|
ax.yaxis.set_major_locator(ticker.MaxNLocator(integer=True)) |
|
ax.set_ylabel('Count', color='white') |
|
ax.set_title('Document Types Contributed by Companies') |
|
ax.grid(True, which='both', axis='both', color='gray', linestyle='-', linewidth=0.5, alpha=0.5) |
|
ax.set_axisbelow(True) |
|
|
|
plt.ylim(-0.2, max_count + 1) |
|
|
|
for spine in ax.spines.values(): |
|
spine.set_color('white') |
|
spine.set_linewidth(2) |
|
|
|
ax.spines['right'].set_visible(False) |
|
ax.spines['top'].set_visible(False) |
|
ax.spines['left'].set_position(('data', 0)) |
|
plt.legend(facecolor='#222c52', edgecolor='white', fontsize=12) |
|
|
|
return fig |
|
|
|
|
|
|
|
def chart_by_expert(file_path, expert_name): |
|
plt.close('all') |
|
|
|
data = pd.read_excel(file_path) |
|
|
|
parts = expert_name.split('/') |
|
|
|
|
|
name = parts[1].strip() |
|
|
|
filtered_data = data[data['Expert'] == name.lower()] |
|
|
|
|
|
merge_entities = { |
|
"Nokia Shanghai Bell": "Nokia", |
|
"Qualcomm Korea": "Qualcomm", |
|
"Qualcomm Incorporated": "Qualcomm", |
|
"Huawei Technologies R&D UK": "Huawei", |
|
"Hughes Network Systems": "Hughes", |
|
"HUGHES Network Systems": "Hughes", |
|
"Hughes Network systems": "Hughes", |
|
"HUGHES Network Systems Ltd": "Hughes", |
|
"KT Corp.": "KT Corporation", |
|
"LG Electronics Inc.": "LG Electronics", |
|
"LG Uplus": "LG Electronics", |
|
"OPPO (chongqing) Intelligence": "OPPO", |
|
"Samsung Electronics GmbH": "Samsung", |
|
"China Mobile International Ltd": "China Mobile", |
|
"NOVAMINT": "Novamint", |
|
"Eutelsat": "Eutelsat Group", |
|
"Inmarsat Viasat": "Inmarsat", |
|
"China Telecommunications": "China Telecom", |
|
"SES S.A.": "SES", |
|
"Ericsson GmbH": "Ericsson", |
|
"JSAT": "SKY Perfect JSAT", |
|
"NEC Europe Ltd": "NEC", |
|
"Fraunhofer IIS": "Fraunhofer", |
|
"Hugues Network Systems": "Hughes" |
|
} |
|
|
|
|
|
def normalize_companies(company_list, merge_entities): |
|
normalized = set() |
|
for company in company_list: |
|
normalized_name = merge_entities.get(company.strip(), company.strip()) |
|
normalized.add(normalized_name) |
|
return list(normalized) |
|
|
|
|
|
sources = filtered_data['Source'].dropna() |
|
split_sources = sources.apply(lambda x: normalize_companies(x.split(', '), merge_entities)) |
|
|
|
|
|
all_sources = [company for sublist in split_sources for company in sublist] |
|
|
|
|
|
source_counts = Counter(all_sources) |
|
top_10_sources = source_counts.most_common(10) |
|
|
|
|
|
top_10_df = pd.DataFrame(top_10_sources, columns=['Company', 'Count']) |
|
|
|
|
|
|
|
fig, ax = plt.subplots(figsize=(14, 11)) |
|
ax.set_facecolor('#222c52') |
|
fig.patch.set_facecolor('#222c52') |
|
|
|
|
|
colors = ['#08F7FE' if i % 2 == 0 else '#FE53BB' for i in range(len(top_10_df))] |
|
top_10_df.plot(kind='bar', x='Company', y='Count', ax=ax, color=colors, edgecolor=colors, alpha=0.5, linewidth=5) |
|
|
|
|
|
ax.xaxis.label.set_color('white') |
|
ax.yaxis.label.set_color('white') |
|
ax.tick_params(axis='x', colors='white', labelsize=12, direction='out', length=6, width=2, rotation=45) |
|
ax.tick_params(axis='y', colors='white', labelsize=12, direction='out', length=6, width=2) |
|
ax.set_title(f"Top 10 Cotributors for Expert '{expert_name}'", color='white', fontsize=16) |
|
ax.set_xlabel('Company', fontsize=14) |
|
ax.set_ylabel('Count', fontsize=14) |
|
ax.yaxis.set_major_locator(ticker.MaxNLocator(integer=True)) |
|
ax.grid(True, which='both', axis='y', color='gray', linestyle='-', linewidth=0.5, alpha=0.5) |
|
ax.set_axisbelow(True) |
|
|
|
for spine in ax.spines.values(): |
|
spine.set_color('white') |
|
spine.set_linewidth(2) |
|
ax.spines['right'].set_visible(False) |
|
ax.spines['top'].set_visible(False) |
|
|
|
return fig |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def generate_company_chart(file_path): |
|
|
|
|
|
merge_entities = { |
|
"Nokia Shanghai Bell": "Nokia", |
|
"Qualcomm Korea": "Qualcomm", |
|
"Qualcomm Incorporated": "Qualcomm", |
|
"Huawei Technologies R&D UK": "Huawei", |
|
"Hughes Network Systems": "Hughes", |
|
"HUGHES Network Systems": "Hughes", |
|
"Hughes Network systems": "Hughes", |
|
"HUGHES Network Systems Ltd": "Hughes", |
|
"KT Corp.": "KT Corporation", |
|
"Deutsche Telekom AG": "Deutsche Telekom", |
|
"LG Electronics Inc.": "LG Electronics", |
|
"LG Uplus": "LG Electronics", |
|
"OPPO (chongqing) Intelligence": "OPPO", |
|
"Samsung Electronics GmbH": "Samsung", |
|
"China Mobile International Ltd": "China Mobile", |
|
"NOVAMINT": "Novamint", |
|
"Eutelsat": "Eutelsat Group", |
|
"Inmarsat Viasat": "Inmarsat", |
|
"China Telecommunications": "China Telecom", |
|
"SES S.A.": "SES", |
|
"Ericsson GmbH": "Ericsson", |
|
"JSAT": "SKY Perfect JSAT", |
|
"NEC Europe Ltd": "NEC", |
|
"Fraunhofer IIS": "Fraunhofer", |
|
"Hugues Network Systems": "Hughes" |
|
} |
|
|
|
|
|
def normalize_companies(company_list, merge_entities): |
|
normalized = set() |
|
for company in company_list: |
|
normalized_name = merge_entities.get(company.strip(), company.strip()) |
|
normalized.add(normalized_name) |
|
return list(normalized) |
|
|
|
|
|
data = pd.read_excel(file_path) |
|
|
|
|
|
sources = data['Source'].dropna() |
|
split_sources = sources.apply(lambda x: normalize_companies(x.split(', '), merge_entities)) |
|
|
|
|
|
all_sources = [company for sublist in split_sources for company in sublist] |
|
|
|
|
|
source_counts = Counter(all_sources) |
|
top_10_sources = source_counts.most_common(10) |
|
|
|
|
|
top_10_df = pd.DataFrame(top_10_sources, columns=['Company', 'Count']) |
|
|
|
|
|
|
|
fig, ax = plt.subplots(figsize=(14, 12)) |
|
ax.set_facecolor('#222c52') |
|
fig.patch.set_facecolor('#222c52') |
|
|
|
|
|
colors = ['#08F7FE' if i % 2 == 0 else '#FE53BB' for i in range(len(top_10_df))] |
|
top_10_df.plot(kind='bar', x='Company', y='Count', ax=ax, color=colors, edgecolor=colors, alpha=0.5, linewidth=5, legend=None) |
|
|
|
|
|
ax.xaxis.label.set_color('white') |
|
ax.yaxis.label.set_color('white') |
|
ax.tick_params(axis='x', colors='white', labelsize=16, direction='out', length=6, width=2, rotation=37) |
|
ax.tick_params(axis='y', colors='white', labelsize=12, direction='out', length=6, width=2) |
|
ax.set_title('Top 10 Contributors: Ranking Company Contributions', color='white', fontsize=16) |
|
ax.set_xlabel('Company', fontsize=14) |
|
ax.set_ylabel('Count', fontsize=14) |
|
ax.grid(True, which='both', axis='y', color='gray', linestyle='-', linewidth=0.5, alpha=0.5) |
|
ax.set_axisbelow(True) |
|
|
|
for spine in ax.spines.values(): |
|
spine.set_color('white') |
|
spine.set_linewidth(2) |
|
ax.spines['right'].set_visible(False) |
|
ax.spines['top'].set_visible(False) |
|
|
|
|
|
return fig |
|
|