i want show quarters in first row and years in second row
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 35/100
- Issue type
- Feature
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- python
- Domain
- data-visualization
Research direction
Start with the provided chart setup, especially chart.x_labels and chart.x_labels_major, and inspect how pygal renders major and regular x-axis labels. Reproduce the supplied quarterly data example and determine what API or rendering change would show quarters on one row and years on another; done means the generated chart visibly has both label levels.
Written by the indexing model from the issue text.
Description

Here is my code
import pygal
from openpyxl import load_workbook
Define a function to format the fiscal period labels
def format_fiscal_period(fiscal_period):
quarter, year = fiscal_period.split('-')
quarter = 'Q' + quarter[1]
return f"{quarter}-{year}"
Load the Excel file
wb = load_workbook(filename='C:/Users/wajiha/Test_Jupyter/Assets.xlsx')
Select the sheet you want to read data from
sheet = wb['Data']
Get the data from the sheet
data = []
for row in sheet.iter_rows(min_row=2, values_only=True):
data.append(row)
Group the data by year and quarter
data_by_year_and_quarter = {}
for row in data:
year = row[2]
quarter = row[0]
if year not in data_by_year_and_quarter:
data_by_year_and_quarter[year] = {}
data_by_year_and_quarter[year][quarter] = row[1]
Set the x-labels to be the years
#x_labels_major = ['2012', '2013', '2014', '2015']
x_labels = ['','2012','Q1-12','Q2-12','Q3-12','Q4-12','2013','Q1-13','Q2-13','Q3-13','Q4-13','2014','Q1-14','Q2-14','Q3-14',
'Q4-14','2015','Q1-15','Q2-15','Q3-15','Q4-15']
#x_labels =[format_fiscal_period(quarter)]
Create a Pygal chart
chart = pygal.Bar(x_label_rotation=90)
chart.title = 'Data from Excel'
chart.x_labels = x_labels
chart.x_labels_major = [x_labels[1], x_labels[6], x_labels[11], x_labels[16]]
Add the data to the chart
for year in sorted(data_by_year_and_quarter.keys()):
year_data = data_by_year_and_quarter[year]
data = [year_data.get(quarter, None) for quarter in x_labels]
chart.add(str(year), data)
Render the chart
chart.render_to_file('chart.svg')
- Dominant language
- Python
- Stars
- 2.8k
- Forks
- 419
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Kozea/pygal
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 52/100
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
-
Difficulty 3/5 1-2 days Newbie friendliness 45/100
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
Techiebutler/freeframe#687 ·
Maintainers usually reply within 1 day
-
bug verbose GC
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
IBM/javacore-analyser#677 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
Maintainers usually reply within 2 days
-
area/config comp/plugins P1 platform/qqbot tool/file type/bug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
NousResearch/hermes-agent#163932 · 1 comment ·
Maintainers usually reply within 1 day
-
plugins/dsh: todayStr() computes UTC but is documented as local — journal entries written 00:00–08:00 local land in the previous day's filePossibly taken @Beehtrix claimed this today. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
zilliztech/memsearch#907 · 1 comment ·
Maintainers usually reply within 1 day