Category : chart.js

This is my query to get the product name and total quantity sold. $prd = DB::table(‘order_details’) ->join(‘products’, ‘order_details.product_id’, ‘=’, ‘products.id’) ->select(‘products.name’, DB::raw(‘SUM(quantity) as quantity’)) ->groupBy(‘products.name’) ->orderBy(‘quantity’, ‘desc’) ->get(); return $prd; This is the output. [ { "name": "PINK", "quantity": "22" }, { "name": "WHITE", "quantity": "14" }, { "name": "RED", "quantity": "13" } ] But ..

Read more

Can someone direct me to example how can I use https://www.chartjs.org/chartjs-plugin-annotation/guide/usage.html with Laravel http://lavacharts.com/ Lavacharts package? I tried to add config to "annotations" array (as in example http://lavacharts.com/#chart-bar) but with no luck. which steps i need to reproduce to get this plugin to work with my existing charts? tnx! Y Sourc..

Read more

I´m traying to create statistics from my database. I´m changing application and before statistics was created from call table. But i change this and i was created a new table statistics and have this column: id, id_ployed, call_id, created_at(nullable), updated_at(nullable) and data example for example: 52,60,88988,4 53,60,88989,10 54,60,88990,6 62,9,88999,1 i have this function in my ..

Read more

I want to make a bar stacked graph with 2 datasets with Chartjs 6 – Laravel 8 $chart->labels($resultados1); $chart->dataset(‘Dataset1′,’bar’,$resultados2)->backgroundColor(collect([‘#7158e2’])); $chart->dataset(‘Dataset2′,’bar’,$resultados3)->backgroundColor(collect([‘#1158e2’])); //>>>>>>>>$chart->scales(‘xAxes’,’stacked’ => true , ‘yAxes’ => [‘stacked’ => true]);<<<<<<<<<<<<<<<<<<<<<< But obviously this last commented line is wrong I’ve found how to make this by javascript but I need to put this on laravel code easily ..

Read more

im trying to pass the content of the database to the dataset for the chartjs but the errors says UNEXPECTED TOKEN < IN JSON AT POSITION 0. this chartjs version is 7 samplechart.php <?php declare(strict_types = 1); namespace AppCharts; use ChartisanPHPChartisan; use ConsoleTVsChartsBaseChart; use IlluminateHttpRequest; class SampleChart extends BaseChart { /** * Handles the HTTP ..

Read more

I’m currently doing the dashboard in our project and can’t progress because of this error. Call to undefined method AppChartsSampleChart::labels(). I suspect that I missed some installation and configurations but I’ve done it several times now. SampleChart.php <?php declare(strict_types = 1); namespace AppCharts; use ChartisanPHPChartisan; use ConsoleTVsChartsBaseChart; use IlluminateHttpRequest; class SampleChart extends BaseChart { /** ..

Read more

I am new to laravel and with chart.js I did surf online but didn’t find the proper solution yet, Any help and suggestions would be great. Here is the link to a similar issue with some code overview. Please tell me if you need anything else. Hey guys,I need help to display datalabels from chartjs ..

Read more

I don’t know, how much time I lost looking for solution for this issue. I wanted to use Chart.js in my Laravel project, so I followed instructions described here. composer require fx3costa/laravelchartjs (runned) Fx3costaLaravelChartJsProvidersChartjsServiceProvider::class (added in the right place) npm i chart.js (used to install chart.js) In my controller and blade I used code from ..

Read more

I am using chart.js, Laravel 5.4 and blade templates. I have to show doughnut chart and when user click on particular area then it should show the name of selected label and value belongs to it in the modal but firstly I am not able to get label name when user click on doughnut chart. ..

Read more

I´m traying to create a graphic in my app developed in Laravel 5.6. I´m sending all my data from my controller with one array. $callSend = array(); foreach($result as $call){ array_push($callSend, Cita::where(‘id_llamada’, $call->id) ->with("estado") ->get()); } Cita it´s my model to get all my data this return this: (754) [Array(1), Array(1), Array(1), Array(1), Array(1), Array(1), Array(1), ..

Read more

var ctx = document.getElementById("myLineChart").getContext(‘2d’); var myLineChart = new Chart(ctx, { type: ‘line’, data: { labels: [ @foreach($year as $year) "{{$year->year}}", @endforeach ], datasets: [ { label: ‘A’, data: [ @foreach($data1 as $dt1) {{$dt1->total}}, @endforeach ], borderColor: ‘rgba(75, 192, 192, 1)’, backgroundColor: ‘rgba(75, 192, 192, 0.2)’, }, { label: ‘B’, data: [ @foreach($data2 as $dt2) {{$dt2->total}}, ..

Read more

I am importing my chart js code from <script src="{{ asset(‘/css/tailwind/js/charts-bars.js’) }}" defer></script> I have some data from the controller and may I ask is it possible to pass the data to this script before the chart gets rendered? My charts-bars.js code const barConfig = { type: ‘bar’, data: { labels: [‘January’, ‘February’, ‘March’, ‘April’, ..

Read more

I’m currently working on a dashboard and im trying to display a score across a lot of people. Here is my chart.js code. <script> const labels = [ @foreach($all_staff as $staff) @php $i++; @endphp ‘{{ $i }}’, @endforeach ]; const data = { labels: labels, datasets: [{ label: ‘My First dataset’, backgroundColor: ‘rgb(255, 99, 132)’, ..

Read more

I would like to ask how install and integrate [email protected] with my laravel application. I use cdn links right now but later it wont be an option for me later. Used cdn links: <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.2/moment.min.js"</script> <script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.4/Chart.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/[email protected]"></script> Method I tried: Installing chartjs npm i [email protected] Add this line in webpack.mix.js: mix.copy(‘node_modules/chart.js/dist/chart.js’, ‘public/chart.js/chart.js’); Then ..

Read more

I’m using Chartisan with Chart.js & Laravel. How do I make use of these hooks to access the more complicated styling options in Chart.js? https://chartisan.dev/documentation/frontend/hooks#Custom-Hooks https://www.chartjs.org/docs/latest/samples/scale-options/grid.html <div x-data="{chart: null}" x-init="chart = new Chartisan({ el: ‘#{{ $chartPath }}’, url: ‘@chart($chartPath)’, hooks: new ChartisanHooks() .datasets([{ type: ‘line’, fill: true, borderColor: ‘#BBE9DE’, tension: 0.1 }]) {{– .options({ title: ..

Read more