livewire-charts
livewire-charts copied to clipboard
Add tooltip override
Returns value if no formatted option in extras.
For example, adding a formatted value to the extras array, allows for passing that value to the tooltip.
return $orders->groupBy('created_at')
->reduce(function (LineChartModel $lineChartModel, $day) {
return $lineChartModel->addPoint($day[0]->created_at, $day->sum('amount')/100, ['formatted' =>'$' . number_format($day->sum('amount')/100, 2)]);
}, new LineChartModel());

If nothing is in the extras array with the key of formatted, just the value appears in the tooltip:

Great suggestion @andymnewhouse . Would it make more sense to include this as an extra parameter when adding a point to the series instead of including it on extras
?
Eg
$lineChartModel->addPoint('Food', 20, '$20', $extras)
Yes I believe so, but figured you might not want an api change like that. 🤷
Sent from my iPhone
On Nov 30, 2020, at 12:03 PM, Andrés Santibáñez [email protected] wrote:
Great suggestion @andymnewhouse . Would it make more sense to include this as an extra parameter when adding a point to the series instead of including it on extras?
Eg
$lineChartModel->addPoint('Food', 20, '$20', $extras) — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.
@andymnewhouse this is a very neat PR, nice! I'm wondering if this is also possible for the multi-line chart?
@asantibanez any plans to merge and release this?
Hello @davidhsianturi @techenby @hamidafghan
Thanks for the suggestion. This has been added to v2.5.0 via extras.tooltip
https://github.com/asantibanez/livewire-charts/releases/tag/v2.5.0
Thanks again.
Hello, can you please provide some clarification on how to use extras.tooltip? As it is not clear right now.