F
F
feniksdv2021-04-15 12:55:25
JavaScript
feniksdv, 2021-04-15 12:55:25

How to transfer data from json to highcharts?

Hello. I receive data in json format, then I need to substitute them in data and categories.

{
   1: {0: "9,00", mouth: "Ноябрь", sum: 38}
   2: {0: "-1,00", mouth: "Декабрь", sum: 37}
   3: {0: "96,00", mouth: "Январь", sum: 133}
   4: {0: "-101,80", mouth: "Февраль", sum: 31.2}
   5: {0: "-21,20", mouth: "Март", sum: 10}
   6: {0: "10,00", mouth: "Апрель", sum: 20}
}

I can't figure out how to pass data from json.data->sum to data and json.data->mouth to categories.

Thank you.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Z
ZB Venom, 2021-04-15
@feniksdv

T
twobomb, 2021-04-15
@twobomb

// let data = {!! json_encode($arrRois) !!};

 let month = data.map(e=>e.mouth);
 let values = data.map(e=>e.sum);

xAxis: {
                tickPixelInterval: 50,
                categories: month, // сюда месяца
                tickmarkPlacement: 'on',
                labels: {
                    useHTML: true,
                },
            },

series: [{
                name: '',
                data: values, //как сюда засунуть sum
                marker: {
                    enabled: false
                }
            }]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question