I have to show two donut charts which I created using Lavacharts, I have to render it on same view. Right now only last chart is displaying.Thanks in advance.!
mohitlandge opened this issue · 3 comments
mohitlandge commented
$lava = new Lavacharts;
$Popularity = $lava->DataTable();
$Popularity->addStringColumn('Country')
->addNumberColumn('Popularity')
->addRow(['Completed',
$quizCompletionCount['completed']
])
->addRow(['Incomplete',
$quizCompletionCount['incomplete']
]);
$lava->DonutChart('Popularity', $Popularity, [
'is3D' => false,
'height' => 350,
'width' => 450,
'pieHole' => 0.4
]);
$quizCompletionChartTemplate = View::make('dash.lavacharts', ['lava' => $lava, 'id' => "completion_quiz", 'hideNewBtn' => true])->render();
$lava1 = new Lavacharts;
$Popularity1 = $lava1->DataTable();
$Popularity1->addStringColumn('Country1')
->addNumberColumn('Popularity1')
->addRow(['Right percentage',
$quizPerformanceCount['right_percent']
])
->addRow(['Wrong percentage',
$quizPerformanceCount['wrong_percent']])
->addRow(['Left percentage',
$quizPerformanceCount['left_percent']]);
$lava1->DonutChart('Popularity1', $Popularity1, [
'is3D' => false,
'height' => 350,
'width' => 450,
'pieHole' => 0.4,
]);
$quizPerfromancenChartTemplate = View::make('vnnogile::dash.lavacharts1', ['lava' => $lava1, 'id' => "performence_quiz", 'hideNewBtn' => true])->render();
view files
render('DonutChart', 'Popularity', $id)?> render('DonutChart', 'Popularity1', $id)?>I tried using same & different view file for both the charts, still it's not rendering second chart.
mohitlandge commented
Controller code ->
$Popularity = \Lava::DataTable();
$Popularity->addStringColumn('Country')
->addNumberColumn('state')
->addNumberColumn('city')
->addRow(['Completed',
$quizCompletionCount['completed'],
])
->addRow(['Incomplete',
$quizCompletionCount['incomplete'],
]);
$Chart = \Lava::DonutChart('Popularity', $Popularity, [
'is3D' => false,
'height' => 350,
'width' => 450,
'pieHole' => 0.4,
'fontName' => 'Poppins',
]);
$quizCompletionChartTemplate = View::make('dash.lavacharts', [ 'id' => "completion_quiz", 'hideNewBtn' => true])->render();
$stocksTable = \Lava::DataTable();
$stocksTable->addStringColumn('Day of Month')
->addNumberColumn('Projected')
->addNumberColumn('Official')
->addRow(['Right percentage',
$quizPerformanceCount['right_percent'],
])
->addRow(['Wrong percentage',
$quizPerformanceCount['wrong_percent']])
->addRow(['Left percentage',
$quizPerformanceCount['left_percent']]);
$Chart = \Lava::DonutChart('stocksTable', $stocksTable, [
'is3D' => false,
'height' => 350,
'width' => 450,
'fontName' => 'Arial',
'pieHole' => 0.4,
]);
$quizPerfromancenChartTemplate = View::make(':dash.lavacharts1', [ 'id' => "performence_quiz", 'hideNewBtn' => true])->render();
view code ->
lavacharts.blade.php
{!! \Lava::render('DonutChart', 'Popularity','quiz_completion') !!}lavacharts1.blade.php
{!! \Lava::render('DonutChart', 'stocksTable','quiz_performance') !!}kevinkhill commented
If you check out the note in the blue box, it explains that the issue is that you are creating two instances of the Lavacharts library.
If you are using Laravel, you don't need to instantiate an instance manually, just register the service provider and use the singleton instance created in the service container.
$lava = new Lavacharts;
...
$lava1 = new Lavacharts;
is not needed. use the \Lava::
alias for everything.
kevinkhill commented
closing due to inactivity. Please open a new issue if needed 😃