add percentage to y-axis tooltip
This commit is contained in:
@@ -69,6 +69,7 @@
|
||||
'legend' => [
|
||||
'show' => false,
|
||||
],
|
||||
|
||||
], $seriesData);
|
||||
$seriesData = json_encode($seriesData)
|
||||
@endphp
|
||||
@@ -89,6 +90,18 @@
|
||||
}
|
||||
}
|
||||
|
||||
this.data.tooltip = {
|
||||
enabled: true,
|
||||
y: {
|
||||
formatter: (value, { series, seriesIndex, dataPointIndex, w }) => {
|
||||
|
||||
const firstDataPoint = this.data.series[seriesIndex].data[1][1]
|
||||
const percentageChange = ((value - firstDataPoint) / firstDataPoint) * 100;
|
||||
return `${value} (${percentageChange.toFixed(2)}%)`;
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
var chart = new ApexCharts(document.querySelector('#chart-{{ $name }}'), this.data);
|
||||
|
||||
chart.render();
|
||||
|
||||
Reference in New Issue
Block a user