I am using ApexChart and I am getting the below object from the server as a response and I want to transform it for the ApexChart data array,
//Below I am getting from server [ { "symbol": "A", "oi_sense": "Long Buildup", "date": "2024-02-27", "oi": 1329300, "color": "#000000" }, { "symbol": "A", "oi_sense": "Short Buildup", "date": "2024-02-28", "oi": 1841250, "color": "#FF0000" }, { "symbol": "B", "oi_sense": "Long Buildup", "date": "2024-02-29", "oi": 2493225, "color": "#000000" }, { "symbol": "B", "oi_sense": "Short Covering", "date": "2024-03-01", "oi": 2335515, "color": "#00FF00" } ] Need to map this way, and I give series : $xxx so once xxx is created, I assign directly series.
Symbol -> name, oi -> y color -> color
//Below what is expected by ApexChart as series and data. series: [ { name: "A", data: [{ x: 'W1', y: 1329300, color: '#000000' }, { x: 'W2', y: 1841250 }, { x: 'W3', y: 2493225 },] }, { name: "A", data: [{ x: 'W1', y: 43 }, { x: 'W2', y: 15 }, { x: 'W3', y: 43 }] }, { name: "B", data: [{ x: 'W1', y: 43 }, { x: 'W2', y: 15 }, { x: 'W3', y: 43 }] } ], How to transform this for series-compatible data?
Thank you
Источник: https://stackoverflow.com/questions/780 ... t-to-array
Мобильная версия