How to display apexChart donut type data using javascript in laravel?

196
January 07, 2021, at 02:30 AM

I am using Laravel 8 and Apex Chart library to display donuts chart. I have data as,

var donutChartData = @json($data['donutChartData']);
let provider = [];
let total = [];
for(let key in donutChartData){
   provider.push(donutChartData[key]['provider']);
   total.push(donutChartData[key]['total']);
}
console.log(provider)
console.log(total)

For provider:

["Subway", "Broadway", "McDonald's"]

For Total Provider:

[22, 16, 13]

And code for chart is, var chart = c3.generate({ bindto: '#chart-donut-d', // id of chart wrapper data: { type: 'donut', // default type of chart

        columns: [
            // each columns data
            ['data1', 20],
            ['data2', 30],
            ['data3', 50]
        ],
        colors: {
            'data1': '#2c83b6',
            'data2': '#a5d8a2',
            'data3': '#9367b4',
        },
        names: {
            // name of each serie
            'data1': 'Organic Search',
            'data2': 'Email Campaign',
            'data3': 'Referral Links',
        }
    },
    legend: {
        show: true, //hide legend
    },
    padding: {
        bottom: 0,
        top: 0
    },
});

and chart display as

How can i add this data in chart. Thanks

Rent Charter Buses Company
READ ALSO
Using parent class to contain many instances of child class

Using parent class to contain many instances of child class

I am trying to write a data processing script and I think I'm misinterpreting the structure of Object Oriented Programming in Python

168
Java Bluetooth Server in Raspberry Pi 0w

Java Bluetooth Server in Raspberry Pi 0w

What is the simplest solution for creating Java Bluetooth Server in Raspberry Pi 0w?

171
How extract the element, id's and classes from a DOM node element to a string

How extract the element, id's and classes from a DOM node element to a string

I would like to know how I can extract the DOM tree string from an element

62