function drawScattered()

in resources/charts/chartjs.js [60:128]


function drawScattered(data) {
    if (!preparedData)
        throw new Error("Please prepare the data first.");

    reset();

    currentChart = new Chart(ROOT, {
        type: "scatter",
        data: {
            datasets: [
                {
                    data: preparedData.flights,
                    backgroundColor: opaqueCheckBox.checked ? "rgb(0, 125, 255)" : "rgba(0, 125, 255, .20)",
                },
            ],
        },
        options: {
            animation: false,
            parsing: {
                xAxisKey: "distance",
                yAxisKey: "count",
            },
            plugins: {
                legend: {
                    display: false,
                },
                title: {
                    display: true,
                    text: "Number of flights for a distance",
                    position: "bottom",
                },
                tooltip: {
                    displayColors: false,
                    callbacks: {
                        label: (item) => {
                            const orig = preparedData.airportMap.get(item.raw.origin);
                            const dest = preparedData.airportMap.get(item.raw.destination);
                            const result = `✈ ${orig.name} (${orig.iata}) → ${dest.name} (${dest.iata}): ${Math.round(item.raw.distance)} km`;
                            return result;
                        },
                    },
                },
            },
            scales: {
                x: {
                    title: {
                        text: "distance →",
                        align: "end",
                        display: true,
                    },
                    ticks: {
                        format: {
                            style: "unit",
                            unit: "kilometer",
                        },
                    },
                },
                y: {
                    type: "logarithmic",
                    title: {
                        text: "# of flights →",
                        align: "end",
                        display: true,
                    },
                },
            },
        },
    });
}