I am sending my data to the front-end of ConsoleTvs 7 Chartisan chart using the built in back-end advancedDataset
method. As the third parameter I decided to send extra dataset configurations in array data type:
// Example of extra info data that forms part of chartData return
$data['extra'] = ['type' => 'line', 'fill' => false, 'borderColor' => '#FF6F6F', 'backgroundColor' => '#FF6F6F', 'hidden' => true,
'datalabels' => ['display' => true], 'borderDash' => [5, 5]];
//--> within handler method
public function handler(Request $request): Chartisan
{
$data = $this->chartData($request); // Trait method chartData return
$chart = Chartisan::build()
->labels($data["labels"]);
foreach ($data['dataset'] as $key => $values) {
$chart->advancedDataset($values['legend'], $values['data'], $values['extra']);
// ^
//----------------------------- -------------------------------------| extra arg
}
return $chart;
}
This extra values are not applied to the datasets configuration. In fact the chart renders its default bar chart if I remove the ChartisanHooks.datasets(...[ configurations ]...)
method.
How can I apply the extra dataset configs to the front-end without having to resort to double work? Is there a setting I am missing or how do I access the extra
argument?
Laravel 8
Chart.js v2.9.4
chartjs-plugin-datalabels v1.0.0
from Laravel 8 ConsoleTvs 7 - Apply dataset configuration through extra argument of advancedDataset method
No comments:
Post a Comment