Initial commit
This commit is contained in:
@@ -0,0 +1,118 @@
|
||||
export const CHART_ENDPOINTS = {
|
||||
costiRicavi: '/dashboard/costi-ricavi',
|
||||
fatturatoCliente: '/dashboard/fatturato-cliente',
|
||||
aperteChiuseCliente: '/dashboard/aperte-chiuse-cliente',
|
||||
aperteChiuseFornitore: '/dashboard/aperte-chiuse-fornitore',
|
||||
apertoCliente: '/dashboard/partite-cliente',
|
||||
chiusoCliente: '/dashboard/partite-cliente',
|
||||
};
|
||||
|
||||
export const CHART_DATA_KEY: Record<string, string> = {
|
||||
apertoCliente: 'partiteCliente',
|
||||
chiusoCliente: 'partiteCliente',
|
||||
};
|
||||
|
||||
|
||||
export const formatEuro = (val: string | number): string => {
|
||||
const num = parseFloat(val as string);
|
||||
return (isNaN(num) ? 0 : num).toLocaleString('it-IT', {
|
||||
style: 'currency',
|
||||
currency: 'EUR'
|
||||
});
|
||||
};
|
||||
|
||||
const TOOLTIP_BASE = {
|
||||
renderMode: 'richText',
|
||||
confine: true,
|
||||
textStyle: { fontSize: 10 }
|
||||
};
|
||||
|
||||
export const buildPieOption = (data: any) => ({
|
||||
legend: {
|
||||
type: 'plain',
|
||||
top: 190,
|
||||
left: 'center',
|
||||
itemGap: 8,
|
||||
itemWidth: 14,
|
||||
itemHeight: 10,
|
||||
textStyle: { fontSize: 12 }
|
||||
},
|
||||
series: [
|
||||
{
|
||||
name: 'Fatturato',
|
||||
type: 'pie',
|
||||
radius: [45, 80],
|
||||
center: ['50%', 95],
|
||||
avoidLabelOverlap: false,
|
||||
itemStyle: {
|
||||
borderRadius: 5,
|
||||
borderColor: '#fff',
|
||||
borderWidth: 2
|
||||
},
|
||||
label: {
|
||||
show: false,
|
||||
position: 'center'
|
||||
},
|
||||
emphasis: {
|
||||
label: {
|
||||
show: true,
|
||||
fontSize: 11,
|
||||
fontWeight: 'bold',
|
||||
formatter: (params: any) => {
|
||||
const val = (typeof params.value === 'number') ? params.value : 0;
|
||||
return `${params.name}\n${val.toLocaleString('it-IT', { style: 'currency', currency: 'EUR', maximumFractionDigits: 0 })}`;
|
||||
}
|
||||
}
|
||||
},
|
||||
labelLine: {
|
||||
show: false
|
||||
},
|
||||
data: data
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
export const buildAperteChiuseOption = (d: any) => ({
|
||||
tooltip: {
|
||||
...TOOLTIP_BASE,
|
||||
trigger: 'axis',
|
||||
valueFormatter: formatEuro
|
||||
},
|
||||
legend: {
|
||||
bottom: 0,
|
||||
itemGap: 10,
|
||||
itemWidth: 14,
|
||||
itemHeight: 10,
|
||||
textStyle: { fontSize: 12 },
|
||||
data: [
|
||||
`Aperto(${d.current_year})`,
|
||||
`Chiuso(${d.current_year})`,
|
||||
`Aperto(${d.prev_year})`,
|
||||
`Chiuso(${d.prev_year})`
|
||||
],
|
||||
selected: {
|
||||
[`Aperto(${d.prev_year})`]: false,
|
||||
[`Chiuso(${d.prev_year})`]: false
|
||||
},
|
||||
},
|
||||
grid: {
|
||||
left: '3%',
|
||||
right: '4%',
|
||||
top: '10%',
|
||||
bottom: 75,
|
||||
containLabel: true
|
||||
},
|
||||
xAxis: {
|
||||
type: 'category',
|
||||
data: d.mesi
|
||||
},
|
||||
yAxis: {
|
||||
type: 'value'
|
||||
},
|
||||
series: [
|
||||
{ name: `Aperto(${d.current_year})`, type: 'bar', stack: 'one', data: d.aperto },
|
||||
{ name: `Chiuso(${d.current_year})`, type: 'bar', stack: 'one', data: d.chiuso },
|
||||
{ name: `Aperto(${d.prev_year})`, type: 'bar', stack: 'one', itemStyle: { color: '#b3b3b3' }, data: d.aperto_prev },
|
||||
{ name: `Chiuso(${d.prev_year})`, type: 'bar', stack: 'one', itemStyle: { color: '#d9d9d9' }, data: d.chiuso_prev }
|
||||
]
|
||||
});
|
||||
Reference in New Issue
Block a user