ngs-doo / TemplaterExamples

Creating reports in .NET and Java
https://templater.info
The Unlicense
48 stars 27 forks source link

Date issue in charts #48

Closed i-marasa closed 2 years ago

i-marasa commented 2 years ago

Hello.. I have a report that has a Stacked Bar depending on dates and values. When I pass data as list of object to the ms word report. the Stacked Bar chart does not render correctly until I open the word file and open edit data, then the chart appear correctly.

Details: Watch video: https://www.loom.com/share/eedcfcccd3e940d8850ef73a7f89f7a2

Source Report: Initative Report.docx

C# data model:

        List<Program> Programs = new List<Program>();
                Programs = _NajmServices.GetAllPrograms();
                var rep = new
                {
                    p = Programs.Select(s => new
                    {
                        name = !string.IsNullOrEmpty(s.NameEnglish) ? s.NameEnglish : s.NameArabic,
                        sdate = s.InitiativeStartDate.Date,//.ToString("M/d/yyyy"),
                        fdate = s.InitiativeFinishDate.Date,//.ToString("M/d/yyyy"),
                        dura = (s.InitiativeFinishDate - s.InitiativeStartDate).TotalDays,

                    }).ToList(),
                };
zapov commented 2 years ago

Hi,

I tried with this sample data:

    var dt = new DateTime(2022, 6, 6);
    var data = new
    {
        p = new[] {
            new {name = "A", sdate = (DateTime?)dt.AddYears(-1), fdate = (DateTime?)dt.AddYears(1), dura = (int?)700 },
            new {name = "B", sdate = (DateTime?)dt.AddDays(-10), fdate = (DateTime?)dt.AddDays(10), dura = (int?)20 },
            new {name = "C", sdate = (DateTime?)null, fdate = (DateTime?)null, dura = (int?)null},
            new {name = "D", sdate = (DateTime?)dt.AddDays(0), fdate = (DateTime?)dt.AddDays(0), dura = (int?)1 },
        }
    };

and it works fine for me. Does it work ok with this data for you? Can you prepare the exact data for which it doesn't work? I tried on latest version, please check also if that fixes your issue.

zapov commented 2 years ago

Pls let me know if this is an issue on latest version. I plan on releasing a new version soon and can look into fixing this if its an actual issue still.

i-marasa commented 2 years ago

Pls let me know if this is an issue on latest version. I plan on releasing a new version soon and can look into fixing this if its an actual issue still.

Thank you @zapov No this was on old version. it solved with our version that we are using. we had date format issues. Thank you for your help