수식에서 다음과 같이 BulletSparkline 함수를 사용하여 글머리 기호 스파크라인을 만들 수 있습니다. =BULLETSPARKLINE(measure, target, maxi, good?, bad?, forecast?, tickunit?, colorScheme?, vertical?)
이 함수에는 다음과 같은 매개 변수가 있습니다.
measure: 측정 막대의 길이를 나타내는 숫자 또는 참조입니다(예: 5 또는 "A1").
target: 대상 선의 위치를 나타내는 번호 또는 참조입니다(예: 7 또는 "A2").
maxi: 스파크라인의 최대값을 나타내는 숫자 또는 참조입니다(예: 10 또는 "A3").
good\: (선택 사항) 좋은 막대의 길이를 나타내는 숫자 또는 참조입니다(예: 3 또는 "A4"). 기본값은 0입니다.
bad\: (선택 사항) 잘못된 막대의 길이를 나타내는 숫자 또는 참조입니다(예: 1 또는 "A5"). 기본값은 0입니다.
forecast\: (선택 사항) 예측 선의 길이를 나타내는 숫자 또는 참조입니다(예: 8 또는 "A6"). 기본값은 0입니다.
tickunit\: (선택 사항) 눈금 단위를 나타내는 숫자 또는 참조입니다(예: 1 또는 "A7"). 기본값은 0입니다.
colorScheme\: (선택 사항) 스파크라인을 표시할 색 그룹을 생성하기 위한 색 구성표를 나타내는 문자열입니다. 기본값은 "#A0A0A0"입니다.
vertical\: (선택 사항) 스파크라인을 세로로 표시할지 여부를 나타내는 부울입니다. 기본값은 false입니다.
measureColor: (선택 사항) 측정 막대 색상을 나타내는 문자열입니다.
targetColor: (선택 사항) 대상 선의 색상을 나타내는 문자열입니다.
maxiColor: (선택 사항) 최대 영역 색상을 나타내는 문자열입니다.
goodColor: (선택 사항) 양호한 영역 색상을 나타내는 문자열입니다.
badColor: (선택 사항) 잘못된 영역 색상을 나타내는 문자열입니다.
forecastColor: (선택 사항) 예측 선 색상을 나타내는 문자열입니다.
allowMeasureOverMaxi: (선택 사항) 측정이 최대 영역을 초과할 수 있는지 여부를 나타내는 부울입니다. 기본값은 false입니다.
barSize: (선택 사항) 셀 높이/너비에 따른 막대 너비/높이의 백분율을 나타내는 숫자입니다. (value > 0 && value <= 1)
var spreadNS = GC.Spread.Sheets, spread;
window.onload = function () {
spread = new GC.Spread.Sheets.Workbook(document.getElementById("ss"), { sheetCount: 2 });
initSpread(spread);
document.getElementById('colorScheme').addEventListener('change',applyChanges);
document.getElementById('measureColor').addEventListener('change',applyChanges);
document.getElementById('targetColor').addEventListener('change',applyChanges);
document.getElementById('maxiColor').addEventListener('change',applyChanges);
document.getElementById('goodColor').addEventListener('change',applyChanges);
document.getElementById('badColor').addEventListener('change',applyChanges);
document.getElementById('forecastColor').addEventListener('change',applyChanges);
document.getElementById('allowMeasureOverMaxi').addEventListener('change',applyChanges);
document.getElementById('barSize').addEventListener('change',applyChanges);
};
function applyChanges() {
var sheet = spread.getActiveSheet();
if (spread.getActiveSheetIndex() == 0) {
for (var index = 3; index < 9; index++) {
sheet.setFormula(index, 1, '=BULLETSPARKLINE($E' + (index + 1) + ','+
'$F' + (index + 1) +','+
'$G' + (index + 1) + ','+
'$H' + (index + 1) + ','+
'$I' + (index + 1) + ','+
'$D' + (index + 1) + ',1,"' +
document.getElementById('colorScheme').value + '",false,"'+
document.getElementById('measureColor').value + '","'+
document.getElementById('targetColor').value + '","'+
document.getElementById('maxiColor').value + '","'+
document.getElementById('goodColor').value + '","'+
document.getElementById('badColor').value + '","'+
document.getElementById('forecastColor').value +'",'+
document.getElementById('allowMeasureOverMaxi').checked +','+
document.getElementById('barSize').value );
}
} else if (spread.getActiveSheetIndex() == 1) {
for (var index = 2; index < 8; index++) {
var columnChar = String.fromCharCode(65 + index);
sheet.setFormula(9, index, '=BULLETSPARKLINE($' + columnChar + '5,'+
'$' + columnChar +'6,'+
'$' + columnChar +'7,'+
'$' + columnChar + '8,'+
'$' + columnChar + '9,'+
'$' + columnChar + '4,1,"' +
document.getElementById('colorScheme').value + '",true,"'+
document.getElementById('measureColor').value + '","'+
document.getElementById('targetColor').value + '","'+
document.getElementById('maxiColor').value + '","'+
document.getElementById('goodColor').value + '","'+
document.getElementById('badColor').value + '","'+
document.getElementById('forecastColor').value +'",'+
document.getElementById('allowMeasureOverMaxi').checked +','+
document.getElementById('barSize').value );
}
}
}
function initSpread(spread) {
spread.options.newTabVisible = false;
initHorizontalSparkline(spread.sheets[0], "Horizontal");
initVerticalSparkline(spread.sheets[1], "Vertical");
};
function initHorizontalSparkline(sheet, name) {
sheet.suspendPaint();
sheet.name(name);
sheet.addSpan(1, 1, 1, 8);
sheet.getCell(1, 1).value("Revenue By Region (million $)")
.font("20px Calibri").hAlign(spreadNS.HorizontalAlign.center).vAlign(spreadNS.VerticalAlign.center)
.foreColor("white").backColor("#82bc00");
sheet.getRange(2, 1, 1, 8).vAlign(spreadNS.VerticalAlign.center)
.font("bold 16px Calibri")
.backColor("#F4F8EB");
sheet.getRange(3, 1, 6, 7).font("20px").vAlign(spreadNS.VerticalAlign.center);
sheet.getRange(2, 1, 7, 8).setBorder(new GC.Spread.Sheets.LineBorder("Black", GC.Spread.Sheets.LineStyle.thin), {
all: true
});
sheet.getRange(3, 1, 6, 8).setBorder(new GC.Spread.Sheets.LineBorder("Black", GC.Spread.Sheets.LineStyle.dotted), {
inside: true
});
sheet.setArray(2, 2, [
['Region', 'Forecast', 'Actual', 'Target', 'Max', 'Optimist F.','Pessimist F.',' '],
['North America', 80, 75, 70, 95, 65, 50],
['South America', 79, 62, 80, 95, 75, 50],
['Europe', 95, 100, 100, 120, 90, 80],
['Azia', 80, 95, 80, 90, 70, 55],
['Australia', 35, 20, 40,50, 35, 15],
['Africa', 34, 40, 30,50, 20, 15]
]);
for (var index = 3; index < 9; index++) {
sheet.setFormula(index, 1, '=BULLETSPARKLINE($E' + (index + 1) + ','+
'$F' + (index + 1) +','+
'$G' + (index + 1) + ','+
'$H' + (index + 1) + ','+
'$I' + (index + 1) + ','+
'$D' + (index + 1) + ',1,"#FFFFFF",false,"#000000","#F7A711","#DDDDDD","#BBBBBB","#999999","#FFFFFF",TRUE,0.7');
}
sheet.setRowHeight(1, 30);
for (var i = 3; i < 9; i++) {
sheet.setRowHeight(i, 40);
}
for (var j = 2; j < 9; j++) {
sheet.setColumnWidth(j, 100);
}
sheet.setColumnWidth(1, 250);
sheet.resumePaint();
}
function initVerticalSparkline(sheet, name) {
sheet.suspendPaint();
sheet.name(name);
sheet.addSpan(1, 1, 1, 7);
sheet.getCell(1, 1).value("Revenue By Region (million $)")
.font("20px Calibri").hAlign(spreadNS.HorizontalAlign.center).vAlign(spreadNS.VerticalAlign.center)
.foreColor("white").backColor("#82bc00");
sheet.getRange(2, 1, 7, 1).vAlign(spreadNS.VerticalAlign.center)
.font("bold 16px Calibri")
.backColor("#F4F8EB");
sheet.getRange(2, 2, 7, 6).font("20px").vAlign(spreadNS.VerticalAlign.center);
sheet.getRange(2, 1, 7, 7).setBorder(new GC.Spread.Sheets.LineBorder("Black", GC.Spread.Sheets.LineStyle.thin), {
all: true
});
sheet.getRange(2, 2, 7, 6).setBorder(new GC.Spread.Sheets.LineBorder("Black", GC.Spread.Sheets.LineStyle.dotted), {
inside: true
});
sheet.setArray(2, 1, [
['Region', 'North America', 'South America', 'Europe', 'Azia', 'Australia','Africa'],
['Forecast', 80, 79, 95, 80, 35, 34],
['Actual', 75, 62, 100, 95, 20, 40],
['Target',70, 80, 100, 80, 40, 30],
['Max',95, 95, 120, 90, 50, 50],
['Optimist F.', 65, 75, 90,70, 35, 20],
['Pessimist F.', 50, 50, 80,55, 15, 15]
]);
for (var index = 2; index < 8; index++) {
var columnChar = String.fromCharCode(65 + index);
sheet.setFormula(9, index, '=BULLETSPARKLINE($' + columnChar + '5,'+
'$' + columnChar +'6,'+
'$' + columnChar +'7,'+
'$' + columnChar + '8,'+
'$' + columnChar + '9,'+
'$' + columnChar + '4,1,"#FFFFFF",TRUE,"#000000","#F7A711","#DDDDDD","#BBBBBB","#999999","#FFFFFF",TRUE,0.7');
}
sheet.setRowHeight(1, 30);
sheet.setRowHeight(9, 200);
for (var j = 1; j < 8; j++) {
sheet.setColumnWidth(j, 100);
}
sheet.resumePaint();
}
<!doctype html>
<html style="height:100%;font-size:14px;">
<head>
<meta name="spreadjs culture" content="ko-kr"/>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" type="text/css" href="$DEMOROOT$/ko/purejs/node_modules/@mescius/spread-sheets/styles/gc.spread.sheets.excel2013white.css">
<script src="$DEMOROOT$/ko/purejs/node_modules/@mescius/spread-sheets/dist/gc.spread.sheets.all.min.js" type="text/javascript"></script>
<script src="$DEMOROOT$/ko/purejs/node_modules/@mescius/spread-sheets-resources-ko/dist/gc.spread.sheets.resources.ko.min.js" type="text/javascript"></script>
<script src="$DEMOROOT$/spread/source/js/license.js" type="text/javascript"></script>
<script src="app.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="styles.css">
</head>
<body>
<div class="sample-tutorial">
<div id="ss" class="sample-spreadsheets"> </div>
<div class="options-container">
<div>
<label><b>Settings:</b></label>
</div>
<hr>
<div class="option-row">
<label for="colorScheme">Color Scheme:</label>
<select id="colorScheme" style="margin: 0 20px 0 6px">
<option value="#FFFFFF" selected>White</option>
<option value="#000000">Black</option>
<option value="#F7A711">Orange</option>
<option value="#DDDDDD">LightGrey</option>
<option value="#BBBBBB">Grey</option>
<option value="#999999">DarkGrey</option>
<option value="#82BC00">Green</option>
</select>
</div>
<div class="option-row">
<label for="measureColor">Measure Color:</label>
<select id="measureColor" style="margin: 0 20px 0 6px">
<option value="#FFFFFF">White</option>
<option value="#000000" selected>Black</option>
<option value="#F7A711">Orange</option>
<option value="#DDDDDD">LightGrey</option>
<option value="#BBBBBB">Grey</option>
<option value="#999999">DarkGrey</option>
<option value="#82BC00">Green</option>
</select>
</div>
<div class="option-row">
<label for="targetColor">Target Color:</label>
<select id="targetColor" style="margin: 0 20px 0 6px">
<option value="#FFFFFF">White</option>
<option value="#000000">Black</option>
<option value="#F7A711" selected>Orange</option>
<option value="#DDDDDD">LightGrey</option>
<option value="#BBBBBB">Grey</option>
<option value="#999999">DarkGrey</option>
<option value="#82BC00">Green</option>
</select>
</div>
<div class="option-row">
<label for="maxiColor">Maximum Color:</label>
<select id="maxiColor" style="margin: 0 20px 0 6px">
<option value="#FFFFFF">White</option>
<option value="#000000">Black</option>
<option value="#F7A711">Orange</option>
<option value="#DDDDDD" selected>LightGrey</option>
<option value="#BBBBBB">Grey</option>
<option value="#999999">DarkGrey</option>
<option value="#82BC00">Green</option>
</select>
</div>
<div class="option-row">
<label for="goodColor">Optimist Color:</label>
<select id="goodColor" style="margin: 0 20px 0 6px">
<option value="#FFFFFF">White</option>
<option value="#000000">Black</option>
<option value="#F7A711">Orange</option>
<option value="#DDDDDD">LightGrey</option>
<option value="#BBBBBB" selected>Grey</option>
<option value="#999999">DarkGrey</option>
<option value="#82BC00">Green</option>
</select>
</div>
<div class="option-row">
<label for="badColor">Pessimist Color:</label>
<select id="badColor" style="margin: 0 20px 0 6px">
<option value="#FFFFFF">White</option>
<option value="#000000">Black</option>
<option value="#F7A711">Orange</option>
<option value="#DDDDDD">LightGrey</option>
<option value="#BBBBBB">Grey</option>
<option value="#999999" selected>DarkGrey</option>
<option value="#82BC00">Green</option>
</select>
</div>
<div class="option-row">
<label for="forecastColor">Forecast Color:</label>
<select id="forecastColor" style="margin: 0 20px 0 6px">
<option value="#FFFFFF" selected>White</option>
<option value="#000000">Black</option>
<option value="#F7A711">Orange</option>
<option value="#DDDDDD">LightGrey</option>
<option value="#BBBBBB">Grey</option>
<option value="#999999">DarkGrey</option>
<option value="#82BC00">Green</option>
</select>
</div>
<div style="padding-top: 16px">
<input type="checkbox" id="allowMeasureOverMaxi" checked="checked"/>
<label for="allowMeasureOverMaxi">Allow Measure Over Max</label>
</div>
<div class="option-row">
<label for="barSize">Bar Size:</label>
<input type="text" style="margin: 0 20px 0 6px;width:120px;" id="barSize" value="0.7"/>
</div>
</div>
</div>
</body>
</html>
.sample-tutorial {
position: relative;
height: 100%;
overflow: hidden;
}
.sample-spreadsheets {
width: calc(100% - 280px);
height: 100%;
overflow: hidden;
float: left;
}
.options-container {
float: right;
width: 280px;
padding: 12px;
height: 100%;
box-sizing: border-box;
background: #fbfbfb;
overflow: auto;
}
.option-row {
font-size: 14px;
padding: 5px;
margin-top: 10px;
}
label {
margin-bottom: 6px;
}
input {
padding: 4px 6px;
}
input[type=button] {
margin-top: 6px;
display: block;
}
input[type=text] {
margin-top: 6px;
margin-bottom: 6px;
}
body {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
}