-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathc2i_Motion.html
344 lines (306 loc) · 17.5 KB
/
c2i_Motion.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>C2i:모션차트(Motion Chart)</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<script src="assets/lib/d3.min.js" charset="utf-8"></script>
<script src="assets/lib/three.min.js"></script>
<script src="assets/js/c2i.v2.min.js"></script>
<script src="assets/i18n/c2i_kr.js"></script>
<!-- 다국어 사용시 아래 스크립트 필요합니다. (사용하지 않으면 제거) -->
<script src="assets/i18n/c2i_en.js"></script>
<script src="assets/i18n/c2i_jp.js"></script>
<script src="assets/i18n/c2i_ch.js"></script>
<!-- 정품 인증번호 발급 및 적용시 아래 스크립트 필요합니다. -->
<!--<script src="../assets/c2iLicenseKey.js"></script>-->
<link rel="stylesheet" href="assets/css/bootstrap.min.css">
<link rel="stylesheet" href="assets/css/c2i.v2.min.css">
<link rel="stylesheet" href="assets/css/demo.css">
<link rel="shortcut icon" type="image/png" href="favicon.png"/>
<style>
.c2iMotion .labelDim {
fill: yellow !important;
}
/* .c2iDynamicSelect {
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
-webkit-box-shadow: 4px 4px 10px rgba(0, 0, 0, 0.4);
-moz-box-shadow: 4px 4px 10px rgba(0, 0, 0, 0.4);
box-shadow: 4px 4px 10px rgba(0, 0, 0, 0.4);
padding: 10px;
border: 1px solid #ccc;
border-radius: 3px;
overflow: hidden;
background: transparent;
}
.c2iDynamicSelect option:hover {
box-shadow: 0 0 10px 100px #b4b4b4 inset;
}
*/
.colorPickerTip{
margin: 2px 0;
padding: 0 2px;
}
.c2iOption {
z-index: 100 !important;
}
</style>
</head>
<body>
<div class="container-fluid">
<div class="row">
<div class="col-sm-offset-1 col-md-offset-1 col-lg-offset-1 col-md-1">
<a href="index.html#c2iDemo" style="color: white"><div class="btn btn-primary btn-sm btn-group-justified">홈</div></a>
</div>
</div>
<div class="row">
<div class="col-sm-offset-1 col-md-offset-1 col-lg-offset-1 col-sm-10 col-md-10 col-lg-10">
<div id="c2iChart01" class="c2iPlace c2iMotion" data-c2iTitle="출발 장소"></div>
</div>
</div>
<div class="row">
<div class="col-sm-6 col-md-6 col-lg-6">
<div id="c2iChart11" class="c2iPlace c2iMotion c2iNoSelect demoClass" title="나는 출발 아래"></div>
</div>
<div class="col-sm-6 col-md-6 col-lg-6">
<div id="c2iChart12" class="c2iPlace c2iMotion c2iNoSelect demoClass" title="출발 아래 옆자리"></div>
</div>
</div>
<div class="row">
<div class="col-sm-12 col-md-12 col-lg-12">
<div id="c2iChart20" class="c2iPlace c2iMotion c2iNoSelect demoClass" data-c2iTitle="가장 아래"></div>
</div>
</div>
</div>
<!-- 자동 툴팁 사용시 name, measure는 필수 존재 내역입니다.
Custom Tooltip은 별도 ID로 만들어 사용자가 임의로 프로그램 가능합니다. -->
<div id="tooltip" class="c2iTooltip c2iHidden">
<table style="width:200px">
<thead>
<tr>
<th colspan='4' class="tipHeader">
<div class="c2iCloseBtn" title="닫기">X</div>
<p><strong><span id="name">판매본부</span></strong></p>
<p id="measure" style="font-size: 14px; color:yellow">1,200</p>
<hr style="margin:2px 0px;"> <!-- ratio가 있거나 hr 태그가 존재해야 합니다 -->
<p id="ratio"></p>
<!--<p><span id="testId" style="font-size: 12px; color: orange;">사용자 임의 툴팁 적용시,<br> 제공 데이터로 재구성 가능.</span></p>-->
</th>
</tr>
</thead>
</table>
</div>
<script>
/*
대.소문자는 반드시 준수해야 합니다.
옵션이 없거나(미정의) '' 이면, 필수요소는 기본값 자동 적용되며 불필요한 옵션은 자동으로 적용되지 않습니다.
*** 공통 정보
-. isResponsive: true, false (기본값: false)
-. width (단위: %, px) : % -> 상위 컨테이너 대비, px -> 절대 사이즈인 경우.(미 설정시 상위의 100% 설정)
-. aspectRatio : 4:3 (= 1.333), 16:9 (= 1.777) 기본값, 또는 width 대비 % 설정 가능
-. height (단위: px) : aspectRatio 없이 height 설정하면 적용 가능.(비 반응형시 추천)
-. theme : #efefef, #444363, #333333 (제거: none)
-. lang : 언어 설정(기본값:'kr')
-. margin : x,y축이 설정 및 점유하는 영역.(기본값 margin : {top: 30, left: 30, right: 30, bottom: 30, isDynamic: true})
top ~ bottom: 기본값 -> 30, 차트의 내역(실제 막대, 라인 등)이 그려질 영역 설정용도
-. easing : 애니메이션시 적용될 기본 알고리즘 (linear, elastic, exp, bounce, quad, cubic, sin, circle, back)
-. duration: 50~1500 ms(기본값 50), delay: 10~500 ms(기본값 10)
-. bgImg : 외부 제공시 기업의 로고등을 표시하기 위한 것으로 표시하지 않으려면 제거합니다.
-. data : 씨투아이에 주입될 데이터 객체로서 직접 주입해도 되며, 다른 옵션 처럼 추후 주입해도 됩니다.
-. preBuildData : 컴포넌트마다 데이터 구조는 상이하나,
true : 별도의 작업 없이 바로 사용가능한 구조(x축이 Numeric인 경우는 항상 true 구조이어야 함),
false: 내부에서 전처리 작업을 하므로 부하가 존재하나 대부분 무시해도 될 수준입니다.
false 지원 이유는 데이터 제공의 서버 알고리즘을 용이하게 하기 위함입니다.
-. linearBeginZero : 선형인 경우(사분면 차트는 모두 선형), 0(zero)값으로 각각의 축 표시 시작 (기본값 true)
-. rawStructure : preBuildData == false 경우,
colNm : 원시 데이터의 컬럼명을 보관하는 컬럼명
valNm : 원시 데이터의 값을 보관하는 컬럼명
-. title : 컨포넌트의 제목을 표시하기 위한 장소이며, 특히 데이터 정렬을 적용하는 차트(표준, 피라미드, 파이 등)에서는
정렬 상태를 부 제목을 통해 제공합니다.
.caption: 제목 명칭
.fonts:제목 폰트 (기본값:['helvetica','20px','#434343'])
.textDeco: underline/line-through/overline
.gap: x, y 의 여유 공간 조정용도
.xPos:start, middle, end, yPos: top,middle, bottom,
.subCaption: 주 제목 명칭, subFonts, opacity:1,
.desc: 제목 툴팁
-. isDev : 개발 모드 여부.
.true: 옵션 창에 개발자용 메뉴 표시되며, 실행시 로그 정보 표시
*** xDim
-. colNm : x축 컬럼명
-. scale : linear, log, sqrt
-. axisPos : x축의 tick 값 대비 tick 위치 'top', 'bottom' (기본값 : bottom)
-. dy : x축 제목명을 표시하기 위한 간격 조정 용도(기본값, dy : -6)
-. ticks : x축의 표시할 값의 갯수 (기본값 : 10)
-. tickPad : x축의 표시할 축과 값의 간격 (기본값 : 0)
-. showGrid : x축 그리드 표시 여부(기본값 : true)
-. rotate : x축 레이블 회전 각도(기본값 : 0, -45 ~ 45)
-. maxGap: .0 ~ .50 ( 0% ~ 50% ), 최대값을 표현하고자 축을 좀더 크게 만든다.
없으면 최소/대 실제 값이 상하한 선으로 설정되므로 상하의 여유가 없게 표시됩니다.
-. barColor: [색상1, 색상1, scale] (기본값 : ['steelblue', 'white', 'radial'])
.색상: 웹 색상 모든 형태 지원.(#ff00ff, yellow, rgb(255,0,0))
.scale: 'linear', 'radial'
-. barFonts : 컬럼명 표시 폰트 (기본값 : ['helvetica','11px','yellow'])
-. fonts: x축의 tick 값 표시하기 위한 폰트 (기본값 : ['helvetica','11px','gray'])
*** yDim
-. colNm : y축 컬럼명
-. scale : linear, log, sqrt
-. axisPos : y축의 tick 값 대비 tick 위치 'left', 'right' (기본값 : left)
-. dx, dy : x축 제목명을 표시하기 위한 간격 조정 용도(기본값 -> dx: 10, dy : 3)
-. ticks : x축의 표시할 값의 갯수 (기본값 : 10)
-. tickPad : x축의 표시할 축과 값의 간격 (기본값 : 0)
-. showGrid : x축 그리드 표시 여부(기본값 : true)
-. rotate : x축 레이블 회전 각도(기본값 : 0, -45 ~ 45)
-. maxGap: .0 ~ .50 ( 0% ~ 50% ), 최대값을 표현하고자 축을 좀더 크게 만든다.
없으면 최소/대 실제 값이 상하한 선으로 설정되므로 상하의 여유가 없게 표시됩니다.
-. captionV : 세로글자 -> 한글은 true(dx:10, dy:3), 영문은 -90(dx:-3, dy:12)
-. barColor: [색상1, 색상1, scale] (기본값 : ['steelblue', 'white', 'radial'])
.색상: 웹 색상 모든 형태 지원.(#ff00ff, yellow, rgb(255,0,0))
.scale: 'linear', 'radial'
-. barFonts : 컬럼명 표시 폰트 (기본값 : ['helvetica','11px','yellow'])
-. fonts: x축의 tick 값 표시하기 위한 폰트 (기본값 : ['helvetica','11px','gray'])
*** slider
-. colNm : slider 설정 컬럼명
-. scale : linear(V3 : time, ordinal 지원)
-. axisPos : slider축의 tick 값 대비 tick 위치 'top', 'bottom' (기본값 : bottom)
-. ticks : slider축의 표시할 값의 갯수 (기본값 : 10)
-. tickPad : slider축의 표시할 축과 값의 간격 (기본값 : 0)
-. speed : slider당 사용할 시간(ms) (기본값 : 50)
-. labelColor : [색상1, 색상1] (기본값 : ['#185f90', '#1f77b4']), scale은 x barColor 계승.
-. labelFonts : slider 값 표시 폰트 (기본값 : ['240px','ddd'])
-. fonts : slider축 tick 값 표시하기 위한 폰트 (기본값 : ['helvetica','11px','gray'])
*** mark
-. colNm : mark 설정 컬럼명
-. type : bubble
-. opacity : 0 <= n <= 1 (기본값 : 1)
*** radius
-. colNm : radius 설정 컬럼명
-. scale : sqrt,linear,log (기본값 : sqrt)
-. range : [5, 15] (기본값 : [2, 40])
-. radiusSame : 동일 크기 적용 여부
*** color
-. colNm : color 설정 컬럼명
-. color : 10, 20, 20b, 20c (기본값 : 10)
-. solid : linear, radial (기본값 : radial)
*** Measures
-. caption : 컬럼 제목명
-. colNm : 컬럼명
-. format : 정수(,d), 실수(,f 또는 ,.2f), 백분율(% .2%), 상세 내용은 매뉴얼 참조
-. unitNm : 백만, 명 등의 서술적 단위명칭
-. dimX : x축에 사용 가능 여부
-. dimY : y축에 사용 가능 여부
-. dimRadius : 반지름에 사용 가능 여부
-. dimColor : 색상에 사용 가능 여부
*** Options
-. optionWindow
.src: 옵션 버튼 이미지, (기본값: '../assets/images/c2i/gear_notice.png'),
.xPos : left, right
.yPos: top, bottom,
.contextMenu : true, opacity: 0.8, autoClose: 컨텐츠 영역 클릭시 자동 닫힘 여부
*** Tooltip
-. id : 툴팁 Container Id('#'을 붙이세요)
-. infoLevel : 툴팁 상세 정보 수준(0 ~ 3 레벨이며, 기본: 0)
0 : 명칭 + 값 + 점유율 표시
1 : 전체/시리즈/그불별 값,점유율 표시 추가
2 : 전체/시리즈/그불별 랭킹,평균,최대,최소값 표시 추가(V3.0)
3 : 전체/시리즈/그불별 평균,최대,최소값과의 차이값 표시 추가(V3.0)
-. fixedPos : 툴팁을 마우스 포지션에 관계없이 고정위치에 표현하고자 할 경우 사용(기본: xPos:'start', yPos:'top')
미 정의시 클릭한 위치에 표시됩니다.
-. displayTips : 자동 툴팁에서 표시될 팁 데이터 건수(라인과 같이 많은 데이터 존재시, 기본값 2: 한 행에 2개씩 표시)
-. isUserTip : 사용자 제공 툴팁 여부, 사용자 제공 툴팁이면
아래 함수에서 상기의 id에 데이터를 바인딩 처리를 하면 됩니다.
*** method
-. click, mouseenter, mouseleave, mousemove, mousemove
이름과 같은 이벤트 이며, 동 함수들은 여러 곳에서 발생합니다.
또한 개발자는 전달되는 파라메터인 발생 소스(fromSource)와 데이터를 확인하여 추가적인 알고리즘을 처리합니다.
*/
var c2iOption = {
isResponsive:false, width:'100%', aspectRatio:'50%', theme: 'linear-gradient(to bottom, #037bb5, #02111d, #037bb5)', // #444363, lang: 'kr',
margin:{top:60, left:120, right:30, bottom:120}, barLeftMargin: 30,
easing:'linear', duration:750, delay:10,
//bgImg:{src: '../assets/images/c2i/logo_co.png', width: 257, height: 72, opacity: 0.3, xPos:'middle', yPos:'middle'},
data: undefined, preBuildData: true, linearBeginZero: true,
title: {
caption:"국가별 부와 건강 분석", fonts:['맑은 고딕','16px','white'], textDeco:"underline", gap: 5, xPos:'middle', yPos:'top',
subCaption:"('2009년 통계 기준)", subFonts: ['맑은 고딕','12px','#777'], opacity:1,
desc:"모션 차트...!!"
},
xDim: {colNm:'income', scale:'log', axisPos:'bottom', dy:-6, ticks:12, tickPad: 5, showGrid:true,
rotate:-45, maxGap: .1, barColor:['#8c564b', '#70443c', 'radial'], barFonts:['맑은 고딕','11px','yellow'],
fonts:['맑은 고딕','11px','#ccc']},
yDim: {colNm:'lifeExpectancy', scale:'linear', axisPos:'left', dx:10, dy:3, ticks:10, showGrid:true,
maxGap: .1, captionV:true, barColor:['#8c564b', '#C1827A', 'linear'], barFonts:['맑은 고딕','11px','yellow'],
fonts:['맑은 고딕','11px','#ccc']},
slider: {colNm:'time', scale:'linear', axisPos:'top', ticks:12, tickPad: 5,
speed:100, labelColor:['#8c564b', '#70443c'], labelFonts:['180px','#ddd'],
fonts:['맑은 고딕','11px','#ccc']},
mark: { colNm:'name', type:'bubble', opacity: 0.15},
radius: { colNm:'population', scale: 'sqrt', range:[2, 45], radiusSame: false},
color: { colNm:'region', color:'10', solid:'radial'},
rawStructure: {colNm:'measureColName', valNm:'value'},
measures:[
{caption:'일인당 국민소득', colNm:'income', format:',f', unitNm:'$',dimX:true, dimY:true, dimRadius:true, dimColor:true},
{caption:'기대수명', colNm:'lifeExpectancy', format:',.0f', unitNm:'년',dimX:true, dimY:true, dimRadius:true, dimColor:true},
{caption:'인구수', colNm:'population', format:',f', unitNm:'명',dimX:true, dimY:true, dimRadius:true, dimColor:true},
{caption:'년도', colNm:'time', format:'d', unitNm:'', dimX:true, dimY:false, dimRadius:false, dimColor:false},
{caption:'국가', colNm:'name', format:'', unitNm:'', dimX:false, dimY:false, dimRadius:false, dimColor:true},
{caption:'대륙명', colNm:'region', format:'', unitNm:'', dimX:false, dimY:false, dimRadius:false, dimColor:true}
],
optionWindow:{ width: '320px', buttonHide: true, xPos: 'right', yPos: 'top', contextMenu: true, opacity: 0.8, autoClose:true},
tooltip: {id: '#tooltip', infoLevel:1, fixedPos: /*undefined*/{xPos:'start', yPos:'top'}, displayTips: 3, opacity: 0.9, isUserTip: undefined, isShow: true },
method:{click:getClickInfo, mouseenter:getMouseEnterInfo, mouseleave:getMouseLeaveInfo, mousemove: getMouseMoveInfo},
isDev:false
};
var c2iChart = c2i.bi.motion('#c2iChart01', c2iOption);
///////////////////
function getClickInfo(fromSource, data){
console.log(fromSource.container + ',' + fromSource.selector + ' click ');
for(var attr in data){
console.log(attr + ' : ' + data[attr]);
}
}
function getMouseEnterInfo(fromSource, data){
console.log(fromSource.container + ',' + fromSource.selector + ' getMouseEnterInfo')
}
function getMouseLeaveInfo(fromSource, data){
console.log(fromSource.container + ',' + fromSource.selector + ' getMouseLeaveInfo')
}
function getMouseMoveInfo(fromSource, data){
console.log(fromSource.container + ',' + fromSource.selector + ' getMouseMoveInfo');
document.getElementById('name').innerHTML = '상황에 맞는';
document.getElementById('measure').innerHTML = '코딩 확장 구현';
}
///////////////////
changeJsonData();
function changeJsonData(){
var srcData = './assets/data/bi/Facts_Income_Life_Populations_by_nations.json';
d3.json(srcData, function(error, root) {
// Displays an error message
if (error) {
console.error('Error getting or parsing the data.');
throw error;
}
c2iChart.clear().data(root).render();
});
}
function changeData(){
var srcData = './assets/data/bi/rawData.csv';
d3.csv(srcData, function(error, root) {
// Displays an error message
if (error) {
console.error('Error getting or parsing the data.');
throw error;
}
c2iChart.clear();
c2iOption.preBuildData = false;
console.log('CSV 데이터 처리..!!');
c2iChart = c2i.chart.motion('#c2iChart01', c2iOption);
c2iChart.clear().data(root).render();
});
}
</script>
</body>
</html>