Skip to content

Commit e19a560

Browse files
authored
Add files via upload
1 parent 8023ca0 commit e19a560

File tree

2 files changed

+51
-12
lines changed

2 files changed

+51
-12
lines changed

040-f1-constructor-standings-dashboard/script.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -171,18 +171,23 @@ function drawSummaryTable(teamData, teamColors) {
171171
d3.select("#summaryTable").html(tableHTML);
172172
}
173173

174-
// --- D3.js animated line chart for team points evolution ---
174+
// --- D3.js animated, fully responsive line chart ---
175175
function drawLineChart(teamData, races, season, teamColors) {
176176
d3.select("#chart").html(""); // reset
177177

178+
// Responsive: use a fixed viewBox and scale to width 100%
178179
const margin = { top: 28, right: 24, bottom: 40, left: 58 },
179-
width = 820 - margin.left - margin.right,
180-
height = 380 - margin.top - margin.bottom;
180+
chartWidth = 820,
181+
chartHeight = 380,
182+
width = chartWidth - margin.left - margin.right,
183+
height = chartHeight - margin.top - margin.bottom;
181184

182185
const svg = d3.select("#chart")
183186
.append("svg")
184-
.attr("width", width + margin.left + margin.right)
185-
.attr("height", height + margin.top + margin.bottom)
187+
.attr("viewBox", `0 0 ${chartWidth} ${chartHeight}`)
188+
.attr("preserveAspectRatio", "xMinYMin meet")
189+
.style("width", "100%")
190+
.style("height", "auto")
186191
.append("g")
187192
.attr("transform", `translate(${margin.left},${margin.top})`);
188193

040-f1-constructor-standings-dashboard/styles.css

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ header { grid-area: header; text-align: center; }
2323
main { grid-area: main; }
2424
footer { grid-area: footer; text-align: center; color: #aaa; font-size: 0.98rem; margin-top: 10px; }
2525

26+
header h1 {
27+
margin-bottom: 10px;
28+
}
29+
2630
.controls {
2731
display: flex;
2832
justify-content: center;
@@ -45,15 +49,20 @@ select {
4549
background: #181d2a;
4650
border-radius: 20px;
4751
padding: 18px 12px 22px 24px;
48-
min-height: 400px;
52+
min-height: 260px;
4953
overflow-x: auto;
5054
box-shadow: 0 6px 26px #0004;
5155
transition: box-shadow 0.3s;
56+
width: 100%;
57+
max-width: 100vw;
58+
min-width: 0;
5259
}
5360
#chart svg {
5461
display: block;
5562
width: 100%;
5663
height: auto;
64+
min-width: 320px;
65+
max-width: 100vw;
5766
}
5867

5968
#summaryTable {
@@ -103,12 +112,6 @@ select {
103112
box-shadow: 0 0 7px #ffda0070;
104113
}
105114

106-
@media (max-width: 900px) {
107-
.dashboard-grid { padding: 14px 2px 4px 2px; }
108-
#chart { padding: 8px 2px 10px 6px; min-height: 320px; }
109-
#summaryTable th, #summaryTable td { padding: 8px 4px; }
110-
}
111-
112115
.chart-tooltip {
113116
pointer-events: none;
114117
z-index: 1000;
@@ -122,3 +125,34 @@ select {
122125
opacity: 0;
123126
transition: opacity 0.2s;
124127
}
128+
129+
/* ----- MOBILE OPTIMIZATION ----- */
130+
@media (max-width: 900px) {
131+
.dashboard-grid { padding: 14px 2px 4px 2px; }
132+
#chart { padding: 8px 2px 10px 6px; min-height: 200px; }
133+
#summaryTable th, #summaryTable td { padding: 8px 4px; }
134+
}
135+
136+
@media (max-width: 600px) {
137+
.dashboard-grid {
138+
gap: 12px 0;
139+
padding: 6px 1px 6px 1px;
140+
}
141+
header h1 {
142+
font-size: 1.2rem;
143+
line-height: 1.15;
144+
word-break: break-word;
145+
margin-bottom: 6px;
146+
}
147+
#summaryTable th, #summaryTable td {
148+
font-size: 0.93rem;
149+
padding: 7px 2px;
150+
}
151+
#chart {
152+
padding: 4px 2px 6px 2px;
153+
min-width: 0;
154+
}
155+
#chart svg text {
156+
font-size: 1rem !important;
157+
}
158+
}

0 commit comments

Comments
 (0)