Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Вивчайте 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.

Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 4. Розділ 4

Запитати АІ

expand

Запитати АІ

ChatGPT

Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат

Awesome!

Completion rate improved to 5

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.

Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 4. Розділ 4
some-alt