const spread = new GC.Spread.Sheets.Workbook(document.getElementById('spreadContainer'));
const sheet = spread.getActiveSheet();
spread.options.tabStripVisible = false;
spread.suspendPaint();
const headers = ['이름','1월','2월','3월','4월','5월','6월','추세(Line)','막대(Column)','승패(WinLoss)'];
headers.forEach((h, c) => {
sheet.setValue(0, c, h);
sheet.getCell(0, c).backColor('#1565C0').foreColor('#fff').font('bold 12px sans-serif');
sheet.setColumnWidth(c, c === 0 ? 72 : c >= 7 ? 88 : 58);
});
sheet.setRowHeight(0, 32);
// 6개월 성과 점수 (목표: 78점)
const TARGET = 78;
const data = [
['김민준', 82, 76, 88, 91, 79, 95],
['이서연', 70, 85, 60, 78, 90, 88],
['박지호', 95, 88, 72, 66, 84, 91],
['최유진', 60, 65, 70, 75, 80, 85],
];
// WinLoss 보조 데이터를 별도 숨김 시트에 저장
// (setColumnWidth(c,0)으로 숨긴 열은 스파크라인이 데이터를 참조하지 못하는 SpreadJS 특성 우회)
const wlSheet = new GC.Spread.Sheets.Worksheet('WLData');
spread.addSheet(1, wlSheet);
data.forEach((row, r) => {
row.forEach((val, c) => sheet.setValue(r + 1, c, val));
sheet.setRowHeight(r + 1, 32);
// WinLoss용: (점수 - 목표) → 양수=달성(↑), 음수=미달(↓)
row.slice(1).forEach((val, i) => wlSheet.setValue(r, i, val - TARGET));
});
const SpType = GC.Spread.Sheets.Sparklines.SparklineType;
const Orient = GC.Spread.Sheets.Sparklines.DataOrientation;
data.forEach((_, r) => {
const dataRange = new GC.Spread.Sheets.Range(r + 1, 1, 1, 6);
// Line 스파크라인 — 월별 점수 추세
const lineSetting = new GC.Spread.Sheets.Sparklines.SparklineSetting();
lineSetting.options.showMarkers = true;
lineSetting.options.lineWeight = 2;
lineSetting.options.seriesColor = '#0078D4';
lineSetting.options.highMarkerColor = '#E53935';
lineSetting.options.lowMarkerColor = '#8BC34A';
sheet.setSparkline(r + 1, 7, dataRange, Orient.horizontal, SpType.line, lineSetting);
// Column 스파크라인 — 월별 점수 크기 비교
const colSetting = new GC.Spread.Sheets.Sparklines.SparklineSetting();
colSetting.options.seriesColor = '#43A047';
colSetting.options.negativeColor = '#E53935';
sheet.setSparkline(r + 1, 8, dataRange, Orient.horizontal, SpType.column, colSetting);
// WinLoss 스파크라인 — 목표(78점) 달성(↑)/미달(↓) 이진 표현
// WLData 시트의 차이값(양수/음수)을 크로스시트 참조로 구동
const wlSetting = new GC.Spread.Sheets.Sparklines.SparklineSetting();
wlSetting.options.seriesColor = '#7B1FA2';
wlSetting.options.negativeColor = '#FFCA28';
sheet.setSparkline(r + 1, 9, `WLData!A${r + 1}:F${r + 1}`, Orient.horizontal, SpType.winloss, wlSetting);
});
spread.resumePaint();