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

Is this code wrong ? #69

Open
manounou opened this issue Mar 23, 2018 · 1 comment
Open

Is this code wrong ? #69

manounou opened this issue Mar 23, 2018 · 1 comment

Comments

@manounou
Copy link

manounou commented Mar 23, 2018

Hi,
Im trying to display Nombre of customers by agent in a doughnut but it display me all agent in one doughnut

here is my code please can you show me my mistake ?

`$agent = User::where('role','=','agent')->pluck('username')->toArray();
$agents = implode(', ', $agent);

       $customerbyagent = app()->chartjs
            ->name('CustomerByAgent')
            ->type('doughnut')
            ->labels([$agents])
            ->datasets([
                [
                   'backgroundColor' => ['#ff6384'],
                  'data' => [10,12]
                ]
            ])
            ->options([]);`

In the render Javascript it display this

labels: ["Agent constantine\", \"Agent Alger"],

@wells
Copy link
Contributor

wells commented May 25, 2018

@manounou do not implode your array of agent names (nombres) into a single string.

Instead, pass $agent->toArray() into the labels() function for this library. You'll instead get labels: [ "Agent Constantine", "Agent Alger" ], in the JS frontend.

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

No branches or pull requests

2 participants