Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lernen Using Linear Scales | Adding Transitions Scales and Axes
Quizzes & Challenges
Quizzes
Challenges
/
JavaScript D3.js Visualization Essentials

bookUsing Linear Scales

index.html

index.html

copy

When you want to display data visually, you need a way to translate your raw data values into positions or sizes on the screen. D3's d3.scaleLinear function lets you do this by creating a linear mapping between your data and the visual properties of your chart, such as pixel positions.

A linear scale is configured using two key concepts: domain and range. The domain defines the minimum and maximum values from your dataset. This is the set of possible input values you expect to handle. The range specifies the minimum and maximum values for the visual output—such as pixel positions along an axis.

For example, if your data values range from 0 to 100, and you want to map these to pixel positions from 0 to 500 along the x-axis, you set the domain to [0, 100] and the range to [0, 500]. With this setup, a data value of 50 would be mapped to 250 pixels, right in the middle of your chart. This approach ensures that your chart scales automatically to fit your data, no matter what values you have.

War alles klar?

Wie können wir es verbessern?

Danke für Ihr Feedback!

Abschnitt 4. Kapitel 4

Fragen Sie AI

expand

Fragen Sie AI

ChatGPT

Fragen Sie alles oder probieren Sie eine der vorgeschlagenen Fragen, um unser Gespräch zu beginnen

Awesome!

Completion rate improved to 5

bookUsing Linear Scales

Swipe um das Menü anzuzeigen

index.html

index.html

copy

When you want to display data visually, you need a way to translate your raw data values into positions or sizes on the screen. D3's d3.scaleLinear function lets you do this by creating a linear mapping between your data and the visual properties of your chart, such as pixel positions.

A linear scale is configured using two key concepts: domain and range. The domain defines the minimum and maximum values from your dataset. This is the set of possible input values you expect to handle. The range specifies the minimum and maximum values for the visual output—such as pixel positions along an axis.

For example, if your data values range from 0 to 100, and you want to map these to pixel positions from 0 to 500 along the x-axis, you set the domain to [0, 100] and the range to [0, 500]. With this setup, a data value of 50 would be mapped to 250 pixels, right in the middle of your chart. This approach ensures that your chart scales automatically to fit your data, no matter what values you have.

War alles klar?

Wie können wir es verbessern?

Danke für Ihr Feedback!

Abschnitt 4. Kapitel 4
some-alt