import { elements } from "chart.js";
import dayjs from "dayjs"

export function MEMORY_CHART_CONFIG(from: Date, to: Date) {
    const lineColor = '#636363ff';
    return {
        type: 'line',
        options: {
            plugins: {
                title: {
                text: 'Chart.js Time Scale',
                display: true
                }
            },
            aspectRatio: 2.75,
            scales: {
                x: {
                    type: 'time',
                    time: {
                        // Luxon format string
                        tooltipFormat: 'DD.MM'
                    },
                    ticks: {
                        autoSkip: true,
                        maxTicksLimit: 6,
                        align: 'center',
                        color: lineColor,
                        callback: function (value: Date) {
                            return dayjs(new Date(value)).format("HH:mm");
                        }
                    },
                    grid: {
                        color: lineColor,
                        borderColor: lineColor,
                        lineWidth: 1
                    },
                    min: from,
                    max: to,
                },
                y: {
                    beginAtZero: true,
                    ticks: {
                        maxTicksLimit: 6,
                        color: lineColor
                    },
                    grid: {
                        color: lineColor,
                        borderColor: lineColor,
                        lineWidth: 1
                    }
                }
            }
        }
    }
};