stacked bar chart
ommyan opened this issue · comments
really appreciate for nice plugin.
let me know, how to create a stacked bar chart, I was tried to configure options with optionraw but doesn't work.
thanks
Hi, @ommyan! I've not tested it yet but see if this works: https://stackoverflow.com/questions/37249439/chartjs-v2-0-stacked-bar-chart
pass to optionsRaw
this setup and post result here, plz!
In My controller ,
`
$membershipChart = app()->chartjs
->name('barChartTest')
->type('bar')
->size(['width' => 400, 'height' => 200])
->labels(['PBU', 'PPU'])
->datasets([
[
"label" => "Aktual",
'backgroundColor' => ['rgba(255, 99, 132, 0.2)', 'rgba(54, 162, 235, 0.72)'],
'data' => [69, 59]
],
[
"label" => "Target",
'backgroundColor' => ['rgba(255, 99, 132, 0.3)', 'rgba(54, 162, 235, 0.93)'],
'data' => [65, 12]
]
]);
$membershipChart ->optionsRaw = "{
legend: {
display:false
},
scales: {
xAxes: [{
stacked:true,
gridLines: {
display:false
}
}]
}
}";
`
debuging with
dd ($membershipChart);
attached is result of debugging,
optionraw failed to generate json for 'options' and chart object, any suggest for me?
i had the same problem and i figured out a way to work around, might not be the best practice but hope this can help you:
$options = [];
$options['scales']['xAxes'][]['stacked'] = true;
$options['scales']['yAxes'][]['stacked'] = true;
$chartjs = app()->chartjs
->name('lineChartTest')
->type('bar')
->size(['width' => 400, 'height' => 200])
->labels($labels)
->datasets($data)
->options($options);
i think this is another way to roma... :)
thank you so much