Laravel highchart: How to display data in chart

I am trying to implemnt highchart to show sells from between certain date(2015-01-01 to current data). I have data in users table: I have created_at and price in users table. I also have other column but i don't need those for graph.

Now I want to show how much money I made from (2015-01-01 to current date) and It should be filterable based on per day,per month,every three month,year, according to this graph:

https://www.highcharts.com/demo/stock/responsive and it is using this data: https://demo-live-data.highcharts.com/aapl-c.json Chart:

Highcharts.getJSON('https://demo-live-data.highcharts.com/aapl-c.json', data => {
    const chart = Highcharts.stockChart('container', {
        chart: {
            height: 400
        },

    title: {
        text: 'Highcharts Stock Responsive Chart'
    },

    subtitle: {
        text: 'Click small/large buttons or change window size to test responsiveness'
    },

    rangeSelector: {
        selected: 1
    },

    series: [{
        name: 'AAPL Stock Price',
        data: data,
        type: 'area',
        threshold: null,
        tooltip: {
            valueDecimals: 2
        }
    }],

    responsive: {
        rules: [{
            condition: {
                maxWidth: 500
            },
            chartOptions: {
                chart: {
                    height: 300
                },
                subtitle: {
                    text: null
                },
                navigator: {
                    enabled: false
                }
            }
        }]
    }
});

document.getElementById('small').addEventListener('click', () => {
    chart.setSize(400);
});

document.getElementById('large').addEventListener('click', () => {
    chart.setSize(800);
});

document.getElementById('auto').addEventListener('click', () => {
    chart.setSize(null);
});
});
   

       

Now question is I didn't understand the data used by this graph. The first may be timestamp and second may be value. I am not sure how to deal with my data:

I think below query will time total price between two dates. But what should I need to do to show data based on graph. User::whereBetween('created_at', [$from, $to])->sum('price')->get();

Any help highly appreciated.



Read more here: https://stackoverflow.com/questions/68477202/laravel-highchart-how-to-display-data-in-chart

Content Attribution

This content was originally published by David at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: