用 ngx-charts 计算两年

compering two years with ngx-charts

现在正在为那几个小时而苦苦挣扎-试图比较一家公司两年(2015 年、2016 年)的销售额-问题是我无法用日期对其进行排序,因为当然 2016 年将在 2015 年之后到来-我希望他们 'overlapping' 我解决了这个问题:

let d = new Date(null,deilyResults[i].date.month - 1, deilyResults[i].date.day);

-所以我将 'year' 设置为 null - 但会自动将年份更改为“1900”,这会导致工具提示中的数据不正确:

在这种情况下,正确的做法是什么?

将数据的年份设置为相同(ether 2016 或 2015),然后使用 ng-template 仅显示日期的月份和日期(或组合系列(年份)以及月份和日期from name) 在这样的工具提示中(你需要 ngx-charts 至少版本 5.3.0):

<ngx-charts-line-chart
...>
    <ng-template #tooltipTemplate let-model="model">
        <h6>{{model.series}} - {{model.name|date:'yyyy'}}.{{model.name|date:'mm.dd'}}</h6>
        <h4>{{model.value}}</h4>
    </ng-template>
</ngx-charts-line-chart>