const MAX_POINTS = 30;
let cpu = 45, memory = 60;
function nextValue(prev) {
const next = prev + (Math.random() - 0.5) * 10;
return Math.max(5, Math.min(95, next));
}
function createPoint() {
cpu = nextValue(cpu);
memory = nextValue(memory);
return {
time: new Date().toLocaleTimeString('ko-KR', { hour12: false }),
cpu: Math.round(cpu * 10) / 10,
memory: Math.round(memory * 10) / 10
};
}
const data = [];
for (let i = 0; i < MAX_POINTS; i++) {
data.push(createPoint());
}
const chart = new wijmo.chart.FlexChart('#liveChart', {
chartType: wijmo.chart.ChartType.Line,
itemsSource: data,
bindingX: 'time',
series: [
{ name: 'CPU 사용률(%)', binding: 'cpu' },
{ name: '메모리 사용률(%)', binding: 'memory' }
],
axisY: { min: 0, max: 100, title: '사용률(%)' },
header: '실시간 시스템 모니터링'
});