Spaces:
Running
Running
Commit ·
412d66d
1
Parent(s): fb7fb3f
Fix translation for Step 6 yield forecast headers and chart titles in results page and PDF utils
Browse files- modules/results.py +18 -24
- utils/pdf_utils.py +19 -26
- utils/translations.py +18 -30
modules/results.py
CHANGED
|
@@ -10971,7 +10971,7 @@ def create_yield_projection_viz(yield_data):
|
|
| 10971 |
|
| 10972 |
return {
|
| 10973 |
'type': 'line_chart',
|
| 10974 |
-
'title': '5-Year Yield Forecast by Investment Scenario',
|
| 10975 |
'subtitle': 'Projected yield increase over 5 years with different investment levels',
|
| 10976 |
'data': {
|
| 10977 |
'categories': [f'Year {year}' for year in years],
|
|
@@ -16589,11 +16589,11 @@ def display_forecast_graph_content(analysis_data, step_number=None, step_title=N
|
|
| 16589 |
# Dynamic header based on step information
|
| 16590 |
if step_number and step_title:
|
| 16591 |
step_prefix = t('step_prefix', 'STEP')
|
| 16592 |
-
|
| 16593 |
-
header_title = f"📈 {step_prefix} {step_number} — {step_title}: {
|
| 16594 |
else:
|
| 16595 |
-
|
| 16596 |
-
header_title = f"📈 {
|
| 16597 |
|
| 16598 |
# Styled header with updated background color
|
| 16599 |
st.markdown(
|
|
@@ -16677,34 +16677,26 @@ def display_forecast_graph_content(analysis_data, step_number=None, step_title=N
|
|
| 16677 |
|
| 16678 |
# Years including baseline (0-5)
|
| 16679 |
years = list(range(0, 6))
|
| 16680 |
-
year_labels = [
|
| 16681 |
-
t('pdf_current', 'Current'),
|
| 16682 |
-
t('pdf_year_1', 'Year 1'),
|
| 16683 |
-
t('pdf_year_2', 'Year 2'),
|
| 16684 |
-
t('pdf_year_3', 'Year 3'),
|
| 16685 |
-
t('pdf_year_4', 'Year 4'),
|
| 16686 |
-
t('pdf_year_5', 'Year 5')
|
| 16687 |
-
]
|
| 16688 |
|
| 16689 |
fig = go.Figure()
|
| 16690 |
|
| 16691 |
# Add baseline reference line
|
| 16692 |
if baseline_yield > 0:
|
| 16693 |
-
current_baseline_text = t('pdf_current_baseline', 'Current Baseline')
|
| 16694 |
fig.add_hline(
|
| 16695 |
y=baseline_yield,
|
| 16696 |
line_dash="dash",
|
| 16697 |
line_color="gray",
|
| 16698 |
-
annotation_text=f"
|
| 16699 |
annotation_position="top right"
|
| 16700 |
)
|
| 16701 |
|
| 16702 |
# Add lines for different investment approaches. Ensure Year 0 matches baseline.
|
| 16703 |
# Always add all three investment lines, even if data is missing
|
| 16704 |
investment_scenarios = [
|
| 16705 |
-
('high_investment',
|
| 16706 |
-
('medium_investment',
|
| 16707 |
-
('low_investment',
|
| 16708 |
]
|
| 16709 |
|
| 16710 |
for scenario_key, scenario_name, color in investment_scenarios:
|
|
@@ -16778,9 +16770,9 @@ def display_forecast_graph_content(analysis_data, step_number=None, step_title=N
|
|
| 16778 |
))
|
| 16779 |
|
| 16780 |
fig.update_layout(
|
| 16781 |
-
title=t('
|
| 16782 |
-
xaxis_title=
|
| 16783 |
-
yaxis_title=
|
| 16784 |
xaxis=dict(
|
| 16785 |
tickmode='array',
|
| 16786 |
tickvals=years,
|
|
@@ -16916,7 +16908,8 @@ def display_economic_forecast(economic_forecast):
|
|
| 16916 |
# Display 5-year projection if available
|
| 16917 |
five_year_projection = economic_forecast.get('five_year_projection', {})
|
| 16918 |
if five_year_projection:
|
| 16919 |
-
|
|
|
|
| 16920 |
|
| 16921 |
# Create projection chart
|
| 16922 |
years = list(range(1, 6))
|
|
@@ -16933,7 +16926,7 @@ def display_economic_forecast(economic_forecast):
|
|
| 16933 |
))
|
| 16934 |
|
| 16935 |
fig.update_layout(
|
| 16936 |
-
title=
|
| 16937 |
xaxis_title="Year",
|
| 16938 |
yaxis_title="Yield (tonnes/hectare)",
|
| 16939 |
height=400
|
|
@@ -17091,7 +17084,8 @@ def display_forecast_visualization(analysis_data):
|
|
| 17091 |
if not forecast_data:
|
| 17092 |
return
|
| 17093 |
|
| 17094 |
-
|
|
|
|
| 17095 |
|
| 17096 |
# Create interactive Plotly chart
|
| 17097 |
years = list(range(2024, 2029))
|
|
|
|
| 10971 |
|
| 10972 |
return {
|
| 10973 |
'type': 'line_chart',
|
| 10974 |
+
'title': t('yield_forecast_by_scenario', '5-Year Yield Forecast by Investment Scenario'),
|
| 10975 |
'subtitle': 'Projected yield increase over 5 years with different investment levels',
|
| 10976 |
'data': {
|
| 10977 |
'categories': [f'Year {year}' for year in years],
|
|
|
|
| 16589 |
# Dynamic header based on step information
|
| 16590 |
if step_number and step_title:
|
| 16591 |
step_prefix = t('step_prefix', 'STEP')
|
| 16592 |
+
forecast_header = t('yield_forecast_5_year_header', '5-Year Yield Forecast & Projections')
|
| 16593 |
+
header_title = f"📈 {step_prefix} {step_number} — {step_title}: {forecast_header}"
|
| 16594 |
else:
|
| 16595 |
+
forecast_header = t('yield_forecast_5_year_header', '5-Year Yield Forecast & Projections')
|
| 16596 |
+
header_title = f"📈 {forecast_header}"
|
| 16597 |
|
| 16598 |
# Styled header with updated background color
|
| 16599 |
st.markdown(
|
|
|
|
| 16677 |
|
| 16678 |
# Years including baseline (0-5)
|
| 16679 |
years = list(range(0, 6))
|
| 16680 |
+
year_labels = ['Current', 'Year 1', 'Year 2', 'Year 3', 'Year 4', 'Year 5']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16681 |
|
| 16682 |
fig = go.Figure()
|
| 16683 |
|
| 16684 |
# Add baseline reference line
|
| 16685 |
if baseline_yield > 0:
|
|
|
|
| 16686 |
fig.add_hline(
|
| 16687 |
y=baseline_yield,
|
| 16688 |
line_dash="dash",
|
| 16689 |
line_color="gray",
|
| 16690 |
+
annotation_text=f"Current Baseline: {baseline_yield:.1f} t/ha",
|
| 16691 |
annotation_position="top right"
|
| 16692 |
)
|
| 16693 |
|
| 16694 |
# Add lines for different investment approaches. Ensure Year 0 matches baseline.
|
| 16695 |
# Always add all three investment lines, even if data is missing
|
| 16696 |
investment_scenarios = [
|
| 16697 |
+
('high_investment', 'High Investment', '#e74c3c'),
|
| 16698 |
+
('medium_investment', 'Medium Investment', '#f39c12'),
|
| 16699 |
+
('low_investment', 'Low Investment', '#27ae60')
|
| 16700 |
]
|
| 16701 |
|
| 16702 |
for scenario_key, scenario_name, color in investment_scenarios:
|
|
|
|
| 16770 |
))
|
| 16771 |
|
| 16772 |
fig.update_layout(
|
| 16773 |
+
title=t('yield_projection_from_baseline', '5-Year Yield Projection from Current Baseline'),
|
| 16774 |
+
xaxis_title='Years',
|
| 16775 |
+
yaxis_title='Yield (tons/ha)',
|
| 16776 |
xaxis=dict(
|
| 16777 |
tickmode='array',
|
| 16778 |
tickvals=years,
|
|
|
|
| 16908 |
# Display 5-year projection if available
|
| 16909 |
five_year_projection = economic_forecast.get('five_year_projection', {})
|
| 16910 |
if five_year_projection:
|
| 16911 |
+
projection_title = t('yield_projection_from_baseline', '5-Year Yield Projection from Current Baseline')
|
| 16912 |
+
st.markdown(f"### 📊 {t('yield_forecast_5_year', '5-Year Yield Forecast')}")
|
| 16913 |
|
| 16914 |
# Create projection chart
|
| 16915 |
years = list(range(1, 6))
|
|
|
|
| 16926 |
))
|
| 16927 |
|
| 16928 |
fig.update_layout(
|
| 16929 |
+
title=t('yield_projection_from_baseline', '5-Year Yield Projection from Current Baseline'),
|
| 16930 |
xaxis_title="Year",
|
| 16931 |
yaxis_title="Yield (tonnes/hectare)",
|
| 16932 |
height=400
|
|
|
|
| 17084 |
if not forecast_data:
|
| 17085 |
return
|
| 17086 |
|
| 17087 |
+
forecast_title = t('yield_forecast_5_year', '5-Year Yield Forecast')
|
| 17088 |
+
st.markdown(f"### 📈 {forecast_title}")
|
| 17089 |
|
| 17090 |
# Create interactive Plotly chart
|
| 17091 |
years = list(range(2024, 2029))
|
utils/pdf_utils.py
CHANGED
|
@@ -1049,7 +1049,7 @@ class PDFReportGenerator:
|
|
| 1049 |
executive_sections.append(f"Year 5 projections: Low {year5_row[1]}, Medium {year5_row[2]}, High {year5_row[3]}")
|
| 1050 |
|
| 1051 |
if not any("year" in section.lower() or "projection" in section.lower() for section in executive_sections[-5:]):
|
| 1052 |
-
executive_sections.append(
|
| 1053 |
executive_sections.append("")
|
| 1054 |
|
| 1055 |
# 7. REGENERATIVE AGRICULTURE - Pull from Step 4
|
|
@@ -4051,7 +4051,8 @@ class PDFReportGenerator:
|
|
| 4051 |
logger.info("🔍 DEBUG Step 6 - Chart is None, adding failure message")
|
| 4052 |
story.append(Paragraph(f"📈 {step_prefix} 6 — {forecast_title}", self.styles['Heading3']))
|
| 4053 |
story.append(Spacer(1, 8))
|
| 4054 |
-
|
|
|
|
| 4055 |
|
| 4056 |
except Exception as e:
|
| 4057 |
logger.error(f"❌ Step 6: Error adding yield forecast chart: {str(e)}")
|
|
@@ -4061,7 +4062,8 @@ class PDFReportGenerator:
|
|
| 4061 |
forecast_title = self._t('pdf_forecast_graph_title', 'Forecast Graph: 5-Year Yield Forecast & Projections')
|
| 4062 |
story.append(Paragraph(f"📈 {step_prefix} 6 — {forecast_title}", self.styles['Heading3']))
|
| 4063 |
story.append(Spacer(1, 8))
|
| 4064 |
-
|
|
|
|
| 4065 |
|
| 4066 |
# Visualizations and Charts - ONLY Step 1 bar graphs; remove charts for Steps 2-6
|
| 4067 |
try:
|
|
@@ -4339,7 +4341,7 @@ class PDFReportGenerator:
|
|
| 4339 |
|
| 4340 |
return {
|
| 4341 |
'type': 'line_chart',
|
| 4342 |
-
'title': '5-Year Yield Forecast by Investment Scenario',
|
| 4343 |
'subtitle': 'Projected yield increase over 5 years with different investment levels',
|
| 4344 |
'data': {
|
| 4345 |
'categories': [f'Year {year}' for year in years],
|
|
@@ -6075,7 +6077,7 @@ class PDFReportGenerator:
|
|
| 6075 |
|
| 6076 |
# Yield Projections Table
|
| 6077 |
if 'yield_projections' in step and step['yield_projections']:
|
| 6078 |
-
story.append(Paragraph(
|
| 6079 |
projections = step['yield_projections']
|
| 6080 |
|
| 6081 |
years = list(range(2025, 2030))
|
|
@@ -6710,7 +6712,7 @@ class PDFReportGenerator:
|
|
| 6710 |
|
| 6711 |
ax.set_xlabel('Year')
|
| 6712 |
ax.set_ylabel('Yield (tonnes/hectare)')
|
| 6713 |
-
ax.set_title('5-Year Yield Projections by Investment Level')
|
| 6714 |
ax.legend()
|
| 6715 |
ax.grid(True, alpha=0.3)
|
| 6716 |
ax.set_xticks(years)
|
|
@@ -7006,7 +7008,7 @@ class PDFReportGenerator:
|
|
| 7006 |
story = []
|
| 7007 |
|
| 7008 |
# 5-Year Yield Forecast header
|
| 7009 |
-
story.append(Paragraph(
|
| 7010 |
story.append(Spacer(1, 12))
|
| 7011 |
|
| 7012 |
# Find yield forecast data from multiple possible locations
|
|
@@ -7134,7 +7136,7 @@ class PDFReportGenerator:
|
|
| 7134 |
# Customize the graph
|
| 7135 |
ax.set_xlabel('Years', fontsize=12, fontweight='bold')
|
| 7136 |
ax.set_ylabel('Yield (tons/ha)', fontsize=12, fontweight='bold')
|
| 7137 |
-
ax.set_title('5-Year Yield Forecast from Current Baseline', fontsize=14, fontweight='bold')
|
| 7138 |
ax.legend(fontsize=10)
|
| 7139 |
ax.grid(True, alpha=0.3)
|
| 7140 |
ax.set_xticks(years)
|
|
@@ -7189,7 +7191,7 @@ class PDFReportGenerator:
|
|
| 7189 |
# Customize the graph
|
| 7190 |
ax.set_xlabel('Years', fontsize=12, fontweight='bold')
|
| 7191 |
ax.set_ylabel('Yield (tons/ha)', fontsize=12, fontweight='bold')
|
| 7192 |
-
ax.set_title('5-Year Yield Forecast - Sample Projections', fontsize=14, fontweight='bold')
|
| 7193 |
ax.legend(fontsize=10)
|
| 7194 |
ax.grid(True, alpha=0.3)
|
| 7195 |
ax.set_xticks(years)
|
|
@@ -7962,30 +7964,22 @@ class PDFReportGenerator:
|
|
| 7962 |
|
| 7963 |
# Years including baseline (0-5) - EXACT SAME AS RESULTS PAGE
|
| 7964 |
years = list(range(0, 6))
|
| 7965 |
-
year_labels = [
|
| 7966 |
-
self._t('pdf_current', 'Current'),
|
| 7967 |
-
self._t('pdf_year_1', 'Year 1'),
|
| 7968 |
-
self._t('pdf_year_2', 'Year 2'),
|
| 7969 |
-
self._t('pdf_year_3', 'Year 3'),
|
| 7970 |
-
self._t('pdf_year_4', 'Year 4'),
|
| 7971 |
-
self._t('pdf_year_5', 'Year 5')
|
| 7972 |
-
]
|
| 7973 |
|
| 7974 |
# Add baseline reference line - EXACT SAME AS RESULTS PAGE
|
| 7975 |
if baseline_yield > 0:
|
| 7976 |
ax.axhline(y=baseline_yield, color='gray', linestyle='--', alpha=0.7, linewidth=2)
|
| 7977 |
# Add annotation text for baseline - position it at top right
|
| 7978 |
-
|
| 7979 |
-
ax.text(1.02, baseline_yield, f'{current_baseline_text}: {baseline_yield:.1f} t/ha',
|
| 7980 |
transform=ax.get_yaxis_transform(), fontsize=10, color='gray',
|
| 7981 |
verticalalignment='center', bbox=dict(boxstyle='round', facecolor='white', alpha=0.8))
|
| 7982 |
|
| 7983 |
# Add lines for different investment approaches - EXACT SAME LOGIC AS RESULTS PAGE
|
| 7984 |
# Always add all three investment lines, even if data is missing
|
| 7985 |
investment_scenarios = [
|
| 7986 |
-
('high_investment',
|
| 7987 |
-
('medium_investment',
|
| 7988 |
-
('low_investment',
|
| 7989 |
]
|
| 7990 |
|
| 7991 |
for scenario_key, scenario_name, color in investment_scenarios:
|
|
@@ -8077,7 +8071,7 @@ class PDFReportGenerator:
|
|
| 8077 |
# Set chart properties - IMPROVED TO MATCH RESULTS PAGE
|
| 8078 |
ax.set_xlabel('Years', fontsize=12, fontweight='bold')
|
| 8079 |
ax.set_ylabel('Yield (tons/ha)', fontsize=12, fontweight='bold')
|
| 8080 |
-
ax.set_title('5-Year Yield Projection from Current Baseline', fontsize=14, fontweight='bold', pad=20)
|
| 8081 |
|
| 8082 |
# Position legend at top right - EXACT SAME AS RESULTS PAGE
|
| 8083 |
ax.legend(loc='upper right', bbox_to_anchor=(1.0, 1.0), framealpha=0.8)
|
|
@@ -8127,8 +8121,7 @@ class PDFReportGenerator:
|
|
| 8127 |
ax.set_xticklabels(year_labels)
|
| 8128 |
|
| 8129 |
# Mandatory footnote
|
| 8130 |
-
|
| 8131 |
-
plt.figtext(0.5, -0.05, footnote_text, ha='center', fontsize=8)
|
| 8132 |
plt.tight_layout()
|
| 8133 |
|
| 8134 |
# Save to buffer with error handling
|
|
@@ -8252,7 +8245,7 @@ class PDFReportGenerator:
|
|
| 8252 |
|
| 8253 |
ax.set_xlabel('Year')
|
| 8254 |
ax.set_ylabel('Yield (tonnes/hectare)')
|
| 8255 |
-
ax.set_title('5-Year Yield Forecast (t/ha)')
|
| 8256 |
ax.legend()
|
| 8257 |
ax.grid(True, alpha=0.3)
|
| 8258 |
|
|
|
|
| 1049 |
executive_sections.append(f"Year 5 projections: Low {year5_row[1]}, Medium {year5_row[2]}, High {year5_row[3]}")
|
| 1050 |
|
| 1051 |
if not any("year" in section.lower() or "projection" in section.lower() for section in executive_sections[-5:]):
|
| 1052 |
+
executive_sections.append(self._t('yield_projections_sustainable', '5-year yield projections indicate sustainable production improvements with proper nutrient management.'))
|
| 1053 |
executive_sections.append("")
|
| 1054 |
|
| 1055 |
# 7. REGENERATIVE AGRICULTURE - Pull from Step 4
|
|
|
|
| 4051 |
logger.info("🔍 DEBUG Step 6 - Chart is None, adding failure message")
|
| 4052 |
story.append(Paragraph(f"📈 {step_prefix} 6 — {forecast_title}", self.styles['Heading3']))
|
| 4053 |
story.append(Spacer(1, 8))
|
| 4054 |
+
error_msg = self._t('yield_forecast_5_year', '5-Year Yield Forecast') + " (t/ha) - Chart generation failed"
|
| 4055 |
+
story.append(Paragraph(error_msg, self.styles['Normal']))
|
| 4056 |
|
| 4057 |
except Exception as e:
|
| 4058 |
logger.error(f"❌ Step 6: Error adding yield forecast chart: {str(e)}")
|
|
|
|
| 4062 |
forecast_title = self._t('pdf_forecast_graph_title', 'Forecast Graph: 5-Year Yield Forecast & Projections')
|
| 4063 |
story.append(Paragraph(f"📈 {step_prefix} 6 — {forecast_title}", self.styles['Heading3']))
|
| 4064 |
story.append(Spacer(1, 8))
|
| 4065 |
+
error_msg = self._t('yield_forecast_5_year', '5-Year Yield Forecast') + " (t/ha) - Chart generation error"
|
| 4066 |
+
story.append(Paragraph(error_msg, self.styles['Normal']))
|
| 4067 |
|
| 4068 |
# Visualizations and Charts - ONLY Step 1 bar graphs; remove charts for Steps 2-6
|
| 4069 |
try:
|
|
|
|
| 4341 |
|
| 4342 |
return {
|
| 4343 |
'type': 'line_chart',
|
| 4344 |
+
'title': self._t('yield_forecast_by_scenario', '5-Year Yield Forecast by Investment Scenario'),
|
| 4345 |
'subtitle': 'Projected yield increase over 5 years with different investment levels',
|
| 4346 |
'data': {
|
| 4347 |
'categories': [f'Year {year}' for year in years],
|
|
|
|
| 6077 |
|
| 6078 |
# Yield Projections Table
|
| 6079 |
if 'yield_projections' in step and step['yield_projections']:
|
| 6080 |
+
story.append(Paragraph(self._t('pdf_yield_projections', '5-Year Yield Projections'), self.styles['Heading3']))
|
| 6081 |
projections = step['yield_projections']
|
| 6082 |
|
| 6083 |
years = list(range(2025, 2030))
|
|
|
|
| 6712 |
|
| 6713 |
ax.set_xlabel('Year')
|
| 6714 |
ax.set_ylabel('Yield (tonnes/hectare)')
|
| 6715 |
+
ax.set_title(self._t('yield_projections_by_level', '5-Year Yield Projections by Investment Level'))
|
| 6716 |
ax.legend()
|
| 6717 |
ax.grid(True, alpha=0.3)
|
| 6718 |
ax.set_xticks(years)
|
|
|
|
| 7008 |
story = []
|
| 7009 |
|
| 7010 |
# 5-Year Yield Forecast header
|
| 7011 |
+
story.append(Paragraph(self._t('yield_forecast_5_year', '5-Year Yield Forecast'), self.styles['Heading1']))
|
| 7012 |
story.append(Spacer(1, 12))
|
| 7013 |
|
| 7014 |
# Find yield forecast data from multiple possible locations
|
|
|
|
| 7136 |
# Customize the graph
|
| 7137 |
ax.set_xlabel('Years', fontsize=12, fontweight='bold')
|
| 7138 |
ax.set_ylabel('Yield (tons/ha)', fontsize=12, fontweight='bold')
|
| 7139 |
+
ax.set_title(self._t('yield_forecast_from_baseline', '5-Year Yield Forecast from Current Baseline'), fontsize=14, fontweight='bold')
|
| 7140 |
ax.legend(fontsize=10)
|
| 7141 |
ax.grid(True, alpha=0.3)
|
| 7142 |
ax.set_xticks(years)
|
|
|
|
| 7191 |
# Customize the graph
|
| 7192 |
ax.set_xlabel('Years', fontsize=12, fontweight='bold')
|
| 7193 |
ax.set_ylabel('Yield (tons/ha)', fontsize=12, fontweight='bold')
|
| 7194 |
+
ax.set_title(self._t('yield_forecast_sample_projections', '5-Year Yield Forecast - Sample Projections'), fontsize=14, fontweight='bold')
|
| 7195 |
ax.legend(fontsize=10)
|
| 7196 |
ax.grid(True, alpha=0.3)
|
| 7197 |
ax.set_xticks(years)
|
|
|
|
| 7964 |
|
| 7965 |
# Years including baseline (0-5) - EXACT SAME AS RESULTS PAGE
|
| 7966 |
years = list(range(0, 6))
|
| 7967 |
+
year_labels = ['Current', 'Year 1', 'Year 2', 'Year 3', 'Year 4', 'Year 5']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7968 |
|
| 7969 |
# Add baseline reference line - EXACT SAME AS RESULTS PAGE
|
| 7970 |
if baseline_yield > 0:
|
| 7971 |
ax.axhline(y=baseline_yield, color='gray', linestyle='--', alpha=0.7, linewidth=2)
|
| 7972 |
# Add annotation text for baseline - position it at top right
|
| 7973 |
+
ax.text(1.02, baseline_yield, f'Current Baseline: {baseline_yield:.1f} t/ha',
|
|
|
|
| 7974 |
transform=ax.get_yaxis_transform(), fontsize=10, color='gray',
|
| 7975 |
verticalalignment='center', bbox=dict(boxstyle='round', facecolor='white', alpha=0.8))
|
| 7976 |
|
| 7977 |
# Add lines for different investment approaches - EXACT SAME LOGIC AS RESULTS PAGE
|
| 7978 |
# Always add all three investment lines, even if data is missing
|
| 7979 |
investment_scenarios = [
|
| 7980 |
+
('high_investment', 'High Investment', '#e74c3c'), # Red
|
| 7981 |
+
('medium_investment', 'Medium Investment', '#f39c12'), # Orange
|
| 7982 |
+
('low_investment', 'Low Investment', '#27ae60') # Green
|
| 7983 |
]
|
| 7984 |
|
| 7985 |
for scenario_key, scenario_name, color in investment_scenarios:
|
|
|
|
| 8071 |
# Set chart properties - IMPROVED TO MATCH RESULTS PAGE
|
| 8072 |
ax.set_xlabel('Years', fontsize=12, fontweight='bold')
|
| 8073 |
ax.set_ylabel('Yield (tons/ha)', fontsize=12, fontweight='bold')
|
| 8074 |
+
ax.set_title(self._t('yield_projection_from_baseline', '5-Year Yield Projection from Current Baseline'), fontsize=14, fontweight='bold', pad=20)
|
| 8075 |
|
| 8076 |
# Position legend at top right - EXACT SAME AS RESULTS PAGE
|
| 8077 |
ax.legend(loc='upper right', bbox_to_anchor=(1.0, 1.0), framealpha=0.8)
|
|
|
|
| 8121 |
ax.set_xticklabels(year_labels)
|
| 8122 |
|
| 8123 |
# Mandatory footnote
|
| 8124 |
+
plt.figtext(0.5, -0.05, "Projections assume continued yearly intervention with recommended nutrient management and stable market conditions.", ha='center', fontsize=8)
|
|
|
|
| 8125 |
plt.tight_layout()
|
| 8126 |
|
| 8127 |
# Save to buffer with error handling
|
|
|
|
| 8245 |
|
| 8246 |
ax.set_xlabel('Year')
|
| 8247 |
ax.set_ylabel('Yield (tonnes/hectare)')
|
| 8248 |
+
ax.set_title(self._t('yield_forecast_tha', '5-Year Yield Forecast (t/ha)'))
|
| 8249 |
ax.legend()
|
| 8250 |
ax.grid(True, alpha=0.3)
|
| 8251 |
|
utils/translations.py
CHANGED
|
@@ -266,6 +266,15 @@ TRANSLATIONS = {
|
|
| 266 |
|
| 267 |
# Yield Forecast
|
| 268 |
'yield_forecast_title': 'Yield Forecast & Projections',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 269 |
'baseline_yield': 'Baseline Yield',
|
| 270 |
'projected_yield': 'Projected Yield',
|
| 271 |
'year_1': 'Year 1',
|
|
@@ -390,21 +399,6 @@ TRANSLATIONS = {
|
|
| 390 |
'pdf_additional_recommendations': 'Additional Recommendations',
|
| 391 |
'pdf_specific_recommendations_rates': 'Specific Recommendations (Rates)',
|
| 392 |
'pdf_forecast_graph_title': 'Forecast Graph: 5-Year Yield Forecast & Projections',
|
| 393 |
-
'pdf_5_year_yield_forecast_projections': '5-Year Yield Forecast & Projections',
|
| 394 |
-
'pdf_5_year_yield_projection_title': '5-Year Yield Projection from Current Baseline',
|
| 395 |
-
'pdf_years': 'Years',
|
| 396 |
-
'pdf_yield_tons_ha': 'Yield (tons/ha)',
|
| 397 |
-
'pdf_current_baseline': 'Current Baseline',
|
| 398 |
-
'pdf_high_investment': 'High Investment',
|
| 399 |
-
'pdf_medium_investment': 'Medium Investment',
|
| 400 |
-
'pdf_low_investment': 'Low Investment',
|
| 401 |
-
'pdf_current': 'Current',
|
| 402 |
-
'pdf_year_1': 'Year 1',
|
| 403 |
-
'pdf_year_2': 'Year 2',
|
| 404 |
-
'pdf_year_3': 'Year 3',
|
| 405 |
-
'pdf_year_4': 'Year 4',
|
| 406 |
-
'pdf_year_5': 'Year 5',
|
| 407 |
-
'pdf_yield_projection_footnote': 'Projections assume continued yearly intervention with recommended nutrient management and stable market conditions.',
|
| 408 |
'pdf_comprehensive_analysis_results': 'Comprehensive Analysis Results:',
|
| 409 |
'pdf_summary': 'Summary',
|
| 410 |
'pdf_detailed_analysis': 'Detailed Analysis',
|
|
@@ -690,6 +684,15 @@ TRANSLATIONS = {
|
|
| 690 |
|
| 691 |
# Yield Forecast (Malaysian)
|
| 692 |
'yield_forecast_title': 'Ramalan & Unjuran Hasil',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 693 |
'baseline_yield': 'Hasil Asas',
|
| 694 |
'projected_yield': 'Hasil Unjuran',
|
| 695 |
'year_1': 'Tahun 1',
|
|
@@ -814,21 +817,6 @@ TRANSLATIONS = {
|
|
| 814 |
'pdf_additional_recommendations': 'Cadangan Tambahan',
|
| 815 |
'pdf_specific_recommendations_rates': 'Cadangan Khusus (Kadar)',
|
| 816 |
'pdf_forecast_graph_title': 'Graf Ramalan: Ramalan & Unjuran Hasil 5 Tahun',
|
| 817 |
-
'pdf_5_year_yield_forecast_projections': 'Ramalan & Unjuran Hasil 5 Tahun',
|
| 818 |
-
'pdf_5_year_yield_projection_title': 'Unjuran Hasil 5 Tahun dari Asas Semasa',
|
| 819 |
-
'pdf_years': 'Tahun',
|
| 820 |
-
'pdf_yield_tons_ha': 'Hasil (tan/ha)',
|
| 821 |
-
'pdf_current_baseline': 'Asas Semasa',
|
| 822 |
-
'pdf_high_investment': 'Pelaburan Tinggi',
|
| 823 |
-
'pdf_medium_investment': 'Pelaburan Sederhana',
|
| 824 |
-
'pdf_low_investment': 'Pelaburan Rendah',
|
| 825 |
-
'pdf_current': 'Semasa',
|
| 826 |
-
'pdf_year_1': 'Tahun 1',
|
| 827 |
-
'pdf_year_2': 'Tahun 2',
|
| 828 |
-
'pdf_year_3': 'Tahun 3',
|
| 829 |
-
'pdf_year_4': 'Tahun 4',
|
| 830 |
-
'pdf_year_5': 'Tahun 5',
|
| 831 |
-
'pdf_yield_projection_footnote': 'Unjuran mengandaikan campur tangan tahunan yang berterusan dengan pengurusan nutrien yang disyorkan dan keadaan pasaran yang stabil.',
|
| 832 |
'pdf_comprehensive_analysis_results': 'Keputusan Analisis Komprehensif:',
|
| 833 |
'pdf_summary': 'Ringkasan',
|
| 834 |
'pdf_detailed_analysis': 'Analisis Terperinci',
|
|
|
|
| 266 |
|
| 267 |
# Yield Forecast
|
| 268 |
'yield_forecast_title': 'Yield Forecast & Projections',
|
| 269 |
+
'yield_forecast_5_year_header': '5-Year Yield Forecast & Projections',
|
| 270 |
+
'yield_forecast_5_year': '5-Year Yield Forecast',
|
| 271 |
+
'yield_projection_from_baseline': '5-Year Yield Projection from Current Baseline',
|
| 272 |
+
'yield_forecast_from_baseline': '5-Year Yield Forecast from Current Baseline',
|
| 273 |
+
'yield_forecast_sample_projections': '5-Year Yield Forecast - Sample Projections',
|
| 274 |
+
'yield_forecast_tha': '5-Year Yield Forecast (t/ha)',
|
| 275 |
+
'yield_forecast_by_scenario': '5-Year Yield Forecast by Investment Scenario',
|
| 276 |
+
'yield_projections_by_level': '5-Year Yield Projections by Investment Level',
|
| 277 |
+
'yield_projections_sustainable': '5-year yield projections indicate sustainable production improvements with proper nutrient management.',
|
| 278 |
'baseline_yield': 'Baseline Yield',
|
| 279 |
'projected_yield': 'Projected Yield',
|
| 280 |
'year_1': 'Year 1',
|
|
|
|
| 399 |
'pdf_additional_recommendations': 'Additional Recommendations',
|
| 400 |
'pdf_specific_recommendations_rates': 'Specific Recommendations (Rates)',
|
| 401 |
'pdf_forecast_graph_title': 'Forecast Graph: 5-Year Yield Forecast & Projections',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 402 |
'pdf_comprehensive_analysis_results': 'Comprehensive Analysis Results:',
|
| 403 |
'pdf_summary': 'Summary',
|
| 404 |
'pdf_detailed_analysis': 'Detailed Analysis',
|
|
|
|
| 684 |
|
| 685 |
# Yield Forecast (Malaysian)
|
| 686 |
'yield_forecast_title': 'Ramalan & Unjuran Hasil',
|
| 687 |
+
'yield_forecast_5_year_header': 'Ramalan & Unjuran Hasil 5 Tahun',
|
| 688 |
+
'yield_forecast_5_year': 'Ramalan Hasil 5 Tahun',
|
| 689 |
+
'yield_projection_from_baseline': 'Unjuran Hasil 5 Tahun dari Asas Semasa',
|
| 690 |
+
'yield_forecast_from_baseline': 'Ramalan Hasil 5 Tahun dari Asas Semasa',
|
| 691 |
+
'yield_forecast_sample_projections': 'Ramalan Hasil 5 Tahun - Unjuran Sampel',
|
| 692 |
+
'yield_forecast_tha': 'Ramalan Hasil 5 Tahun (t/ha)',
|
| 693 |
+
'yield_forecast_by_scenario': 'Ramalan Hasil 5 Tahun mengikut Senario Pelaburan',
|
| 694 |
+
'yield_projections_by_level': 'Unjuran Hasil 5 Tahun mengikut Tahap Pelaburan',
|
| 695 |
+
'yield_projections_sustainable': 'Unjuran hasil 5 tahun menunjukkan peningkatan pengeluaran mampan dengan pengurusan nutrien yang betul.',
|
| 696 |
'baseline_yield': 'Hasil Asas',
|
| 697 |
'projected_yield': 'Hasil Unjuran',
|
| 698 |
'year_1': 'Tahun 1',
|
|
|
|
| 817 |
'pdf_additional_recommendations': 'Cadangan Tambahan',
|
| 818 |
'pdf_specific_recommendations_rates': 'Cadangan Khusus (Kadar)',
|
| 819 |
'pdf_forecast_graph_title': 'Graf Ramalan: Ramalan & Unjuran Hasil 5 Tahun',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 820 |
'pdf_comprehensive_analysis_results': 'Keputusan Analisis Komprehensif:',
|
| 821 |
'pdf_summary': 'Ringkasan',
|
| 822 |
'pdf_detailed_analysis': 'Analisis Terperinci',
|