Чтобы отметить точки A(-2$$\frac{11}{15}$$), B(3$$\frac{11}{13}$$) и C(3.71) на координатной прямой, нужно сначала понять, где примерно находятся эти точки.
Ниже представлен код для графика, но без точной координатной прямой, так как невозможно точно отметить на ней точки без интерактивного графика.
html
<canvas id="myChart"></canvas>
<script>
const ctx = document.getElementById('myChart').getContext('2d');
const myChart = new Chart(ctx, {
type: 'line',
data: {
labels: [-3, -2, -1, 0, 1, 2, 3, 4],
datasets: [{
label: 'Координатная прямая',
data: [0, 0, 0, 0, 0, 0, 0, 0],
borderColor: 'rgba(75, 192, 192, 1)',
borderWidth: 1,
pointRadius: 5, // Увеличиваем размер точек
pointStyle: 'circle', // Форма точек: круг
pointBorderColor: 'black', // Цвет обводки точек
pointBackgroundColor: 'white', // Цвет заливки точек
showLine: false
}]
},
options: {
scales: {
x: {
type: 'linear',
position: 'bottom'
},
y: {
display: false // Скрываем ось Y
}
},
plugins: {
tooltip: {
enabled: false // Отключаем всплывающие подсказки
},
annotation: {
annotations: {
pointA: {
type: 'point',
xValue: -2.73,
yValue: 0,
radius: 5,
backgroundColor: 'red',
label: {
enabled: true,
content: 'A',
position: 'top'
}
},
pointB: {
type: 'point',
xValue: 3.85,
yValue: 0,
radius: 5,
backgroundColor: 'blue',
label: {
enabled: true,
content: 'B',
position: 'top'
}
},
pointC: {
type: 'point',
xValue: 3.71,
yValue: 0,
radius: 5,
backgroundColor: 'green',
label: {
enabled: true,
content: 'C',
position: 'top'
}
}
}
}
}
},
plugins: [ChartAnnotation]
});
</script>