Fixed eps chart

This commit is contained in:
Claudio Maggioni 2023-05-29 13:59:23 +02:00
parent e9713cc60c
commit d3cd94feb0

View file

@ -15,9 +15,8 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { EmployeeCount, Eps, getEmployees, getEps } from '@/api'; import { Eps, getEps } from '@/api';
import { defineLoader } from '@/api/loader'; import { defineLoader } from '@/api/loader';
import { time } from 'ag-charts-community';
import { DateTime } from 'luxon'; import { DateTime } from 'luxon';
import { roundTo } from 'round-to'; import { roundTo } from 'round-to';
import { onMounted, computed } from 'vue'; import { onMounted, computed } from 'vue';
@ -25,10 +24,9 @@ import { AgChartsVue } from 'ag-charts-vue3';
const renderer = (params: any) => ({ const renderer = (params: any) => ({
title: params.title, title: params.title,
content: DateTime.fromMillis(params.xValue).year + ': ' + roundTo(params.yValue, 0), content: DateTime.fromMillis(params.xValue).toFormat('yyyy-MM') + ': ' + roundTo(params.yValue, 4),
}); });
const props = defineProps<{ const props = defineProps<{
tickers: string[], tickers: string[],
colors: string[] colors: string[]
@ -49,26 +47,24 @@ const options = computed(() => {
type: 'column', type: 'column',
yKey: t, yKey: t,
yName: t, yName: t,
fill: getTickerColor(t),
stroke: getTickerColor(t), stroke: getTickerColor(t),
tooltip: { renderer: renderer }, tooltip: { renderer: renderer },
marker: { highlightStyle: {
fill: getTickerColor(t), item: { fillOpacity: 0 },
stroke: getTickerColor(t) series: { enabled: false }
} },
})), })),
axes: [ axes: [
{ {
type: 'time', type: 'category',
position: 'bottom', position: 'bottom',
tick: {
interval: time.month.every(3, {
snapTo: DateTime.utc(2000, 1, 1).toJSDate() // snap to solar year quarters
})
},
label: { label: {
autoRotate: true, autoRotate: true,
autoRotateAngle: 335, autoRotateAngle: 335,
format: '%Y-%m' formatter: (params: any) => {
return DateTime.fromMillis(parseInt(params.value)).toFormat('yyyy-MM');
}
} }
}, },
{ {