Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stacked bar chart #49

Closed
ommyan opened this issue Jul 8, 2017 · 6 comments
Closed

stacked bar chart #49

ommyan opened this issue Jul 8, 2017 · 6 comments
Labels

Comments

@ommyan
Copy link

ommyan commented Jul 8, 2017

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

@fxcosta
Copy link
Owner

fxcosta commented Jul 8, 2017

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!

@ommyan
Copy link
Author

ommyan commented Jul 9, 2017

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,

dd

optionraw failed to generate json for 'options' and chart object, any suggest for me?

@Emhc
Copy link

Emhc commented Jul 13, 2017

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

@ommyan
Copy link
Author

ommyan commented Jul 13, 2017

i think this is another way to roma... :)
thank you so much

@fxcosta
Copy link
Owner

fxcosta commented Jul 19, 2017

@ommyan @Emhc It was a serious mistake of mine. The documentation was wrong. It has been corrected... b2b1560

@fxcosta fxcosta closed this as completed Jul 19, 2017
@ommyan
Copy link
Author

ommyan commented Jul 19, 2017 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants