kurkle / chartjs-chart-matrix

Chart.js module for creating matrix charts
MIT License
214 stars 18 forks source link

isoWeekday not working as intended #156

Closed quiquelhappy closed 1 month ago

quiquelhappy commented 8 months ago

image the first column (the one that is overlapping) should be on the latest column (sunday).

const dailyFormat = 'dd'
const weeklyFormat = 'YY/WW (MMM)'
const isoWeekday = 1;
const grid = {
    display: false,
    drawBorder: false,
    tickLength: 0,
}
const ticks = {
    maxRotation: 0,
    autoSkip: true,
    padding: 1
}
const x = {
    type: 'time',
    offset: true,
    time: {
        isoWeekday,
        unit: 'day',
        round: 'day',
        parser: dailyFormat,
        displayFormats: {
            day: 'dd'
        }
    },
    reverse: false,
    position: 'right',
    ticks,
    grid,
    min: moment().startOf('isoWeek'),
    max: moment().endOf('isoWeek')
}
const y = {
    type: 'time',
    offset: true,
    reverse: true,
    time: {
        isoWeekday,
        unit: 'week',
        round: 'week',
        displayFormats: {
            week: weeklyFormat
        }
    },
    ticks,
    grid,
}

these settings are being used on the options object:

scales: {
    x,
    y
},

data:

data: s.data.map(d => {
    const k = d.key as Date // valid
    const day = moment(k).format(dailyFormat)
    const date = moment(k)
    return {
        x: day,
        y: date,
        d: k,
        v: d.data[l]
    }
})
kurkle commented 2 months ago

You'd probably want to be using 'E' as dailyFormat, which would yield ISO day of week from 1 to 7.