0👍
Since this.state.list is a list of objects, so you can simply use map method to loop through each object https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map. Then create new object with custom value.
let new_series = [];
this.state.list.map((obj) => {
let info = {
name: obj.channel_name + obj.channel_number, //from your code
data: obj.VALUE //from your code
}
new_series.push(info)
});
Then assign new list to your chart.
//chart data
var data = {
categories: ['June, 2015'],
series: new_series
]
};
- Chartjs-How can I add multiple datasets into my dropdown menu and keep it as dynamic as it is right now?
- Chartjs-Adding item to TooltipItems[] in ChartJS doesn't update labelColors
Source:stackexchange.com