wa0x6e / cal-heatmap

Cal-Heatmap is a javascript charting library to create a time-series calendar heatmap
http://cal-heatmap.com
MIT License
2.66k stars 291 forks source link

Hours subdomain is not honoring local browser time #476

Open empireshades opened 6 months ago

empireshades commented 6 months ago

I've commented on other issues but I wanted to log this here officially as well. When I use domain: day with subdomain: hour, the timezone appears in UTC and does not honor my local browser time. I've tried this with multiple Date formats in different input timezones including string and also epoch. The only thing that seems to make a minor difference is if I set the timezone to 'America/Los_Angeles' but even then the time only gets shifted by an hour for the epoch entry only. Thank you.

Full example: JS Fiddle

JS:

const cal = new CalHeatmap();
cal.paint({
  range: 5,
  domain: {
    type: 'day'
  },
  subDomain: {
    type: 'hour'
  },
  date: {
    start: new Date('2023-03-09'),
    //timezone: 'America/Los_Angeles'
  },
  data: {
    defaultValue: 0,

    source: [{
        date: new Date('Mar 10 2023 07:00:00 GMT-0700'),
        rate: 3
      },
      {
        date: new Date('Sat Mar 11 2023 08:00:00 GMT+0800 (Chinese Standard Time)'),
        rate: 1
      },
      {
        date: 1678606470000, //GMT: Sunday, March 12, 2023 7:34:30 AM
        rate: 4
      },
    ],
    x: 'date',
    y: 'rate'
  },
  scale: {
    opacity: {
      baseColor: 'red',
      domain: [0, 5],
    }
  }
}, [
  [Tooltip]
]);
Tang59 commented 5 months ago

Same problem here

forrany commented 1 week ago

Same problem here