Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
holtzy committed Nov 12, 2024
1 parent dfb2147 commit 04cd58c
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 30 deletions.
26 changes: 16 additions & 10 deletions pages/course/scales/linear-scale.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -267,27 +267,33 @@ const exercices: Exercise[] = [
whyItMatters: (
<>
<p>
The logic behind each functions of the <code>d3-shape</code> module is
the same.
There is no way you can build this kind of chart with a charting
library like <code>plotly</code> or <code>highCharts</code>.
</p>
<p>
If you have a good understanding of d3.line(), you're on the right way
to build any other chart type!
Thanks to <code>d3</code>, we can build literally anything. It's just
a bit of mental gymnastic!
</p>
</>
),
toDo: (
<>
<p>
Let's create a mirror histogram!! The mirror histogram looks like
this:
Let's create a mirror histogram! Check the <code>solution</code> tab
to see how it must look like.
</p>
<ul>
<li>Create 2 scales!</li>
<li>
Values are <code>23</code>, <code>55</code>, <code>87</code> on the
left, and <code>12</code>, <code>43</code>, <code>98</code> on the
right
There are 3 bars on the left, and 3 and on the right. All starting
from the center.
</li>
<li>
A bit of <code>padding</code> is added in the center.
</li>
<li>
Bar values are <code>23</code>, <code>55</code>, <code>87</code> on
the left, and <code>12</code>, <code>43</code>, <code>98</code> on
the right. Axes go from 0 to 100.
</li>
</ul>
</>
Expand Down
13 changes: 2 additions & 11 deletions pages/course/scales/other-scale-types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,6 @@ export default function Home() {
return null;
}

const yScale = scaleBand()
.domain(['A', 'B', 'C'])
.range([0, 240])
.paddingInner(0.33)
.paddingOuter(0);

// console.log(yScale('A'));
// console.log(yScale('B'));
// console.log(yScale('C'));
// console.log(yScale.bandwidth());

return (
<LayoutCourse
title={currentLesson.name}
Expand Down Expand Up @@ -253,6 +242,8 @@ colorScale("b") // --> green
},
]}
/>

<blockquote>TODOOOOOOOOO</blockquote>
{/* -
-
-
Expand Down
18 changes: 9 additions & 9 deletions viz/exercise/linearScaleMirrorSolution/Graph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,24 +43,24 @@ export const Graph = () => {

{/* Right Bars */}
<rect
x={WIDTH / 2 + PADDING_CENTER / 2}
x={scaleRight(0)}
y={50}
height={30}
width={scaleRight(12)}
width={scaleRight(12) - scaleRight(0)}
fill="#69b3a2"
/>
<rect
x={WIDTH / 2 + PADDING_CENTER / 2}
x={scaleRight(0)}
y={100}
height={30}
width={scaleRight(43)}
width={scaleRight(43) - scaleRight(0)}
fill="#69b3a2"
/>
<rect
x={WIDTH / 2 + PADDING_CENTER / 2}
x={scaleRight(0)}
y={150}
height={30}
width={scaleRight(98)}
width={scaleRight(98) - scaleRight(0)}
fill="#69b3a2"
/>

Expand All @@ -69,21 +69,21 @@ export const Graph = () => {
x={scaleLeft(23)}
y={50}
height={30}
width={WIDTH / 2 - PADDING_CENTER / 2 - scaleLeft(23)}
width={scaleLeft(0) - scaleLeft(23)}
fill="#69b3a2"
/>
<rect
x={scaleLeft(55)}
y={100}
height={30}
width={WIDTH / 2 - PADDING_CENTER / 2 - scaleLeft(55)}
width={scaleLeft(0) - scaleLeft(55)}
fill="#69b3a2"
/>
<rect
x={scaleLeft(87)}
y={150}
height={30}
width={WIDTH / 2 - PADDING_CENTER / 2 - scaleLeft(87)}
width={scaleLeft(0) - scaleLeft(87)}
fill="#69b3a2"
/>
</svg>
Expand Down

0 comments on commit 04cd58c

Please sign in to comment.