title: Dynamic chart in laravel
body: <p>I am using <a href="https://github.com/ConsoleTVs/Charts" rel="nofollow noreferrer">ConsoleTVs/Charts</a> and it's working perfectly, now I want to make new <code>donut</code> chart with dynamic <code>values</code> &amp; <code>labels</code> but i have issues with it.</p>
  
  <h1>What I try to do:</h1>
  
  <p>I want to fetch all users that registered in my website and check their <code>provider</code> column, <strong>If is <code>null</code> label in my chart  be <code>Site</code></strong> otherwise <strong>get value of provider column</strong> and <strong>for result of this labels count the users</strong>.</p>
  
  <h1>Codes</h1>
  
  <p>this is function I'm using for my chart:</p>
  
  <pre><code>$providerUsers = Charts::database(User::all(), 'donut', 'morris')
      -&gt;title("My Cool Chart")
      -&gt;groupBy('provider')
      -&gt;responsive(true)
      -&gt;labels(['Google', 'Facebook', 'Github', 'Linkedin']);
  </code></pre>
  
  <h1>Issues</h1>
  
  <p>with my code above:</p>
  
  <ol>
  <li>My labels are static and not dynamic base on <code>provider</code> column</li>
  <li>Corrently I'm getting all my users as <code>Google</code> label</li>
  <li>I'm not sure how to should I count my users with specific provider <code>eg. google 2, facebook 0, site 10 etc.</code></li>
  </ol>
  
  <p><a href="https://ibb.co/n6gw1c" rel="nofollow noreferrer">Screenshot</a></p>
  
  <p><a href="https://i.stack.imgur.com/y0fAl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/y0fAl.png" alt="screenshot"></a></p>
  
  <h1>Update</h1>
  
  <p>Default chart function (provided in package documents)</p>
  
  <pre><code>Charts::create('donut', 'highcharts')
    -&gt;title('My nice chart')
    -&gt;labels(['First', 'Second', 'Third'])
    -&gt;values([5,10,20])
    -&gt;dimensions(1000,500)
    -&gt;responsive(false);
  </code></pre>
  
  <h1>UPDATE 2</h1>
  
  <p>I changed my code to using <code>bar</code> chart instead of <code>donut</code> and this is my current function:</p>
  
  <pre><code>$providercounter = DB::table('users')
              -&gt;select(DB::raw('count(provider) as count'),'users.provider')
              -&gt;groupBy('provider')
              -&gt;orderBy('count','desc')
              -&gt;get();
      dd($providercounter);
      $providerUsers = Charts::create('bar', 'highcharts')
         -&gt;title('User Providers')
         -&gt;elementLabel('User by this prvider')
         -&gt;labels([$providercounter])
         -&gt;values([$providercounter])
         -&gt;responsive(true);
  </code></pre>
  
  <p>as result of <code>dd($providercounter);</code> in my code i have:</p>
  
  <pre><code>Collection {#639 ▼
    #items: array:3 [▼
      0 =&gt; {#628 ▼
        +"count": 2
        +"provider": "facebook"
      }
      1 =&gt; {#638 ▼
        +"count": 1
        +"provider": "google"
      }
      2 =&gt; {#636 ▼
        +"count": 0
        +"provider": null
      }
    ]
  }
  </code></pre>
  
  <p>But in my blade i get <code>nothing!</code> my chart will disappear.</p>
  
  <p>How can I get my data in <code>$providerUsers</code> ?</p>