livewire-charts icon indicating copy to clipboard operation
livewire-charts copied to clipboard

Add tooltip override

Open techenby opened this issue 4 years ago • 3 comments

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());

Screen Shot 2020-11-26 at 3 57 33 PM

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

Screen Shot 2020-11-26 at 3 58 53 PM

techenby avatar Nov 26 '20 21:11 techenby

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)

asantibanez avatar Nov 30 '20 18:11 asantibanez

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.

techenby avatar Nov 30 '20 23:11 techenby

@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?

davidhsianturi avatar Sep 01 '21 06:09 davidhsianturi

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.

asantibanez avatar Feb 01 '23 18:02 asantibanez

Hello, can you please provide some clarification on how to use extras.tooltip? As it is not clear right now.

pkaratzhs avatar Jun 21 '23 15:06 pkaratzhs