I had problem with my new calculator because one date was showed as year (25year) and second as moths (300moth). After many attempts I finally find 2 good working solution to change month to year:
var kopia = [];
for(var i = 0; i < chart1.length; i++){
kopia.push(chart1[i]/12)
}
const dublicateItems = (arr, numberOfRepetitions) =>
arr.flatMap(i => Array.from({ length: numberOfRepetitions }).fill(i));
var finalnywynik = dublicateItems(kopia, 12);
and
newArray = new array();
for(i=0;i<chart. length; i++){
for(j=0;i<12; j++){
newArray[j] += chart1[i]
}}
but it do not look cool on chart so now I think how map another chartdate to look it more clean by reduce them to.
My attempts to reduce months to years just give a sum of each month and previous payment. It is useful, but not in this case:
import { create, all } from 'mathjs'
const config = { }
const math = create(all, config)
var r = RataBezDotacji;
var payment = 0;
if (r.length) {
for (var i = 0, h = r.length; i < h; i++) {
payment = math.sum(payment, r[i]['payment']);
if((i+1)%12 || i+1 == h)
{
RataBezDotacjaa.push(payment.toFixed(2))
}
} }
Please indicate correct solution, to bring my project to a final deployment.