Marker style

This commit is contained in:
Claudio Maggioni 2023-05-29 16:35:27 +02:00
parent 34d7955870
commit 636cc119e6
5 changed files with 108 additions and 109 deletions

View file

@ -1,5 +1,5 @@
<template>
<v-card color="blue-grey-lighten-4">
<v-card variant="outlined">
<v-card-item>
<v-card-title>Balance sheet</v-card-title>
</v-card-item>

View file

@ -1,5 +1,5 @@
<template>
<v-card color="blue-grey-lighten-4">
<v-card variant="outlined">
<v-card-item>
<v-card-title>Employees over time</v-card-title>
</v-card-item>

View file

@ -1,5 +1,5 @@
<template>
<v-card color="blue-grey-lighten-4">
<v-card variant="outlined">
<v-card-item>
<v-card-title>Earnings per Share (EPS)</v-card-title>
</v-card-item>

View file

@ -1,112 +1,111 @@
<template>
<v-row>
<v-col cols="12">
<v-card>
<v-card-item>
<v-card-title>Past Performance</v-card-title>
</v-card-item>
<v-card-text>
<v-skeleton-loader class="chart-loader" v-if="epsCompData.loading" />
<ag-charts-vue class="chart" v-else :options="options" />
</v-card-text>
</v-card>
</v-col>
</v-row>
</template>
<v-card variant="outlined">
<v-card-item>
<v-card-title>Past Performance</v-card-title>
</v-card-item>
<v-card-text>
<v-skeleton-loader class="chart-loader" v-if="epsCompData.loading" />
<ag-charts-vue class="chart" v-else :options="options" />
</v-card-text>
</v-card>
</template>
<script setup lang="ts">
import { EpsComp, getEpsComp } from '@/api';
import { defineLoader } from '@/api/loader';
import { DateTime } from 'luxon';
import { AgAxisLabelFormatterParams } from 'ag-charts-community';
import { roundTo } from 'round-to';
import { onMounted, computed } from 'vue';
import { AgChartsVue } from 'ag-charts-vue3';
const renderer = (params: any) => ({
title: params.title,
content: DateTime.fromMillis(params.xValue).toFormat('yyyy-MM') + ': ' + roundTo(params.yValue, 4) + '%',
});
const props = defineProps<{
tickers: string[],
colors: string[]
}>();
const getTickerColor = (ticker: string) => props.colors[props.tickers.indexOf(ticker)];
const epsCompData = defineLoader<EpsComp[]>(() => getEpsComp(props.tickers));
const options = computed(() => {
if (epsCompData.loading) return null;
return {
theme: 'ag-material',
data: epsCompData.data?.map(e => ({ ...e, quarter: Date.parse(e.quarter) })),
series: props.tickers.map((t: string) => ({
xKey: 'quarter',
type: 'line',
yKey: t,
yName: t,
<script setup lang="ts">
import { EpsComp, getEpsComp } from '@/api';
import { defineLoader } from '@/api/loader';
import { DateTime } from 'luxon';
import { AgAxisLabelFormatterParams } from 'ag-charts-community';
import { roundTo } from 'round-to';
import { onMounted, computed } from 'vue';
import { AgChartsVue } from 'ag-charts-vue3';
const renderer = (params: any) => ({
title: params.title,
content: DateTime.fromMillis(params.xValue).toFormat('yyyy-MM') + ': ' + roundTo(params.yValue, 4) + '%',
});
const props = defineProps<{
tickers: string[],
colors: string[]
}>();
const getTickerColor = (ticker: string) => props.colors[props.tickers.indexOf(ticker)];
const epsCompData = defineLoader<EpsComp[]>(() => getEpsComp(props.tickers));
const options = computed(() => {
if (epsCompData.loading) return null;
return {
theme: 'ag-material',
data: epsCompData.data?.map(e => ({ ...e, quarter: Date.parse(e.quarter) })),
series: props.tickers.map((t: string) => ({
xKey: 'quarter',
type: 'line',
yKey: t,
yName: t,
stroke: getTickerColor(t),
marker: {
fill: getTickerColor(t),
stroke: getTickerColor(t),
tooltip: { renderer: renderer },
highlightStyle: {
item: { fillOpacity: 0 },
series: { enabled: false }
stroke: getTickerColor(t)
},
tooltip: { renderer: renderer },
highlightStyle: {
item: { fillOpacity: 0 },
series: { enabled: false }
},
})),
axes: [
{
type: 'category',
position: 'bottom',
label: {
autoRotate: true,
autoRotateAngle: 335,
formatter: (params: any) => {
return DateTime.fromMillis(parseInt(params.value)).toFormat('yyyy-MM');
}
},
})),
axes: [
{
type: 'category',
position: 'bottom',
label: {
autoRotate: true,
autoRotateAngle: 335,
formatter: (params: any) => {
return DateTime.fromMillis(parseInt(params.value)).toFormat('yyyy-MM');
}
},
gridStyle: [
{
lineDash: [Infinity],
}, {
lineDash: [Infinity],
}
],
},
{
type: 'number',
position: 'left',
label: {
format: '$~s',
formatter: (params: AgAxisLabelFormatterParams) => {
params?.formatter?.(params.value)
return params.value + '%';
}
},
gridStyle: [{
gridStyle: [
{
lineDash: [Infinity],
}, {
lineDash: [Infinity],
}],
crossLines:[
{
type: 'range',
value: 0,
lineDash: [6, 3],
stroke: 'black',
}
]
lineDash: [Infinity],
}
],
},
{
type: 'number',
position: 'left',
label: {
format: '$~s',
formatter: (params: AgAxisLabelFormatterParams) => {
params?.formatter?.(params.value)
return params.value + '%';
}
},
],
legend: {
position: 'bottom',
}
};
});
onMounted(() => {
epsCompData.load();
});
</script>
gridStyle: [{
lineDash: [Infinity],
}, {
lineDash: [Infinity],
}],
crossLines: [
{
type: 'range',
value: 0,
lineDash: [6, 3],
stroke: 'black',
}
]
},
],
legend: {
position: 'bottom',
}
};
});
onMounted(() => {
epsCompData.load();
});
</script>

View file

@ -1,5 +1,5 @@
<template>
<v-card color="blue-grey-lighten-4">
<v-card variant="outlined">
<v-card-item>
<v-card-title>Stock price over time</v-card-title>
</v-card-item>