Sencha chart series 동적 처리
2024. 11. 23. 23:42ㆍJavascript/Sencha
function getSeriesByData2() {
let data = [
{ DATE: 1732167001000, A: 13, B: 'aks-userpool-260158-vmss000000' },
{ DATE: 1732167001000, A: 13, B: 'aks-userpool-260158-vmss000001' },
{ DATE: 1732167001000, A: 14, B: 'aks-userpool-260158-vmss000002' },
{ DATE: 1732167061000, A: 7, B: 'aks-userpool-260158-vmss000003' },
{ DATE: 1732167061000, A: 17, B: 'aks-userpool-260158-vmss000006' },
{ DATE: 1732167121000, A: 18, B: 'aks-userpool-260158-vmss000006' },
];
// Extract unique B values manually
let uniqueKeys = [];
for (let i = 0; i < data.length; i++) {
let key = data[i].B;
if (uniqueKeys.indexOf(key) === -1) {
uniqueKeys.push(key); // Add key if it's not already in the array
}
}
// Generate series for each unique B
let series = [];
for (let j = 0; j < uniqueKeys.length; j++) {
let key = uniqueKeys[j];
series.push({
type: 'line',
title: key, // Use B as the series title
xField: 'DATE',
yField: 'A',
style: {
stroke: getRandomColor(), // Random color
lineWidth: 2,
},
marker: {
type: 'circle',
size: 4,
fillStyle: getRandomColor(),
},
});
}
return series;
}
function getRandomColor() {
// Generate a random hex color code
return '#' + Math.floor(Math.random() * 16777215).toString(16).padStart(6, '0');
}
'Javascript > Sencha' 카테고리의 다른 글
Sencha layout item들이 수평으로 꽉차게 보이도록 처리 (0) | 2024.11.24 |
---|---|
Sencha chart x축 글자 수직으로 표시하기 (0) | 2024.11.24 |
Sencha chart 데이터 타입이 time인 x축 포멧 지정하기 (0) | 2024.11.23 |
Sencha chart Oracle Date type을 그대로 받아 쓰려면.. (0) | 2024.11.23 |
Sencha chart tbar를 사용하여 상단 오른쪽에 버튼 추가하기 (0) | 2024.11.23 |