You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@echarts.apache.org by GitBox <gi...@apache.org> on 2019/05/09 14:39:55 UTC

[GitHub] [incubator-echarts] greggomalley opened a new issue #10430: Heatmap calendar does not display correctly for October and timezone London

greggomalley opened a new issue #10430: Heatmap calendar does not display correctly for October and timezone London
URL: https://github.com/apache/incubator-echarts/issues/10430
 
 
   ### Version
   4.2.1
   
   ### Steps to reproduce
   The easiest way to reproduce is browse to https://ecomfe.github.io/echarts-examples/public/editor.html?c=calendar-heatmap
   
   Change 
   ```
    calendar: {
           top: 120,
           left: 30,
           right: 30,
           cellSize: ['auto', 13],
           range: '2016',
           itemStyle: {
               normal: {borderWidth: 0.5}
           },
           yearLabel: {show: false}
       },
   ```
   to
   ```
    calendar: {
           top: 120,
           left: 30,
           right: 30,
           cellSize: ['auto', 13],
           range: '2016-10',
           itemStyle: {
               normal: {borderWidth: 0.5}
           },
           yearLabel: {show: false}
       },
   ```
   i.e select the range as October 2016. Crucially set your timezone to Europe/London and it will display the calendar incorrectly - it displays correctly for all other timezones.
   
   ### What is expected?
   It should correctly format the calendar for the month of October.
   
   ### What is actually happening?
   The formatting is incorrect.
   
   ---
   The problem seems to stem from the DST calculation that is done in `_getRangeInfo` of `src/coord/calendar/Calendar.js`. It seems quite complicated so I wouldn't be comfortable suggesting a change although I replaced the lines
   ```
     var allDay = Math.floor(range[1].time / PROXIMATE_ONE_DAY) - Math.floor(range[0].time / PROXIMATE_ONE_DAY)   1; // Consider case:
     
       var date = new Date(range[0].time);
       var startDateNum = date.getDate();
       var endDateNum = range[1].date.getDate();
       date.setDate(startDateNum   allDay - 1); // The bias can not over a month, so just compare date.
   
       if (date.getDate() !== endDateNum) {
         var sign = date.getTime() - range[1].time > 0 ? 1 : -1;
   
         while (date.getDate() !== endDateNum && (date.getTime() - range[1].time) * sign > 0) {
           allDay -= sign;
           date.setDate(startDateNum   allDay - 1);
         }
       }
   ```
   
   with
   
   ```
       var allDay = Math.round((range[1].time - range[0].time) / PROXIMATE_ONE_DAY)   1;
   ``
   
    and it seems to work - this should also be sufficient to calculate the number of days regardless of DST when only dates are input. However this line of code may have other consequences that I'm not aware of with my use of the library.
   
   <!-- This issue is generated by echarts-issue-helper. DO NOT REMOVE -->
   <!-- This issue is in English. DO NOT REMOVE -->

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@echarts.apache.org
For additional commands, e-mail: dev-help@echarts.apache.org