а

Year get caclulated wrong when using Fiscal Year


#1

when I use fiscal year which starts at Oct 1 , the first year is calculated wrong. For example, if I have tasks starts at Oct 1 2018 , the chart will show like this:
FY 2017 FY 2017 FY 2018 …
I’m attaching a sample project here.

Has anyone had the same issue? any solution would be appreciated

FiscalYear.zip (1.1 MB)


#2

Hi @thao_trinh!

  1. Your “fiscalYearLabel()” function is unused.

  2. You need to use gantt.templates.date_scale to set custom date values in the scale instead gantt.config.date_scale. Here is a related article:
    https://docs.dhtmlx.com/gantt/api__gantt_date_scale_template.html

  3. Please remove gantt.config.date_scale and set your “fiscalYearLabel()” function to the gantt.templates.date_scale.

  4. Please pay attention you need to set templates.date_scale value in the “onTemplatesReady” event.
    https://docs.dhtmlx.com/gantt/api__gantt_ontemplatesready_event.html.
    So you need to add such code to your project:

gantt.attachEvent("onTemplatesReady", function(){
  gantt.templates.date_scale = fiscalYearLabel 
});

Here is a snippet with your full code modified:
http://snippet.dhtmlx.com/0efb316e6

You can use your “fiscalYearLabel()” function as a template for the subscale. Just add this object {unit:"fiscal_year", step:1, template:fiscalYearLabel} to gantt.config.subscales array. Here is a snippet you can see how it can be implemented:
http://snippet.dhtmlx.com/4b959a692


#3

Hello Thao,
The dev team updated the scales API. Now you can specify the templates directly in the scale property and list all scales you need in one object:
https://docs.dhtmlx.com/gantt/desktop__configuring_time_scale.html

Originally, you had this configuration:
https://snippet.dhtmlx.com/39c34c239
Here is the updated configuration:
http://snippet.dhtmlx.com/528faf625