Skip to content

Commit f4dfc18

Browse files
committed
refactor: layout improvements
1 parent eb566a1 commit f4dfc18

File tree

6 files changed

+16
-16
lines changed

6 files changed

+16
-16
lines changed

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
1111
<title>Wiki Infographics</title>
1212
</head>
13-
<body>
13+
<body class="bg-gray-100">
1414
<div id="root"></div>
1515
<script type="module" src="/src/main.jsx"></script>
1616
</body>

src/Components/CodeEditor/codeEditor.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ function CodeEditor({ onCodeChange, handleFetchChartData, isLoading, errorMessag
124124
<>
125125
<div>
126126
<Editor
127-
height="60vh"
127+
height="80vh"
128128
language="sparql"
129129
theme={darkMode ? 'vs-dark' : 'light'}
130130
onChange={handleValueChange}

src/Components/Infographics/BarChartRace/barChartRace.css

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
#play-controls {
88
max-width: 1000px;
9-
margin: 1em auto;
109
}
1110

1211
#play-pause-button {

src/Components/Infographics/BarChartRace/barChartRace.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ const BarChartRace = ({ title, speed, colorPalette, timeUnit, barRaceData, isDow
271271
return (
272272
<div id="parent-container" className="relative p-4">
273273
<TimeLeftAlert/>
274-
<div id="play-controls" className="flex items-center mb-4">
274+
<div id="play-controls" className="flex items-center">
275275
<button
276276
id="play-pause-button"
277277
className={`bg-cyan-700 hover:bg-cyan-800 dark:bg-cyan-600 dark:hover:bg-cyan-800 fa ${isPlaying ? "fa-pause" : "fa-play"}`}

src/Components/Infographics/BarChartRace/barChartRaceUtils.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import * as d3 from "d3";
44

55

66
// Constants
7-
export const margin = { top: 32, right: 16, bottom: 32, left: 0 }; // Added padding/margin
8-
export const barSize = 48;
7+
export const margin = { top: 16, right: 16, bottom: 16, left: 0 }; // Added padding/margin
8+
export const barSize = 38;
99
export const maxNumberVisible = 12;
1010
export let color;
1111

@@ -15,20 +15,21 @@ let dateFormatter;
1515

1616
// Function to initialize the chart
1717
export const initializeChart = (svgRef, dataset, width, title, colorPaletteArray, timeUnit, locale) => {
18-
const chartMargin = 30; // Adjust this value to increase the space
18+
const chartMarginTop = 30;
19+
const chartMarginBottom = 12;
1920

2021
// Create SVG element
2122
svgRef.current = d3
2223
.select("#container")
2324
.append("svg")
24-
.attr("viewBox", [0, -chartMargin, width, margin.top + barSize * maxNumberVisible + margin.bottom + chartMargin]);
25+
.attr("viewBox", [0, -chartMarginTop, width, margin.top + barSize * maxNumberVisible + margin.bottom + chartMarginBottom]);
2526

2627
// Add a title to the SVG
2728
svgRef.current.append("text")
2829
.attr("x", width / 2) // Center horizontally
29-
.attr("y", -11) // Adjust this value to move the title up
30+
.attr("y", -12) // Adjust this value to move the title up
3031
.attr("text-anchor", "middle") // Center the text
31-
.attr("font-size", "24px")
32+
.attr("font-size", "16px")
3233
.attr("font-weight", "bold")
3334
.text(title || "");
3435

@@ -49,7 +50,7 @@ export const initializeChart = (svgRef, dataset, width, title, colorPaletteArray
4950
const y = d3
5051
.scaleBand()
5152
.domain(d3.range(maxNumberVisible + 2))
52-
.rangeRound([margin.top, margin.top + barSize * (maxNumberVisible + 1 + 0.1)])
53+
.rangeRound([-16, barSize * (maxNumberVisible + 1.3)])
5354
.padding(0.1);
5455

5556
const scale = d3.scaleOrdinal(colorPaletteArray);
@@ -120,7 +121,7 @@ function cap_at_max_rank(rank) {
120121
function labels(svgRef, x, y, prev, next) {
121122
let label = svgRef
122123
.append("g")
123-
.style("font", "bold 12px var(--sans-serif)")
124+
.style("font", "bold 11px var(--sans-serif)")
124125
.style("font-variant-numeric", "tabular-nums")
125126
.attr("text-anchor", "end")
126127
.selectAll("text");

src/Pages/Infographics.jsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,12 @@ const Infographics = () => {
133133
<>
134134

135135
<NavBar username={username}/>
136-
<div className="px-4 py-8 mx-auto bg-gray-100 dark:bg-gray-700 container mt-4">
137-
<div className="grid grid-rows-5 gap-4 lg:grid-cols-5 lg:grid-rows-1 lg:gap-4">
138-
<div className="lg:col-span-2 row-span-1 border dark:border-gray-800 overflow-x-auto bg-white dark:bg-gray-600 max-h-[790px]">
136+
<div className="mx-auto bg-gray-100 dark:bg-gray-700 container mt-2">
137+
<div className="flex flex-col gap-4 lg:flex-row">
138+
<div className="flex-1 border dark:border-gray-800 overflow-x-auto bg-white dark:bg-gray-600 max-h-[790px]">
139139
<CodeEditor onCodeChange={handleCodeChange} handleFetchChartData={getChartData} isLoading={isLoading} errorMessage={error}/>
140140
</div>
141-
<div className="lg:col-span-3 row-span-4 border dark:border-gray-800 relative overflow-x-auto bg-white dark:bg-gray-600">
141+
<div style={{minHeight: "90vh"}} className="flex-1 border dark:border-gray-800 relative overflow-x-auto bg-white dark:bg-gray-600">
142142
{isLoading && <Overlay />}
143143
{error && <div className="flex items-center justify-center mt-7"><ErrorAlert alertText={getContent(error) || error} /></div>}
144144
{Object.keys(chartData).length < 1 && !error && <div className="flex items-center justify-center mt-7"><InfoAlert alertText={getContent("preview-no-data")} /></div>}

0 commit comments

Comments
 (0)