Added axis labels

This commit is contained in:
Claudio Maggioni 2023-05-29 15:21:58 +02:00
parent e1abc59e99
commit 435ba7450e
4 changed files with 41 additions and 5 deletions

View file

@ -90,6 +90,10 @@ const options = computed(() => {
})), })),
axes: [ axes: [
{ {
title: {
enabled: true,
text: 'Company Ticker'
},
type: 'category', type: 'category',
position: 'bottom', position: 'bottom',
gridStyle: [{ gridStyle: [{
@ -99,12 +103,18 @@ const options = computed(() => {
}] }]
}, },
{ {
enabled: true,
title: {
enabled: true,
text: 'Amount in USD',
},
type: 'number', type: 'number',
position: 'left', position: 'left',
label: { label: {
format: '$~s', format: '$~s',
formatter: (params: AgAxisLabelFormatterParams) => formatter: (params: AgAxisLabelFormatterParams) =>
params?.formatter?.(params.value) params?.formatter?.(params.value)
.replace('y', '')
.replace('k', 'K') .replace('k', 'K')
.replace('G', 'B') ?? '' .replace('G', 'B') ?? ''
}, },

View file

@ -71,7 +71,11 @@ const options = computed(() => {
lineDash: [Infinity] lineDash: [Infinity]
}, { }, {
lineDash: [Infinity] lineDash: [Infinity]
}] }],
title: {
enabled: true,
text: 'Year'
},
}, },
{ {
type: 'number', type: 'number',
@ -80,7 +84,11 @@ const options = computed(() => {
lineDash: [Infinity] lineDash: [Infinity]
}, { }, {
lineDash: [Infinity] lineDash: [Infinity]
}] }],
title: {
enabled: true,
text: '# of employees'
},
}, },
], ],
legend: { legend: {

View file

@ -66,7 +66,11 @@ const options = computed(() => {
lineDash: [Infinity] lineDash: [Infinity]
}, { }, {
lineDash: [Infinity] lineDash: [Infinity]
}] }],
title: {
enabled: true,
text: 'Quarter'
},
}, },
{ {
type: 'number', type: 'number',
@ -75,7 +79,11 @@ const options = computed(() => {
lineDash: [Infinity] lineDash: [Infinity]
}, { }, {
lineDash: [Infinity] lineDash: [Infinity]
}] }],
title: {
enabled: true,
text: 'Amount in USD'
},
}, },
], ],
legend: { legend: {

View file

@ -141,6 +141,7 @@ const options = computed(() => {
stroke: getTickerColor(t), stroke: getTickerColor(t),
tooltip: { renderer: renderer }, tooltip: { renderer: renderer },
marker: { marker: {
size: timeToggle.value == '1M' || timeToggle.value == '3M' ? 5 : 1,
fill: getTickerColor(t), fill: getTickerColor(t),
stroke: getTickerColor(t) stroke: getTickerColor(t)
} }
@ -164,6 +165,10 @@ const options = computed(() => {
}, { }, {
lineDash: [Infinity] lineDash: [Infinity]
}], }],
title: {
enabled: true,
text: 'Closing date'
},
crossLines: Object.entries(minDates(stockPrice.data ?? [])) crossLines: Object.entries(minDates(stockPrice.data ?? []))
.map(([key, value]: [string, number]) => ({ .map(([key, value]: [string, number]) => ({
type: 'line', type: 'line',
@ -181,14 +186,19 @@ const options = computed(() => {
format: '$~s', format: '$~s',
formatter: (params: AgAxisLabelFormatterParams) => formatter: (params: AgAxisLabelFormatterParams) =>
params?.formatter?.(params.value) params?.formatter?.(params.value)
.replace('y', '')
.replace('k', 'K') .replace('k', 'K')
.replace('G', 'B') ?? '' + '$' .replace('G', 'B') ?? ''
}, },
gridStyle: [{ gridStyle: [{
lineDash: [Infinity] lineDash: [Infinity]
}, { }, {
lineDash: [Infinity] lineDash: [Infinity]
}], }],
title: {
enabled: true,
text: 'Amount in USD'
},
}, },
], ],
legend: { legend: {