C
C
consumerdefault7892021-08-04 14:11:59
PHP
consumerdefault789, 2021-08-04 14:11:59

How to update data in apexcharts via ajax?

I want to request data from the server in order to change the chart depending on the date, what json-a format should I give it?

what is currently available when loading the page

var options = {
        series: [
                    {
            name: "user 1",
            data: 1,2,3,4,5,6,7
        },        {
               name: "user 2",
            data: 5,1,7,6,2,3,4
        },        {
            name: "user 2",
            data: 5,6,7,9,2,3,4
        }],
        chart: {
            height: 350,
            type: 'line',
            zoom: {
                enabled: false
            },
        },
        dataLabels: {
            enabled: false
        },
        stroke: {
            width: [2, 2, 2],
            curve: 'straight',
            dashArray: [0, 8, 5]
        },
        legend: {
            tooltipHoverFormatter: function(val, opts) {
                return val + ' - ' + opts.w.globals.series[opts.seriesIndex][opts.dataPointIndex] + ''
            }
        },
        markers: {
            size: 0,
            hover: {
                sizeOffset: 6
            }
        },
        xaxis: {
            categories:  1,2,3,4,5,6,7,8,9,10
            ,
        },
        grid: {
            borderColor: '#f1f1f1',
        }
    };


found an example

$.getJSON('https://example.com/test/test/', function(response) {
        chart.updateSeries([{
          name: 'Sales',
          data: response
        }])
      });

but how to update data for user 1,2,3 and categories for graphics?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question