@jgravois can you pass in the parameters via your Request?
Chartisan with Livewire
I followed Kevin McKee's excellent Interactive Charts in his Multitenancy Series and was able to add a chart to my livewire component .. thanks, Kevin.
I explored the Chartisan package and found this:
Chartisan allows for customizing how the HTTP request is performed. You can pass a property called options to the chart constructor and it will be directly passed to the fetch() function as the second parameter. This allows modifying how the request is performed at a deeper level by having total control of how the HTTP request is performed and allows for instance, appending headers or changing the request method. You can also append query parameters as usual by appending them on the chart URL at the url property.
so in App\Charts\MonthlySalesChart.php I am trying to add in an additional parameter so that I can pass this in the constructor and retrieve chart data from different months.
class MonthlySalesChart extends BaseChart
{
public function handler(Request $request, $dt): Chartisan
{
$monthlies = Invoice::mtd($dt);
$labels = collect($monthlies)->pluck('last_name')->toArray();
$totals = collect($monthlies)->pluck('gross')->toArray();
return Chartisan::build()
->labels($labels)
->dataset('Sales', $totals);
}
}
however when I do that, phpStorm has a hissy and tells me Declaration must be compatible with BaseChart->handler(request: \Illuminate\Http\Request) .
Clearly I didn't grasp the docs ... is anyone using Chartisan and able to pass in parameters?
Any insight is appreciated.
Please or to participate in this conversation.